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



Le Deal du moment : -39%
Pack Home Cinéma Magnat Monitor : Ampli DENON ...
Voir le deal
1190 €

Partagez
 

 [Resolut][RMXP][Script] Pong - Fond d'écran

Voir le sujet précédent Voir le sujet suivant Aller en bas 
AuteurMessage
Invité
Invité
Anonymous


[Resolut][RMXP][Script] Pong - Fond d'écran Empty
MessageSujet: [Resolut][RMXP][Script] Pong - Fond d'écran   [Resolut][RMXP][Script] Pong - Fond d'écran EmptySam 6 Avr 2013 - 18:42

Jour'...

Après les myriades d'éloges entendu a votre sujet, je viens voir en personne le talent presque légendaire des membres de cette prestigieuse assemblée...

C'est donc, très humblement, que je viens vous exposer mon affaire. Il s'agit d'un script de Pong:
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)
  TRAINEE = true
  module_function
  #-------------------------------------------------------------
  # Démarage
  #-------------------------------------------------------------
  def start(score=10)
    Graphics.freeze
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # Points
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    @score = score
    @j1 = @cpu = 0
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # Trainée
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    if TRAINEE
      @trainée = Sprite.new
      @trainée.bitmap = Bitmap.new(640, 480)
      @trainée.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
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # Fond
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    @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
    @trainée.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
      @trainée.bitmap.blt(0, 0, @vide, @vide.rect, 50)
      @trainée.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
Marrant ça... il me paraissait moins long dans l'éditeur du programme... ...

Bref. Je souhaiterai... y ajouter un fond.
Ce n'est pas que le jeux soit moche... ... bien qu'effectivement il soit moche, mais là... c'est l'effet rétro.
C'est comme le Disco... c'était bien a l'époque (quoi que pour le disco c'est pas sur), mais un p'tit coup de jeune lui ferai du bien...
(L'expression "un coup de jeune" n'est pas a prendre de manière littéral... )

Donc... j'ai essayé de bidouiller le grimoire:

- après module Pong:
Code:
FOND_ECRAN = "tetris-bg-test"
puis:
Code:
@fond.bitmap = RPG::Cache.picture(FOND_ECRAN)
Un peu partout dans le script... dont, dans la partie : def refresh
... mais, dans le meilleur des cas j'obtiens le fond d'écran au début, puis dès qu'un point est marqué, il s'efface et ne revient plus.
(ou je commence sans, un point est marqué, paf... il apparait. Un second point arrive et Paf, il disparait sans revenir... )
Et dans le pire des cas... bah... au moins je réussi à ne pas faire planter le programme ^^,

Les deux lignes de code ne sont pas de moi. J'ai essayer une fois de me mettre au Ruby... mais... j'ai décroché à la troisième page de cours ^^,
Du coup, il s'agit de lignes piquées dans le script d'un Tétris... afficher un fond... que se soit pour un Tétris ou un Pong... je ne vois pas la différence ^^,

Sinon, le jeux se lance via la commande script:
Code:
Pong.start

Je suis sur qu'avec une musique adaptée et des images à faire s'évanouir un zèbre ou une chèvre unijambiste ménopausée d’Australie occidentale, nous pourrions, ensemble... oui... ensemble, nous pourrions rendre ce merveilleux Retro-game un peu moins atroce.
Et puis dans l'état, j'aurai vraiment trop honte pour l'associer a mon projet ^^,


Dernière édition par kioresse le Sam 6 Avr 2013 - 20:58, édité 1 fois
Revenir en haut Aller en bas
Seri
Mage (niveau 3)
Mage (niveau 3)
Seri

Masculin
Messages postés : 303
Date d'inscription : 04/12/2012
Jauge LPC :
[Resolut][RMXP][Script] Pong - Fond d'écran 891527140025 / 10025 / 100[Resolut][RMXP][Script] Pong - Fond d'écran 8915271400


[Resolut][RMXP][Script] Pong - Fond d'écran Empty
MessageSujet: Re: [Resolut][RMXP][Script] Pong - Fond d'écran   [Resolut][RMXP][Script] Pong - Fond d'écran EmptySam 6 Avr 2013 - 18:57

Salut !

La solution de Cantarelle est bien meilleure Wink

~Seri


Dernière édition par Seri le Sam 6 Avr 2013 - 19:59, édité 1 fois
Revenir en haut Aller en bas
Cantarelle
Ancien staffeux
Ancien staffeux
Cantarelle

Féminin
Messages postés : 353
Date d'inscription : 26/10/2012
Jauge LPC :
[Resolut][RMXP][Script] Pong - Fond d'écran 891527140049 / 10049 / 100[Resolut][RMXP][Script] Pong - Fond d'écran 8915271400

[Resolut][RMXP][Script] Pong - Fond d'écran Dessinateurq
[Resolut][RMXP][Script] Pong - Fond d'écran Charamaker
[Resolut][RMXP][Script] Pong - Fond d'écran Graphi10
[Resolut][RMXP][Script] Pong - Fond d'écran Script10


[Resolut][RMXP][Script] Pong - Fond d'écran Empty
MessageSujet: Re: [Resolut][RMXP][Script] Pong - Fond d'écran   [Resolut][RMXP][Script] Pong - Fond d'écran EmptySam 6 Avr 2013 - 19:43

Bon, je t'ai fait le truc. Change le code avec celui-ci :


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

J'ai ajouté la contante : IMAGE_BACKGROUND. C'est là que sera stocké la chaîne de caractère de ton image (attention, sans extension. Si ton image est en PNG, JPG ou autre, pas la peine de mettre le .PNG etc...
J'en ai aussi profité pour changer un attribut. Rien ne doit pas avoir de caratères spéciaux (dans le script de corbaque, il y a un é dans @trainée, je l'ai changé en @trainee).

Normalement, ça marche.
Mais le code est vraiment scripté comme de la merde... Ca se voit que c'est un de ses premiers scripts.


Edit pour Seri : ce que tu as pointé est uniquement pour l'écriture. Il fallait créer un nouvel attribut et surtout le placer après la partie Trainée (qui cache tout sinon...)
Revenir en haut Aller en bas
Seri
Mage (niveau 3)
Mage (niveau 3)
Seri

Masculin
Messages postés : 303
Date d'inscription : 04/12/2012
Jauge LPC :
[Resolut][RMXP][Script] Pong - Fond d'écran 891527140025 / 10025 / 100[Resolut][RMXP][Script] Pong - Fond d'écran 8915271400


[Resolut][RMXP][Script] Pong - Fond d'écran Empty
MessageSujet: Re: [Resolut][RMXP][Script] Pong - Fond d'écran   [Resolut][RMXP][Script] Pong - Fond d'écran EmptySam 6 Avr 2013 - 19:58

Canta > je vois. Décidément le RGSS est bien différent du vrai Ruby ....

~Seri
Revenir en haut Aller en bas
Invité
Invité
Anonymous


[Resolut][RMXP][Script] Pong - Fond d'écran Empty
MessageSujet: Re: [Resolut][RMXP][Script] Pong - Fond d'écran   [Resolut][RMXP][Script] Pong - Fond d'écran EmptySam 6 Avr 2013 - 20:57

Les rumeurs semblaient fondées...
Je te remercie Cantarelle pour ton intervention rapide et... rapide.
(je te laisse changer le dernier mot par un terme qui te glorifierai d'avantage.)

Tout fonctionne comme je l'espérait... ce n'est plus qu'une question de temps avant que le phénomène Pong ne déferle une fois de plus sur le monde... noyant tout les geek retro de la planète... (rire maléfique effrayant)

@Seri: J'espère que je n'aurai jamais besoin de ton aide... ... sans vouloir te vexer, cela ne me ferai pas plaisir de me retrouver dans le -----. Mais si le cas devait se présenter, j’appréciai surement beaucoup que tu me soutienne dans un projet de conquête du monde.

En un mot comme en cent: どうもありがとうございました.
[Resolut][RMXP][Script] Pong - Fond d'écran Salut
Revenir en haut Aller en bas
Cantarelle
Ancien staffeux
Ancien staffeux
Cantarelle

Féminin
Messages postés : 353
Date d'inscription : 26/10/2012
Jauge LPC :
[Resolut][RMXP][Script] Pong - Fond d'écran 891527140049 / 10049 / 100[Resolut][RMXP][Script] Pong - Fond d'écran 8915271400

[Resolut][RMXP][Script] Pong - Fond d'écran Dessinateurq
[Resolut][RMXP][Script] Pong - Fond d'écran Charamaker
[Resolut][RMXP][Script] Pong - Fond d'écran Graphi10
[Resolut][RMXP][Script] Pong - Fond d'écran Script10


[Resolut][RMXP][Script] Pong - Fond d'écran Empty
MessageSujet: Re: [Resolut][RMXP][Script] Pong - Fond d'écran   [Resolut][RMXP][Script] Pong - Fond d'écran EmptySam 6 Avr 2013 - 21:39

Seri : Et tu peux m'expliquer ce qu'est du VRAI Ruby ?

Le RGSS n'est qu'une bibliothèque. C'est-à-dire qu'en plus des fonctions et des principes de bases du langage Ruby, tu as des fonctions et des classes en plus liées à la bibliothèque RGSS (Sprite, Bitmap ou le module RPG). Les méthodes de Ruby fonctionnent en RGSS (tu peux utiliser, pour un tableau, la fonction uniq! par exemple).
C'est comme avec Java. Ce n'est pas parce que tu utilises la bibliothèque Swing ou Awt que tu n'as plus les fonctionnalités du langage Java.

Donc, arrête de sortir des énormités pareilles. Surtout que c'est la deuxième fois que tu sors ça.


Sans compter que le code de Corbaque était commenté (pour une fois que ça arrive). Puis, sérieusement, si tu n'arrives pas à comprendre que ça : @fond.bitmap.font.name, c'est pour la police d'écriture...
Un conseil : ne touche plus à du code.
Revenir en haut Aller en bas
Zexion
Administrateur
Administrateur
Zexion

Masculin
Messages postés : 6228
Date d'inscription : 04/01/2012
Jauge LPC :
[Resolut][RMXP][Script] Pong - Fond d'écran 891527140097 / 10097 / 100[Resolut][RMXP][Script] Pong - Fond d'écran 8915271400

[Resolut][RMXP][Script] Pong - Fond d'écran Membre15
[Resolut][RMXP][Script] Pong - Fond d'écran Event-10
[Resolut][RMXP][Script] Pong - Fond d'écran Altrui10
[Resolut][RMXP][Script] Pong - Fond d'écran Action10
[Resolut][RMXP][Script] Pong - Fond d'écran Travai10
[Resolut][RMXP][Script] Pong - Fond d'écran Collec10
[Resolut][RMXP][Script] Pong - Fond d'écran Collec11
[Resolut][RMXP][Script] Pong - Fond d'écran Collec12
[Resolut][RMXP][Script] Pong - Fond d'écran Staffe11
[Resolut][RMXP][Script] Pong - Fond d'écran Dessin10


[Resolut][RMXP][Script] Pong - Fond d'écran Empty
MessageSujet: Re: [Resolut][RMXP][Script] Pong - Fond d'écran   [Resolut][RMXP][Script] Pong - Fond d'écran EmptySam 6 Avr 2013 - 22:04

Je pense qu'il est des façons plus adaptées de se parler, en bonne intelligence.

Quoi qu'il en soit, je remercie les différents intervenants, que je récompense comme il se faut en points.

Kioresse : bienvenue, j'espère que tu prendras ton pied ici. =)
N'hésite pas à aller te présenter si tu en as l'envie, pour qu'on puisse mieux te connaître.
Revenir en haut Aller en bas
Contenu sponsorisé




[Resolut][RMXP][Script] Pong - Fond d'écran Empty
MessageSujet: Re: [Resolut][RMXP][Script] Pong - Fond d'écran   [Resolut][RMXP][Script] Pong - Fond d'écran Empty

Revenir en haut Aller en bas
 
[Resolut][RMXP][Script] Pong - Fond d'écran
Voir le sujet précédent Voir le sujet suivant Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» [RMXP]Script affichant le level up.
» RMXP bug script (window_selectable)
» [RMXP] Modification du script Ring Menu
» [RMXP] Bug Script Bestiaire [Résolu]
» [RMXP] Problème de script MogHunter

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
Le Palais Créatif :: ~ APPRENTISSAGE ~ :: Entraide :: Problèmes résolus-
Sauter vers: