class RubyFighter::Controls
Constants
- PLAYER1
- PLAYER2
Public Class Methods
new(window, player, num)
click to toggle source
# File lib/ruby_fighter/controls.rb, line 20 def initialize(window, player, num) @window = window @player = player @keys = [PLAYER1, PLAYER2][num-1] end
Public Instance Methods
update(left, right)
click to toggle source
# File lib/ruby_fighter/controls.rb, line 26 def update(left, right) case matching_action when :left then @player.move_left if @player.left > left when :right then @player.move_right if @player.right < right end end
Private Instance Methods
matching_action()
click to toggle source
# File lib/ruby_fighter/controls.rb, line 48 def matching_action @keys.each do |key, action| if @window.button_down? key return action end end end