Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Initiation à Gosu

Initiation à Gosu

Initiation à la création de jeux 2D avec Gosu

Matthieu Segret

November 05, 2013
Tweet

More Decks by Matthieu Segret

Other Decks in Technology

Transcript

  1. gem install gosu require 'gosu' class GameWindow < Gosu::Window def

    initialize super(640, 480, false) self.caption = "Human Coders Game" end end window = GameWindow.new window.show Affichage d’une fenêtre
  2. class GameWindow < Gosu::Window def initialize super(640, 480, false) self.caption

    = "Gosu Tutorial Game" @background_image = Gosu::Image.new(self, "images/background.png", true) end def draw @background_image.draw(0, 0, 0) end end Affichage de l’image de fond
  3. def initialize ... @player = Gosu::Image.new(self, "images/player.png", true) @player_x, @player_y

    = 550, 400 end def update @player_x -= 1 if button_down? Gosu::Button::KbLeft @player_x += 1 if button_down? Gosu::Button::KbRight @player_y -= 1 if button_down? Gosu::Button::KbUp @player_y += 1 if button_down? Gosu::Button::KbDown end def draw ... @player.draw(@player_x, @player_y, 1) end Déplacement du joueur