instantiate collision engine in area

This commit is contained in:
yuki 2025-11-11 03:22:25 -03:00
parent 16f9233ea8
commit fd69762121
2 changed files with 9 additions and 1 deletions

View file

@ -3,12 +3,14 @@
---@class Area:Object
---@field room Room
---@field game_objects GameObject[]
---@field world table|nil
local Area = Object:extend()
---Instantiates area
function Area:new(room)
self.room = room
self.game_objects = {}
self.world = nil
end
---Updates area
@ -36,4 +38,10 @@ function Area:addGameObject(game_object_type, x, y, opts)
return game_object
end
---Initializes HC physics as a world
---@param cell_size number|nil
function Area:addPhysicsWorld(cell_size)
self.world = HC(cell_size or 100)
end
return Area

View file

@ -3,7 +3,7 @@ local Stage = Room:extend()
function Stage:new()
Stage.super.new(self)
self.area:addPhysicsWorld()
self.area:addGameObject('Player', gw/2, gh/2)
end