Side collision
How do I add side collision to this platformer?
init = function()
ct.init()
cx = 0
cy = 0
cz = 1
map = ["map1"]
level = 0
velocy = 0
velocx = 0
end
update = function()
if checkCollision(cx,cy,map[level],1536,1536) == false then
velocy += .25
end
if checkCollision(cx,cy,map[level],1536,1536) == true then
velocy = 0
end
if keyboard.RIGHT and velocx < 3 then
velocx += .25
elsif keyboard.LEFT and velocx > -3then
velocx -= .25
elsif velocx < 0 then velocx += 1
elsif velocx > 0 then velocx -= 1 end
if keyboard.UP and checkCollision(cx,cy,map[level],1536,1536) == true or keyboard.SPACE and checkCollision(cx,cy,map[level],1536,1536) == true then
velocy = - 5
end
cx += velocx
cy -= velocy
ct.camera.glideTo(cx,cy,cz)
end
draw = function()
screen.clear("rgb(0,170,255)")
ct.drawMap(map[level],0,0,1536,1536)
screen.drawSprite("hero",0,0,24,24)
end