-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgame.rb
More file actions
30 lines (27 loc) · 733 Bytes
/
game.rb
File metadata and controls
30 lines (27 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
@x = 100
@y = 100
def on_key_press(input)
puts "Called on_key_press method with input: #{input.inspect}"
case input
when :left, 'Left' then @x -= 10
when :right, 'Right' then @x += 10
when :up, 'Up' then @y -= 10
when :down, 'Down' then @y += 10
end
puts "Current x/y: #{@x}, #{@y}"
end
def while_key_down(input)
# puts "Called while_key_down method with input: #{input.inspect}"
case input
when :left, 'Left' then @x -= 10
when :right, 'Right' then @x += 10
when :up, 'Up' then @y -= 10
when :down, 'Down' then @y += 10
end
# puts "Current x/y: #{@x}, #{@y}"
end
def render
Engine.draw_square(@x, @y, 100) # call C code
rescue => e
puts "Error in render: " + e.message
end