Method: AMazeIng::GameWindow#button_down

Defined in:
lib/a_maze_ing/game_window.rb

#button_down(id) ⇒ Object



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/a_maze_ing/game_window.rb', line 173

def button_down(id)
  if id == Gosu::KB_LEFT
    check_available_move(3, @player)
  end

  if id == Gosu::KB_RIGHT
    check_available_move(1, @player)
  end

  if id == Gosu::KB_UP
    check_available_move(0, @player)
  end
  
  if id == Gosu::KB_DOWN
    check_available_move(2, @player)
  end

  # control keys for player 2
  if @game_mode == 2 or @game_mode == 3

    if id == Gosu::KB_A
      check_available_move(3, @player_2)
    end

    if id == Gosu::KB_D
      check_available_move(1, @player_2)
    end

    if id == Gosu::KB_W
      check_available_move(0, @player_2)
    end
    
    if id == Gosu::KB_S
      check_available_move(2, @player_2)
    end

  end

  if id == Gosu::KB_ESCAPE
    close
  else
    super
  end
end