improvement(world): separate bodies from actor management
This commit is contained in:
parent
241baad935
commit
2b1bdd0be5
2 changed files with 13 additions and 16 deletions
|
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## Unreleased
|
||||
|
||||
### Changed
|
||||
|
||||
- **world2D:** Use a list for bodies (hitboxes, etc) and one other for actors
|
||||
|
||||
### Fixed
|
||||
|
||||
- **world:** Remove a forgotten camera debug function
|
||||
|
|
|
@ -39,37 +39,30 @@ end
|
|||
|
||||
function World2D:initActors()
|
||||
self.currentCreationID = 0
|
||||
self.actors = Bump.newWorld(50)
|
||||
self.actors = {}
|
||||
self.bodies = Bump.newWorld(50)
|
||||
end
|
||||
|
||||
function World2D:registerActor(actor)
|
||||
actor.creationID = self.currentCreationID
|
||||
self.currentCreationID = self.currentCreationID + 1
|
||||
return self.actors:add(actor, actor.x, actor.y, actor.w, actor.h)
|
||||
World2D.super.registerActor(self, actor)
|
||||
return self.bodies:add(actor, actor.x, actor.y, actor.w, actor.h)
|
||||
end
|
||||
|
||||
function World2D:removeActor(actor)
|
||||
return self.actors:remove(actor)
|
||||
World2D.super.removeActor(self, actor)
|
||||
return self.bodies:remove(actor)
|
||||
end
|
||||
|
||||
function World2D:moveActor(actor, x, y, filter)
|
||||
return self.actors:move(actor, x, y, filter)
|
||||
return self.bodies:move(actor, x, y, filter)
|
||||
end
|
||||
|
||||
function World2D:checkCollision(actor, x, y, filter)
|
||||
return self.actors:check(actor, x, y, filter)
|
||||
return self.bodies:check(actor, x, y, filter)
|
||||
end
|
||||
|
||||
function World2D:queryRect(x, y, w, h)
|
||||
return self.actors:queryRect(x, y, w, h)
|
||||
end
|
||||
|
||||
function World2D:countActors()
|
||||
return self.actors:countItems()
|
||||
end
|
||||
|
||||
function World2D:getActors()
|
||||
return self.actors:getItems()
|
||||
return self.bodies:queryRect(x, y, w, h)
|
||||
end
|
||||
|
||||
return World2D
|
||||
|
|
Loading…
Reference in a new issue