-
Notifications
You must be signed in to change notification settings - Fork 0
/
boss.lua
38 lines (29 loc) · 801 Bytes
/
boss.lua
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
boss = Class{}
function boss:init(x, y,hp)
self.x = x
self.y = y
self.hp = 1000
self.image = love.graphics.newImage("sprites/Boss.png")
self.width = self.image:getWidth()
self.height = self.image:getHeight()
self.hit = false
end
function boss:render()
if self.hit == true then
return
else
love.graphics.draw(self.image, self.x, self.y, 0, 1, 1, self.width, self.height)
love.graphics.printf('Boss: '..math.floor(self.hp),0,15,1280,'center')
end
self.hp = self.hp + 0.1
end
function boss:check(lazer)
if lazer.y-60 == self.y and lazer.x > self.x-60 and lazer.x < self.x+60 and self.hit == false and self.hp ~= 0 and lazer.hit == false then
self.hp = self.hp - 10
return "hitw/hp"
end
if self.hp <= 0 and self.hit == false then
self.hit = true
return true
end
end