forked from HRCK0/Space_Invaders_Remastered
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enemy.rb
55 lines (45 loc) · 880 Bytes
/
enemy.rb
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
51
52
53
54
55
class Enemy
@@speed = 4
attr_reader :x, :y, :radius
def initialize(window, level)
@radius = 50
@x = rand(window.width - 2*@radius)+@radius
@y = 0
randint = rand((level/2).to_i..level)
if randint <= 2
@image = Gosu::Image.new('SPRITES/enemysprite3.png')
@health = 1
@pGo = 1
elsif randint <= 4
@image = Gosu::Image.new('SPRITES/enemysprite2.png')
@health = 2
@pGo = 2
elsif randint > 4
@image = Gosu::Image.new('SPRITES/enemysprite.png')
@health = 3
@pGo = 3
end
#@speed = 4
end
def decrease_hp
@health -= 1
end
def get_health
@health
end
def get_pt
@pGo
end
def speed_up(level)
@@speed += 0.1*level
end
def reset_speed
@@speed = 4
end
def move
@y += @@speed
end
def draw
@image.draw(@x-@radius, @y-@radius, 1)
end
end