first off, very new to game dev (though not programming in general) and new to the forums!
I have been working on my first ever hobby game project and am just working on the framework upon which I will build the game. I need a decent system for collision detection so I thought I would use HC as recommended on https://github.com/love2d-community/awe ... e2d#helper.
Every entity would store their own Shape to keep things encapsulated. Their shapes are created by using the provided functions (e.g HC.rectangle()).
Since I would like to have multiple collider instances and think that keeping state in the general one will cause issues down the line my World object holds an instance of HC, created like:
Code: Select all
self.collider = HC:new(100)
Code: Select all
-- Add an entity to the world
function World:addEntity(entity)
-- Give the entity an ID
entity.ID = self:getNewID()
if entity.collidable then
self.collider:register(entity.shape)
end
-- Use that ID to add the entity
self.entities[entity:getID()] = entity
end
Code: Select all
Error: modules/HC/spatialhash.lua:49: attempt to perform arithmetic on field 'cell_size' (a table value)
stack traceback:
modules/HC/spatialhash.lua:49: in function 'cellCoords'
modules/HC/spatialhash.lua:101: in function 'register'
modules/HC/init.lua:60: in function 'register'
world.lua:37: in function 'addEntity'
abstracts/entity.lua:47: in function 'addToWorld'
actors/player.lua:64: in function 'initialize'
modules/middleclass.lua:122: in function 'new'
main.lua:55: in function 'load'
[string "boot.lua"]:440: in function <[string "boot.lua"]:436>
[C]: in function 'xpcall'
I am not sure if I am doing something horribly wrong here or there is actually a fatal bug in a normal use case in HC. In any case, I have also made an issue on the HC github page but I am not sure how maintained it is.table: 0x074932b0
collisions
function: 0x074935a8
new
function: 0x07493460
rectangle
function: 0x07493528
point
function: 0x07493568
circle
function: 0x07493548
neighbors
function: 0x07493588
remove
function: 0x074934e8
register
function: 0x074934c8
resetHash
function: 0x07493488
hash
function: 0x074935c8
polygon
function: 0x07493508
If you have any suggestions, feel free to give them to me!
Cheers.