-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentity.lua
46 lines (41 loc) · 1.01 KB
/
entity.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
39
40
41
42
43
44
45
46
local entity = love.filesystem.load('animated.lua')()
entity.smoothX = 0
entity.smoothY = 0
function entity:moveRel(x, y)
self.smoothX = self.smoothX + x
self.smoothY = self.smoothY + y
end
function entity:turnLeft()
if self.state == 'down' then
self.state = 'right'
elseif self.state == 'right' then
self.state = 'up'
elseif self.state == 'up' then
self.state = 'left'
elseif self.state == 'left' then
self.state = 'down'
end
end
function entity:turnRight()
if self.state == 'down' then
self.state = 'left'
elseif self.state == 'right' then
self.state = 'down'
elseif self.state == 'up' then
self.state = 'right'
elseif self.state == 'left' then
self.state = 'up'
end
end
function entity:turnAround()
if self.state == 'down' then
self.state = 'up'
elseif self.state == 'right' then
self.state = 'left'
elseif self.state == 'up' then
self.state = 'down'
elseif self.state == 'left' then
self.state = 'right'
end
end
return entity