added rooms

This commit is contained in:
binarycat
2022-03-04 14:41:45 -05:00
committed by lustlion
parent 2b9f605a0a
commit 5643fc0140
8 changed files with 126 additions and 10 deletions

View File

@@ -4,6 +4,8 @@ LoadedObjects.Collisions = {}
LoadedObjects.Platforms = {}
LoadedObjects.Ladders = {}
LoadedObjects.Hazards = {}
LoadedObjects.Rooms = {}
--[[
Collision
@@ -51,6 +53,8 @@ function Collision:New(ox,oy,tx,ty)
return o
end
function Collision:CenterAt(x, y)
self.from.x = x-self.width/2
self.from.y = y-self.height/2
@@ -65,6 +69,13 @@ function Collision:PlaceAt(x, y)
self.to.y = self.from.x + self.height
end
function Collision:ContainsPoint(x, y)
return x => self.from.x and
y >= self.from.y and
x <= self.to.x and
y <= self.to.y
end
function Collision:Draw(color)
if self.isColliding == true then
love.graphics.setColor(0,1,0,0.5)
@@ -77,3 +88,10 @@ function Collision:Draw(color)
love.graphics.setColor(0,1,90,0.5)
love.graphics.rectangle("line",self.from.x-Camera.pos.x, self.from.y-Camera.pos.y, self.width, self.height)
end
function DrawRooms()
for _, room in pairs(LoadedObjects.Rooms) do
love.graphics.setColor(0,0,100,1)
love.graphics.rectangle("line",room.from.x-Camera.pos.x, room.from.y-Camera.pos.y, room.width, room.height)
end
end