-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTileObs.lua
46 lines (42 loc) · 1.14 KB
/
TileObs.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
TileObs = Class{__includes = Rectangle}
if TILE_SIZE==nil then
TILE_SIZE=50
end
TILE_VEC= Vector(TILE_SIZE,TILE_SIZE)
math.randomseed(os.time())
function TileObs:init(t)
Rectangle.init(self,Vector(t.x,t.y),Vector(t.w or TILE_SIZE,t.h or TILE_SIZE))
if t.color==nil then
self.color={ math.random(),math.random() ,math.random()}
else
self.color=t.color
end
self.obst=t.obst or 0 --boolens to remove Edges
end
function TileObs:Draw()
if self.color~=nil then
love.graphics.setColor(self.color)
end
Rectangle.Draw(self)
end
function TileObs:Type()
return "Tile"
end
function TileObs:OpEdgesP(point)
local result ={}
local vertices=Rectangle.findVertices(self)
self.edges=Rectangle.Edges(self)
if point.x < self.b.x and math.floor(self.obst/2)%2==0 then
table.insert(result,self.edges[1])
end
if point.x > self.c.x and math.floor(self.obst/8)%2==0 then
table.insert(result,self.edges[3])
end
if point.y < self.b.y and math.floor(self.obst/4)%2==0 then
table.insert(result,self.edges[0])
end
if point.y > self.c.y and self.obst%2==0 then
table.insert(result,self.edges[2])
end
return result
end