-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshield.lua
More file actions
executable file
·34 lines (30 loc) · 960 Bytes
/
shield.lua
File metadata and controls
executable file
·34 lines (30 loc) · 960 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
Shield = {}
-- Constructor
function Shield:new()
require 'character'
local char = Character:new()
local object = {
name = 'shield',
image = love.graphics.newImage('img/player/player_shield.png'),
protectZoneImage = love.graphics.newImage('img/player/protectZone.png'),
shieldPoints = 0,
protecting = false,
}
setmetatable(self, {__index = char })
setmetatable(object, {__index = Shield })
return object
end
function Shield:draw()
if self.protecting then
for i=(math.max(0, self.x-self.shieldPoints)), (math.min(BOARD_X_SIZE, self.x+self.shieldPoints)) do
for j=(math.max(0, self.y-self.shieldPoints)), (math.min(BOARD_Y_SIZE, self.y+self.shieldPoints)) do
draw_on_tile(self.protectZoneImage, i, j)
end
end
end
Character.draw(self)
end
function Shield:protect(points)
self.protecting = true
self.shieldPoints = points
end