Class: RubyFighter::Game

Inherits:
Gosu::Window
  • Object
show all
Defined in:
lib/ruby_fighter/game.rb

Instance Method Summary collapse

Constructor Details

#initializeGame

Returns a new instance of Game.



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/ruby_fighter/game.rb', line 4

def initialize
  super(768, 480, false)
  self.caption = "Ruby Fighter"

  @backdrop  = Backdrop.new(self, "background-1.jpg")

  @player1   = Player.new(self, "ryu", false)
  @player2   = Player.new(self, "chun-li", true)

  @controls1 = Controls.new(self, @player1, 1)
  @controls2 = Controls.new(self, @player2, 2)
end

Instance Method Details

#button_down(id) ⇒ Object



29
30
31
32
# File 'lib/ruby_fighter/game.rb', line 29

def button_down(id)
  @controls1.button_down button_id_to_char(id)
  @controls2.button_down button_id_to_char(id)
end

#button_down?(char) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/ruby_fighter/game.rb', line 39

def button_down?(char)
  super char_to_button_id(char)
end

#button_up(id) ⇒ Object



34
35
36
37
# File 'lib/ruby_fighter/game.rb', line 34

def button_up(id)
  @controls1.button_up button_id_to_char(id)
  @controls2.button_up button_id_to_char(id)
end

#drawObject



17
18
19
20
21
22
# File 'lib/ruby_fighter/game.rb', line 17

def draw
  @backdrop.draw

  @player1.draw
  @player2.draw
end

#updateObject



24
25
26
27
# File 'lib/ruby_fighter/game.rb', line 24

def update
  @controls1.update 0, @player2.left
  @controls2.update @player1.right, width
end