forked from NoahMilam/ruby_shootemup
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.rb
More file actions
44 lines (40 loc) · 671 Bytes
/
Copy pathplayer.rb
File metadata and controls
44 lines (40 loc) · 671 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
class Ship
attr_reader :x, :y, :w, :h
def initialize(window)
@image = Gosu::Image.new(window,'Gship.png',false)
@x = 350
@y = 550
@w =60
@h = 55
@moveShip = 5
end
# chage me when you get final ship drawn
def hitBox
hitbox_x = ((@x).to_i..(@x + @image.width).to_i).to_a
hitbox_y = ((@y).to_i..(@y + @image.height).to_i).to_a
{:x => hitbox_x, :y => hitbox_y}
end
def moveLeft
if x >= 0
@x -= @moveShip
end
end
def moveRight
if x <= 730
@x += @moveShip
end
end
def moveUp
if y >= 0
@y -= @moveShip
end
end
def moveDown
if y <= 550
@y += @moveShip
end
end
def draw
@image.draw(@x,@y,StageLayer)
end
end