instantiate collision engine in area
This commit is contained in:
parent
16f9233ea8
commit
fd69762121
2 changed files with 9 additions and 1 deletions
|
|
@ -3,12 +3,14 @@
|
||||||
---@class Area:Object
|
---@class Area:Object
|
||||||
---@field room Room
|
---@field room Room
|
||||||
---@field game_objects GameObject[]
|
---@field game_objects GameObject[]
|
||||||
|
---@field world table|nil
|
||||||
local Area = Object:extend()
|
local Area = Object:extend()
|
||||||
|
|
||||||
---Instantiates area
|
---Instantiates area
|
||||||
function Area:new(room)
|
function Area:new(room)
|
||||||
self.room = room
|
self.room = room
|
||||||
self.game_objects = {}
|
self.game_objects = {}
|
||||||
|
self.world = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
---Updates area
|
---Updates area
|
||||||
|
|
@ -36,4 +38,10 @@ function Area:addGameObject(game_object_type, x, y, opts)
|
||||||
return game_object
|
return game_object
|
||||||
end
|
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
|
return Area
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ local Stage = Room:extend()
|
||||||
|
|
||||||
function Stage:new()
|
function Stage:new()
|
||||||
Stage.super.new(self)
|
Stage.super.new(self)
|
||||||
|
self.area:addPhysicsWorld()
|
||||||
self.area:addGameObject('Player', gw/2, gh/2)
|
self.area:addGameObject('Player', gw/2, gh/2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue