demo recording and playback, collision table
This commit is contained in:
@@ -9,10 +9,6 @@ LoadedObjects = {
|
||||
|
||||
-- level functions
|
||||
function LoadedObjects.DrawCollisions()
|
||||
for _, collision in pairs(LoadedObjects.Collisions) do
|
||||
collision:Draw(1)
|
||||
end
|
||||
|
||||
for _, platform in pairs(LoadedObjects.Platforms) do
|
||||
if platform.disable == true then platform:Draw(2) end
|
||||
if platform.disable == false then platform:Draw(1) end
|
||||
@@ -29,33 +25,26 @@ end
|
||||
|
||||
-- returns true if theres a collision at that point
|
||||
function isThereObjectAt(x,y,objectType)
|
||||
for _, collision in pairs(objectType) do
|
||||
if collision.disable then
|
||||
for _, object in pairs(objectType) do
|
||||
if object.disable then
|
||||
-- Dont calculate if dissabled
|
||||
elseif x >= collision.from.x
|
||||
and x <= collision.to.x
|
||||
and y >= collision.from.y
|
||||
and y <= collision.to.y then
|
||||
collision.isColliding = true
|
||||
elseif x >= object.from.x
|
||||
and x <= object.to.x
|
||||
and y >= object.from.y
|
||||
and y <= object.to.y then
|
||||
object.isColliding = true
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function isThereAnyCollisionAt(x,y)
|
||||
local Check = {
|
||||
LoadedObjects.Collisions,
|
||||
LoadedObjects.Ladders,
|
||||
LoadedObjects.Platforms
|
||||
}
|
||||
for _, type in pairs(Check) do
|
||||
local result = isThereObjectAt(x,y,type)
|
||||
if result then
|
||||
return result
|
||||
end
|
||||
function isThereCollisionAt(x,y)
|
||||
if x >= 0 and x < #CollisionTable
|
||||
and y >= 0 and y < #CollisionTable[0] then
|
||||
return CollisionTable[math.floor(y)][math.floor(x)]
|
||||
end
|
||||
return false
|
||||
return false
|
||||
end
|
||||
|
||||
-- flags
|
||||
|
||||
Reference in New Issue
Block a user