uh, a lot happened, i murdered physics code, redesigned tiles & levels, now i need to make another level editor. I'm sorry game. I'm sorry git.

This commit is contained in:
lustlion
2021-11-28 03:38:30 +01:00
parent 8607399d16
commit dd2debc0bd
30 changed files with 701 additions and 693 deletions

View File

@@ -6,7 +6,6 @@ objects = {
ladders = {}
}
-- level functions
function objects.DrawCollisions()
for _, col in pairs(objects.collisions) do
@@ -24,32 +23,14 @@ function objects.DrawCollisions()
end
-- returns true if theres a collision at that point. also marks collisioned tile as collision true
function isThereCollisionAt(x,y)
function isThereObjectAt(x,y,objectType)
local result = false
for _, col in pairs(objects.collisions) do
if x >= col.from.x and x <= col.to.x and y >= col.from.y and y <= col.to.y then
result = true
col.collision = true
end
end
return result
end
function isTherePlatformAt(x,y)
local result = false
for _, col in pairs(objects.platforms) do
if x >= col.from.x and x <= col.to.x and y >= col.from.y and y <= col.to.y and col.disable ~= true then
result = true
col.collision = true
end
end
return result
end
function isThereLadderAt(x,y)
local result = false
for _, col in pairs(objects.ladders) do
if x >= col.from.x and x <= col.to.x and y >= col.from.y and y <= col.to.y and col.disable ~= true then
for _, col in pairs(objectType) do
if x >= col.from.x
and x <= col.to.x
and y >= col.from.y
and y <= col.to.y
and col.disable ~= true then
result = true
col.collision = true
end
@@ -60,28 +41,13 @@ end
function isThereAnyCollisionAt(x,y)
local result = false
if not result then
for _, col in pairs(objects.collisions) do
if x >= col.from.x and x <= col.to.x and y >= col.from.y and y <= col.to.y then
result = true
col.collision = true
end
end
result = isThereObjectAt(x,y,objects.collisions)
end
if not result then
for _, col in pairs(objects.ladders) do
if x >= col.from.x and x <= col.to.x and y >= col.from.y and y <= col.to.y and col.disable ~= true then
result = true
col.collision = true
end
end
result = isThereObjectAt(x,y,objects.ladders)
end
if not result then
for _, col in pairs(objects.platforms) do
if x >= col.from.x and x <= col.to.x and y >= col.from.y and y <= col.to.y and col.disable ~= true then
result = true
col.collision = true
end
end
result = isThereObjectAt(x,y,objects.platforms)
end
return result
end