-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmovement.rb
More file actions
50 lines (44 loc) · 831 Bytes
/
movement.rb
File metadata and controls
50 lines (44 loc) · 831 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
module Movement
def move
if @game_window.button_down? Gosu::Button::KbLeft
move_left
end
if @game_window.button_down? Gosu::Button::KbRight
move_right
end
if @game_window.button_down? Gosu::Button::KbDown
move_down
end
if @game_window.button_down? Gosu::Button::KbUp
move_up
end
end
def move_left
if @x < 0
@x = 0
else
@x = @x - 10
end
end
def move_right
if @x > (@game_window.width - @icon.width)
@x = @game_window.width - @icon.width
else
@x = @x + 10
end
end
def move_up
if @y < 0
@y = 0
else
@y = @y - 10
end
end
def move_down
if @y >(@game_window.height - @icon.height)
@y = @game_window.height - @icon.height
else
@y = @y + 10
end
end
end