-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLowerObstacles.lua
More file actions
53 lines (46 loc) · 1.59 KB
/
LowerObstacles.lua
File metadata and controls
53 lines (46 loc) · 1.59 KB
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
LowerObstacles = {}
LowerObstacles.fun = math.sin
LowerObstacles.speed = Background.speed
LowerObstacles.startY = 50
LowerObstacles.scale = 14
LowerObstacles.xPos = 10 --%1600
local NUM_VERTS=100
function LowerObstacles:move(dt)
LowerObstacles.xPos=(LowerObstacles.xPos+dt*LowerObstacles.speed)%2000
end
function LowerObstacles:draw()
local verticies = {}
--Lower right
verticies [#verticies+1]=love.graphics.getWidth()
verticies [#verticies+1]= love.graphics.getHeight()
--Lower left
verticies [#verticies+1]=0
verticies [#verticies+1]=love.graphics.getHeight()
for i=0,NUM_VERTS do
verticies [#verticies+1]=i*(love.graphics.getWidth()/NUM_VERTS)
verticies [#verticies+1]=LowerObstacles:getY(verticies[#verticies])
--love.graphics.circle("fill", verticies [#verticies-1], verticies [#verticies], 4, 20)
end
--love.graphics.polygon("fill", unpack(verticies) )
end
function LowerObstacles:getY(pointX)
return love.graphics.getHeight()-( LowerObstacles.startY + LowerObstacles.scale*LowerObstacles.fun((pointX+LowerObstacles.xPos)/20) )
end
function LowerObstacles:isPointOverLapped(pointX,pointY)
if LowerObstacles:getY(pointX) < pointY then
return true
else
return false
end
end
function LowerObstacles:isPlayerOverLapping(player)
--Player.yPos = 0 --some default values - not to be used
--Player.xPos = 100 --some default values - not to be used
if LowerObstacles:isPointOverLapped(player.xPos, player.yPos +player.height) then
return true
end
if LowerObstacles:isPointOverLapped(player.xPos + player.width , player.yPos +player.height) then
return true
end
return false
end