Accueil du SiteAccueil du Site  AccueilAccueil  Dernières imagesDernières images  RechercherRechercher  ConnexionConnexion  S'enregistrerS'enregistrer  



Le Deal du moment : -40%
-40% sur le Pack Gaming Mario PDP Manette filaire + ...
Voir le deal
29.99 €

Partagez
 

 Pong Verticale

Voir le sujet précédent Voir le sujet suivant Aller en bas 
AuteurMessage
Diorm
Paysan (niveau 1)
Paysan (niveau 1)
Diorm

Messages postés : 2
Date d'inscription : 09/10/2014
Jauge LPC :
Pong Verticale 89152714000 / 1000 / 100Pong Verticale 8915271400


Pong Verticale Empty
MessageSujet: Pong Verticale   Pong Verticale EmptyJeu 9 Oct 2014 - 14:48

Je me demandais si il était possible de transformer ce script de PONG en PONG verticale. Ce que j'entend par cela c'est que notre barre serait en bas et celle du CPU en haut. Est-ce possible?

Code:
#===================================
# Pong 1.0
#---------------------------------------------------------------
# Le grand classique adapté à RPG Maker XP
#---------------------------------------------------------------
# Créé par Corbaque (03/06/2007)
#---------------------------------------------------------------
# Appeller le mini jeu :
# Pong.start(10)
# 10 est le nombre de points pour gagner
#===================================
module Pong
  #-------------------------------------------------------------
  # Options
  #-------------------------------------------------------------
  # Remplacer par le nom du fichier sans
  # extension (dossier Pictures) si vous voulez
  # une image pour les barres (redimensionné
  # en jeu)
  BARRE_PERSO = false
  # Remplacer par le nom du fichier sans
  # extension (dossier Pictures) si vous voulez
  # une image pour la balle (redimensionné en
  # jeu)
  BALLE_PERSO = false
  COULEUR_JOUEUR_1 = Color.new(255, 100, 100, 255)
  COULEUR_JOUEUR_2 = Color.new(100, 100, 255, 255)
  IMAGE_BACKGROUND = "LE_NOM_DE_MON_IMAGE_DANS_PICTURE_SANS_L_EXTENSION"
  TRAINEE = true
  module_function
 
  #-------------------------------------------------------------
  # Démarage
  #-------------------------------------------------------------
  def start(score=10)
   
    Graphics.freeze
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # Points
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    @score = score
    @j1 = @cpu = 0
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # Trainée
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    if TRAINEE
      @trainee = Sprite.new
      @trainee.bitmap = Bitmap.new(640, 480)
      @trainee.bitmap.fill_rect(0, 0, 640, 480, Color.new(0, 0, 0))
      @vide = Bitmap.new(640, 480)
      @vide.fill_rect(0, 0, 640, 480, Color.new(0, 0, 0))
    end
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # image_Background
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    @imagebackground = Sprite.new
    @imagebackground.bitmap = RPG::Cache.picture(IMAGE_BACKGROUND)   
   
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # Police
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    @fond = Sprite.new
    @fond.bitmap = Bitmap.new(640, 480)
    @fond.bitmap.font.name = "Lucida Console"
    @fond.bitmap.font.size = 72
    @fond.bitmap.draw_text(0, 0, 640, 200, "0 - 0", 1)
    @fond.bitmap.font.size = 30
    @fond.bitmap.draw_text(0, 280, 640, 200, "Score à atteindre : #{@score}", 1)
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # Barres
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    @barre_1 = Sprite.new
    @barre_1.bitmap = Bitmap.new(20, 100)
    @barre_2 = Sprite.new
    @barre_2.bitmap = @barre_1.bitmap
    @gls_1 = @gls_2 = 0.0
    if BARRE_PERSO
      pic = RPG::Cache.picture(BARRE_PERSO)
      @barre_1.bitmap.stretch_blt(@barre_1.bitmap.rect, pic, pic.rect)
    else
      # Remplissage
      @barre_1.bitmap.fill_rect(0, 0, 20, 100, Color.new(255, 255, 255))
      # Contour noir, haut
      @barre_1.bitmap.fill_rect(0, 0, 20, 2, Color.new(0, 0, 0, 122.5))
      # Gauche
      @barre_1.bitmap.fill_rect(0, 0, 2, 100, Color.new(0, 0, 0, 122.5))
      # Droite
      @barre_1.bitmap.fill_rect(18, 0, 2, 100, Color.new(0, 0, 0, 122.5))
      # Bas
      @barre_1.bitmap.fill_rect(0, 98, 20, 2, Color.new(0, 0, 0, 122.5))
    end
    # Repère
    @barre_1.oy = @barre_2.oy = 50
    # Position
    @barre_1.y = @barre_2.y = 240
    @barre_2.x = 620
    # Couleur
    @barre_1.color = COULEUR_JOUEUR_1
    @barre_2.color = COULEUR_JOUEUR_2
   
   
   
   
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # Balle
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    @balle = Sprite.new
    # Position
    @balle.ox = @balle.oy = 10
    @balle.x, @balle.y = 320, 240
    @balle.angle = 135 + rand(90)
    @balle_float_x = @balle_float_y = 0.0
    @balle_veloc = 5
    @rotate = 0
    # Apparence
    @balle.bitmap = Bitmap.new(20, 20)
    if BALLE_PERSO
      pic = RPG::Cache.picture(BALLE_PERSO)
      @barre_1.bitmap.stretch_blt(@balle.bitmap.rect, pic, pic.rect)
    else
      20.times do |x|
        20.times do |y|
          r = Math.hypot(10-x, 10-y).to_i
          if r < 10
            @balle.bitmap.set_pixel(x, y, Color.new(255, 255, 255))
          end
        end
      end
    end
    @fin = false
   
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # Intro
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    @masque = Sprite.new
    @masque.bitmap = Bitmap.new(640, 480)
    @masque.bitmap.fill_rect(0, 0, 640, 480, Color.new(0, 0, 0))
    @masque.z = 200
    @t = Sprite.new
    @t.bitmap = Bitmap.new(400, 200)
    @t.x = 320
    @t.y = 100
    @t.ox = 200
    @t.zoom_x = 1.5
    @t.zoom_y = 1.5
    @t.bitmap.font.name = "Lucida Console"
    @t.bitmap.font.size = 30
    @t.bitmap.draw_text(0, 0, 400, 200, "Score à atteindre : #{@score}", 1)
    @t.z = 250   

    Graphics.transition(10)
    Graphics.freeze
    @t.z = 250
    Graphics.transition(20)
    31.times do |i|
      Graphics.update
      @t.y = i * 180 / 30 + 100
      @t.zoom_x = 1.5 - i / 60.0
      @t.zoom_y = 1.5 - i / 60.0
    end
    Graphics.freeze
    @t.dispose
    @masque.z = -1
    Graphics.transition(20)
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # Boucle de jeu
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    until @fin
      Graphics.update
      Input.update
      update()
    end
    @victoire = @fin == 1
    Graphics.freeze
    @masque.z = 200
    @t = Sprite.new
    @t.bitmap = Bitmap.new(400, 200)
    @t.x = 320
    @t.y = 100
    @t.ox = 200
    @t.bitmap.font.name = "Lucida Console"
    @t.bitmap.font.size = 30
    if @fin == 1
      @t.bitmap.draw_text(0, 0, 400, 200, "Victoire", 1)
    else
      @t.bitmap.draw_text(0, 0, 400, 200, "Défaite", 1)
    end
    @score = "#{@j1} - #{@cpu}"
    Graphics.transition(20)
    Graphics.freeze
    @t.z = 250
    Graphics.transition(20)
    20.times { Graphics.update }
    Graphics.freeze
    @t.dispose
    Graphics.transition(20)
    Graphics.freeze
    @masque.dispose
    @balle.dispose
    @barre_1.dispose
    @barre_2.dispose
    @trainee.dispose
    @imagebackground.dispose
    @fond.dispose
    Graphics.transition(10)
  end
  #-------------------------------------------------------------
  # Mise à jour
  #-------------------------------------------------------------
  def update
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # Déplacement joueur
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    if Input.press?(Input::UP) and @barre_1.y > 50
      @barre_1.y -= 5
      @gls_1 -= 1 if @gls_1 < 10
    elsif Input.press?(Input::DOWN) and @barre_1.y < 430
      @barre_1.y += 5
      @gls_1 += 1 if @gls_1 < 10
    else
      @gls_1 = 0
    end
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # Déplacement CPU
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    dis = (@balle.y - @barre_2.y)
    if dis.abs > 10 and @balle.x >= 300
      if (dis > 0 and @barre_2.y < 430) or (dis < 0 and @barre_2.y > 50)
        @gls_2 += dis <=> 0 if @gls_2 < 10 and @gls_2 > 10
        @barre_2.y += (dis <=> 0) * 5
      end
    else
      @gls_2 = 0
    end
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # Déplacement balle
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    vx = Math.cos(@balle.angle * Math::PI / 180) * @balle_veloc
    vy = Math.sin(@balle.angle * Math::PI / 180) * @balle_veloc
    @balle.x += vx.to_i + @balle_float_x.to_i
    @balle.y += vy.to_i + @balle_float_y.to_i
    @balle_float_x += (vx - vx.to_i) - @balle_float_x.to_i
    @balle_float_y += (vy - vy.to_i) - @balle_float_y.to_i
    @balle.angle += @rotate
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # Trainée
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    if TRAINEE
      @trainee.bitmap.blt(0, 0, @vide, @vide.rect, 50)
      @trainee.bitmap.blt(@balle.x-10, @balle.y-10, @balle.bitmap, @balle.bitmap.rect)
    end
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # Contactes
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # Haut/bas
    unless @balle.y.between?(10, 470)
      @balle.angle *= -1
      @balle.y = [[11, @balle.y].max, 469].min
    end
    # Gauche/droite
    if @balle.x <= 0
      @cpu += 1
      refresh()
      @balle.x = 320
      @balle.y = 240
      @balle.angle = 45 - rand(90) + rand(2) * 180
      20.times do |x|
        20.times do |y|
          c = Color.new(255, 255, 255)
          c.alpha = @balle.bitmap.get_pixel(x, y).alpha
          @balle.bitmap.set_pixel(x, y, c)
        end
      end
      @rotate = 0
      @balle_veloc = 5
    elsif @balle.x >= 640
      @j1 += 1
      refresh()
      @balle.x = 320
      @balle.y = 240
      @balle.angle = 45 - rand(90) + rand(2) * 180
      20.times do |x|
        20.times do |y|
          c = Color.new(255, 255, 255)
          c.alpha = @balle.bitmap.get_pixel(x, y).alpha
          @balle.bitmap.set_pixel(x, y, c)
        end
      end
      @rotate = 0
      @balle_veloc = 5
    # Barre joueur
    elsif @balle.x <= 30
      if @balle.y.between?(@barre_1.y-50, @barre_1.y+50)
        @balle.angle =  -@balle.angle + 180 + @gls_1
        if (@balle.angle > 180 and @gls_1 > 0) or (@balle.angle < 180 and @gls_1 < 0)
          @rotate = @gls_1 / 20.0
        else
          @rotate = 0
        end
        @balle.x = 30
        @balle_veloc += 0.5
        c = COULEUR_JOUEUR_1.clone
        20.times do |x|
          20.times do |y|
            c.alpha = @balle.bitmap.get_pixel(x, y).alpha
            @balle.bitmap.set_pixel(x, y, c)
          end
        end
      end
    # Barre CPU
    elsif @balle.x >= 610
      if @balle.y.between?(@barre_2.y-50, @barre_2.y+50)
        @balle.angle = -@balle.angle + 180 + @gls_2
        if (@balle.angle > 0 and @gls_2 > 0) or (@balle.angle < 0 and @gls_1 < 0)
          @rotate = @gls_2 / 20.0
        else
          @rotate = 0
        end
        @balle.x = 610
        @balle_veloc += 0.1
        c = COULEUR_JOUEUR_2.clone
        20.times do |x|
          20.times do |y|
            c.alpha = @balle.bitmap.get_pixel(x, y).alpha
            @balle.bitmap.set_pixel(x, y, c)
          end
        end
      end
    end
  end
  #-------------------------------------------------------------
  # Rafraichissement
  #-------------------------------------------------------------
  def refresh
    @fond.bitmap.clear
    @fond.bitmap.font.size = 75
    @fond.bitmap.draw_text(0, 0, 640, 200, "#{@j1} - #{@cpu}", 1)
    @fond.bitmap.font.size = 30
    @fond.bitmap.draw_text(0, 200, 640, 200, "Score à atteindre : #{@score}", 1)
    if @j1 == @score
      @fin = 1
    elsif @cpu == @score
      @fin = 2
    end
  end
  #-------------------------------------------------------------
  # Score
  #-------------------------------------------------------------
  def score
    return @score
  end
  #-------------------------------------------------------------
  # Victoire
  #-------------------------------------------------------------
  def victoire
    return @victoire
  end
end
Revenir en haut Aller en bas
Jin
Ancien staffeux
Ancien staffeux
Jin

Masculin
Messages postés : 8557
Date d'inscription : 08/12/2010
Jauge LPC :
Pong Verticale 891527140069 / 10069 / 100Pong Verticale 8915271400

G 1 petit zizi Very Happy
Nn C pa vré Sad
Pong Verticale Membre15
Pong Verticale Partag10
Pong Verticale Travai10
Pong Verticale Event-10
Pong Verticale Altrui10
Pong Verticale Riche_10
Pong Verticale Couhil10
Pong Verticale Nain_p11
Pong Verticale Connar10


Pong Verticale Empty
MessageSujet: Re: Pong Verticale   Pong Verticale EmptyJeu 9 Oct 2014 - 16:11

Tout est possible.
A condition de trouver quelqu'un qui puisse le faire.
Revenir en haut Aller en bas
Hellper
Chevalier Dragon (niveau 5)
Chevalier Dragon (niveau 5)
Hellper

Masculin
Messages postés : 1190
Date d'inscription : 04/03/2013
Jauge LPC :
Pong Verticale 891527140086 / 10086 / 100Pong Verticale 8915271400


Pong Verticale Membre15
Pong Verticale Membre10
Pong Verticale Altrui10
Pong Verticale Event-10
Pong Verticale Script10
Pong Verticale Projet16
Pong Verticale Riche_10
Pong Verticale King_o10
Pong Verticale Collec10


Pong Verticale Empty
MessageSujet: Re: Pong Verticale   Pong Verticale EmptyJeu 9 Oct 2014 - 17:09

Je ferais ça si j'en ai le temps.
Revenir en haut Aller en bas
http://kustomskromatiks.byethost17.com/
Diorm
Paysan (niveau 1)
Paysan (niveau 1)
Diorm

Messages postés : 2
Date d'inscription : 09/10/2014
Jauge LPC :
Pong Verticale 89152714000 / 1000 / 100Pong Verticale 8915271400


Pong Verticale Empty
MessageSujet: Re: Pong Verticale   Pong Verticale EmptyVen 10 Oct 2014 - 2:47

Je voudrais bien tenter d'inverser quelques variables mais je ne veux pas me risquer avec mes maigres connaissances et rendre le jeu injouable Sad
Revenir en haut Aller en bas
Contenu sponsorisé




Pong Verticale Empty
MessageSujet: Re: Pong Verticale   Pong Verticale Empty

Revenir en haut Aller en bas
 
Pong Verticale
Voir le sujet précédent Voir le sujet suivant Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» Jam Pong
» [Resolut][RMXP][Script] Pong - Fond d'écran

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
Le Palais Créatif :: ~ APPRENTISSAGE ~ :: Entraide :: Scripts et plugins-
Sauter vers: