From 2b1bdd0be59e323645a53acc4ca648b7eecca827 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 22 Jun 2019 17:19:54 +0200 Subject: [PATCH 01/18] improvement(world): separate bodies from actor management --- CHANGELOG.md | 4 ++++ gamecore/modules/world/world2D.lua | 25 +++++++++---------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f650c5..680fef8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/gamecore/modules/world/world2D.lua b/gamecore/modules/world/world2D.lua index 7375c46..cba3b17 100644 --- a/gamecore/modules/world/world2D.lua +++ b/gamecore/modules/world/world2D.lua @@ -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 From cb97c2ceee65ce15c92b29aeb36946360092973b Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 22 Jun 2019 17:27:36 +0200 Subject: [PATCH 02/18] chore(world): prepate using an external hitbox object --- gamecore/modules/world/actors/actor2D.lua | 31 ++++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/gamecore/modules/world/actors/actor2D.lua b/gamecore/modules/world/actors/actor2D.lua index a6613d2..d67df15 100644 --- a/gamecore/modules/world/actors/actor2D.lua +++ b/gamecore/modules/world/actors/actor2D.lua @@ -30,7 +30,8 @@ local Actor2D = BaseActor:extend() -- Initialise the actor and its base functions function Actor2D:new(world, type, x, y, w, h, isSolid) - self:initHitbox(x, y, w, h) + self:setCoordinate(x, y) + self:initMainHitbox(w, h) Actor2D.super.new(self, world, type, isSolid) end @@ -165,16 +166,28 @@ function Actor2D:applyGravity(dt) end end --- COORDINATE FUNCTIONS --- Functions related to coordinate and hitbox +-- HITBOXES FUNCTIONS +-- Functions related to actor hitboxes -function Actor2D:initHitbox(x, y, w, h) - self.x = x or 0 - self.y = y or 0 +function Actor2D:initMainHitbox(w, h) self.w = w or 0 self.h = h or 0 end +function Actor2D:drawMainHitbox() + local x, y = math.floor(self.x), math.floor(self.y) + love.graphics.setColor(self.debug.r, self.debug.g, self.debug.b, 1) + utils.graphics.box(x, y, self.w, self.h) +end + +-- COORDINATE FUNCTION +-- Handle the coordinate system + +function Actor2D:setCoordinate(x, y) + self.x = x or self.x + self.y = y or self.y +end + function Actor2D:getCenter() return (self.x + (self.w / 2)), (self.y + (self.h / 2)) end @@ -183,12 +196,6 @@ function Actor2D:getViewCenter() return self:getCenter() end -function Actor2D:drawHitbox() - local x, y = math.floor(self.x), math.floor(self.y) - love.graphics.setColor(self.debug.r, self.debug.g, self.debug.b, 1) - utils.graphics.box(x, y, self.w, self.h) -end - -- DRAW FUNCTIONS -- Draw the actors. From 8c1e9d8e0539478184df31e89ca12b702d7494dc Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 22 Jun 2019 19:27:31 +0200 Subject: [PATCH 03/18] feat(world): initial support for external hitbox For the moment it doesn't add any real feature, but it allow the mainHitbox to be an external object to the actor, giving to it more power. --- CHANGELOG.md | 2 + gamecore/modules/world/actors/actor2D.lua | 22 +++- .../modules/world/actors/utils/hitbox2D.lua | 107 ++++++++++++++++++ gamecore/modules/world/baseworld.lua | 10 +- gamecore/modules/world/world2D.lua | 19 +++- 5 files changed, 148 insertions(+), 12 deletions(-) create mode 100644 gamecore/modules/world/actors/utils/hitbox2D.lua diff --git a/CHANGELOG.md b/CHANGELOG.md index 680fef8..ebec843 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **world2D:** Use a list for bodies (hitboxes, etc) and one other for actors +- **world2D:** Make the hitbox an object, owned by the actor + ### Fixed - **world:** Remove a forgotten camera debug function diff --git a/gamecore/modules/world/actors/actor2D.lua b/gamecore/modules/world/actors/actor2D.lua index d67df15..669f697 100644 --- a/gamecore/modules/world/actors/actor2D.lua +++ b/gamecore/modules/world/actors/actor2D.lua @@ -26,13 +26,21 @@ local cwd = (...):gsub('%.actor2D$', '') .. "." local BaseActor = require(cwd .. "baseactor") local Actor2D = BaseActor:extend() +local Hitbox = require(cwd .. "utils.hitbox2D") + -- INIT FUNCTIONS -- Initialise the actor and its base functions function Actor2D:new(world, type, x, y, w, h, isSolid) self:setCoordinate(x, y) - self:initMainHitbox(w, h) Actor2D.super.new(self, world, type, isSolid) + self:initMainHitbox(w, h) +end + +function BaseActor:destroy() + self.world:removeActor(self) + self.world:removeBody(self.mainHitbox) + self.isDestroyed = true end -- MOVEMENT FUNCTIONS @@ -118,7 +126,8 @@ end function Actor2D:move(dx, dy) local cols, colNumber = {}, 0 if (self.isDestroyed == false) then - self.x, self.y, cols, colNumber = self.world:moveActor(self, dx, dy, self.filter) + self.x, self.y, cols, colNumber = self.mainHitbox:checkCollision(dx, dy, self.filter) + self.mainHitbox:updatePosition() end return self.x, self.y, cols, colNumber end @@ -126,7 +135,7 @@ end function Actor2D:checkCollision(dx, dy) local x, y, cols, colNumber = dx, dy, {}, 0 if (self.isDestroyed == false) then - x, y, cols, colNumber = self.world:moveActor(self, dx, dy, self.filter) + x, y, cols, colNumber = self.mainHitbox:checkCollision(dx, dy, self.filter) end return self.x, self.y, cols, colNumber end @@ -172,12 +181,13 @@ end function Actor2D:initMainHitbox(w, h) self.w = w or 0 self.h = h or 0 + + self.mainHitbox = Hitbox(self, self.type, 0, 0, self.w, self.h, self.isSolid) + self.world:registerBody(self.mainHitbox) end function Actor2D:drawMainHitbox() - local x, y = math.floor(self.x), math.floor(self.y) - love.graphics.setColor(self.debug.r, self.debug.g, self.debug.b, 1) - utils.graphics.box(x, y, self.w, self.h) + self.mainHitbox:draw() end -- COORDINATE FUNCTION diff --git a/gamecore/modules/world/actors/utils/hitbox2D.lua b/gamecore/modules/world/actors/utils/hitbox2D.lua new file mode 100644 index 0000000..4f4953d --- /dev/null +++ b/gamecore/modules/world/actors/utils/hitbox2D.lua @@ -0,0 +1,107 @@ +-- hitbox2D.lua :: a basic 2D hitbox object. It's used by the actors to check +-- collisions and to handle different type of responses. + +--[[ + Copyright © 2019 Kazhnuz + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +]] + +local Hitbox2D = Object:extend() + +-- INIT FUNCTIONS +-- Initialise the actor and its base functions + +function Hitbox2D:new(owner, type, ox, oy, w, h, isSolid) + self.owner = owner + self.world = owner.world + + self.type = type + self.ox = ox + self.oy = oy + self.x, self.y = self:getPosition() + self.w = w + self.h = h + self.isSolid = isSolid + + self:setDebugColor(0,0,0) +end + +function Hitbox2D:modify(ox, oy, w, h) + self.ox = ox + self.oy = oy + self.x, self.y = self:getPosition() + self.w = w + self.h = h +end + +function Hitbox2D:setDebugColor(r,g,b) + self.debug = {} + self.debug.r = r + self.debug.g = g + self.debug.b = b +end + +-- COORDINATE FUNCTIONS +-- Handle Hitbox position + +function Hitbox2D:updatePosition() + self.x, self.y = self:getPosition() + self.world:updateBody(self) + return self.x, self.y +end + +function Hitbox2D:getPosition() + return self.ox + self.owner.x, self.oy + self.owner.y +end + +function Hitbox2D:getOwnerPosition() + return self.x - self.ox, self.y - self.oy +end + +function Hitbox2D:getNewOwnerPosition(x, y) + return x - self.ox, y - self.oy +end + +function Hitbox2D:getCenter() + return self.x + (self.w/2), self.y + (self.h/2) +end + +-- COLLISION FUNCTIONS +-- Handle Hitbox position + +function Hitbox2D:checkCollision(dx, dy, filter) + self:updatePosition() + + local dx, dy = self.ox + dx, self.oy + dy + local x, y, cols, colNumber = self.world:checkCollision(self, dx, dy, filter) + local newx, newy = self:getNewOwnerPosition(x, y) + + return newx, newy, cols, colNumber +end + +-- DRAW FUNCTIONS +-- Just some debug function to draw hitbox + +function Hitbox2D:draw() + local x, y = self:getPosition() + love.graphics.setColor(self.debug.r, self.debug.g, self.debug.b, 1) + utils.graphics.box(x, y, self.w, self.h) +end + +return Hitbox2D diff --git a/gamecore/modules/world/baseworld.lua b/gamecore/modules/world/baseworld.lua index db3fbf0..375b2dc 100644 --- a/gamecore/modules/world/baseworld.lua +++ b/gamecore/modules/world/baseworld.lua @@ -163,7 +163,15 @@ function BaseWorld:getVisibleActors(id) local y = camy - paddingh local w = camw + paddingw * 2 local h = camh + paddingh * 2 - return self:queryRect(x, y, w, h) + + local query = self:queryRect(x, y, w, h) + local returnquery = {} + + for i,v in ipairs(query) do + table.insert(returnquery, v.owner) + end + + return returnquery end -- INFO FUNCTIONS diff --git a/gamecore/modules/world/world2D.lua b/gamecore/modules/world/world2D.lua index cba3b17..98ce64e 100644 --- a/gamecore/modules/world/world2D.lua +++ b/gamecore/modules/world/world2D.lua @@ -35,7 +35,7 @@ function World2D:new(scene, actorlist, mapfile) end -- ACTORS FUNCTIONS --- Wrappers around Bump2D functions +-- Add support for bodies in Actor functions function World2D:initActors() self.currentCreationID = 0 @@ -45,12 +45,21 @@ end function World2D:registerActor(actor) World2D.super.registerActor(self, actor) - return self.bodies:add(actor, actor.x, actor.y, actor.w, actor.h) end -function World2D:removeActor(actor) - World2D.super.removeActor(self, actor) - return self.bodies:remove(actor) +function World2D:registerBody(body) + return self.bodies:add(body, body.x, body.y, body.w, body.h) +end + +-- ACTORS FUNCTIONS +-- Wrappers around Bump2D functions + +function World2D:updateBody(body) + return self.bodies:update(body, body.x, body.y, body.w, body.h) +end + +function World2D:removeBody(body) + return self.bodies:remove(body) end function World2D:moveActor(actor, x, y, filter) From b770253cb591e09a6810a8b2f59703bb1318932c Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 22 Jun 2019 19:28:28 +0200 Subject: [PATCH 04/18] fix(examples): adapt to the new hitbox system --- examples/gameplay/plateform/actors/player.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/gameplay/plateform/actors/player.lua b/examples/gameplay/plateform/actors/player.lua index 74b0173..b2c5322 100644 --- a/examples/gameplay/plateform/actors/player.lua +++ b/examples/gameplay/plateform/actors/player.lua @@ -62,10 +62,16 @@ end function Player:collisionResponse(collision) if collision.other.type == "coin" then - collision.other:takeCoin(self) + collision.other.owner:takeCoin(self) end end +function Player:draw() + Player.super.draw(self) + self:drawMainHitbox() + utils.graphics.resetColor() +end + function Player:drawHUD(id) love.graphics.print(id .. " test", 4, 4) end From c553dfafa386cbcb08ade25a235a5b00082d4c5b Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 22 Jun 2019 20:17:36 +0200 Subject: [PATCH 05/18] feat(examples): add ducking in plateforming example Show how we can now modify in action an hitbox without glitching it --- CHANGELOG.md | 4 ++++ examples/gameplay/plateform/actors/player.lua | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebec843..d268b70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- **actor2D:** Make hitbox modifiable. + ### Changed - **world2D:** Use a list for bodies (hitboxes, etc) and one other for actors diff --git a/examples/gameplay/plateform/actors/player.lua b/examples/gameplay/plateform/actors/player.lua index b2c5322..cc892f6 100644 --- a/examples/gameplay/plateform/actors/player.lua +++ b/examples/gameplay/plateform/actors/player.lua @@ -15,7 +15,9 @@ function Player:updateStart(dt) self.ysp = -280 end if self.keys["down"].isDown then - --self.ysp = 120 + self.mainHitbox:modify(0, 8, 16, 16) + else + self.mainHitbox:modify(0, 0, 16, 24) end if self.keys["left"].isDown then self.xsp = -120 From f88c7f49e4f0246471005bbe94a55a55eb3a0688 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 22 Jun 2019 22:11:22 +0200 Subject: [PATCH 06/18] feat(world): add multiple hitbox support on actor2D --- CHANGELOG.md | 2 + examples/gameplay/plateform/actors/player.lua | 36 +++++++++- .../gameplay/plateform/assets/monkey_lad.lua | 4 +- gamecore/modules/world/actors/actor2D.lua | 66 ++++++++++++++++++- 4 files changed, 101 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d268b70..4cfdb3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **actor2D:** Make hitbox modifiable. +- **actor2D:** Add multiple hitbox support. + ### Changed - **world2D:** Use a list for bodies (hitboxes, etc) and one other for actors diff --git a/examples/gameplay/plateform/actors/player.lua b/examples/gameplay/plateform/actors/player.lua index cc892f6..80eb06b 100644 --- a/examples/gameplay/plateform/actors/player.lua +++ b/examples/gameplay/plateform/actors/player.lua @@ -6,6 +6,9 @@ function Player:new(world, x, y, id) self:setSprite("player", 8, 12) self:cloneSprite() self:setYGravity(480) + + self.isPunching = false + self.direction = 1 end function Player:updateStart(dt) @@ -19,13 +22,29 @@ function Player:updateStart(dt) else self.mainHitbox:modify(0, 0, 16, 24) end - if self.keys["left"].isDown then + if self.keys["left"].isDown and (not self.isPunching) then self.xsp = -120 end - if self.keys["right"].isDown then + if self.keys["right"].isDown and (not self.isPunching) then self.xsp = 120 end + if self.keys["A"].isDown then + self.isPunching = true + if (self.direction == 1) then + self:addHitbox("punch", "punch", 16, 6, 12, 12, false) + else + self:addHitbox("punch", "punch", -12, 6, 12, 12, false) + end + else + self.isPunching = false + self:removeHitbox("punch") + end + + if (self.isPunching) then + self:checkHitboxCollisions("punch") + end + if self.keys["start"].isPressed then --self.world:switchActivity() --self.assets:switchActivity() @@ -43,6 +62,9 @@ end function Player:setAnimation() self:setCustomSpeed(math.abs(self.xsp) / 12) + if (self.isPunching) then + self:changeAnimation("punch", false) + else if (self.onGround) then if math.abs(self.xsp) > 0 then self:changeAnimation("walk", false) @@ -52,12 +74,14 @@ function Player:setAnimation() else self:changeAnimation("jump", true) end + end end function Player:setDirection(direction) direction = direction or 0 if direction ~= 0 then direction = utils.math.sign(direction) + self.direction = direction self:setSpriteScallingX(direction) end end @@ -68,9 +92,15 @@ function Player:collisionResponse(collision) end end +function Player:hitboxResponse(name, type, collision) + if (collision.other.type == "coin") and (type == "punch") then + collision.other.owner:takeCoin(self) + end +end + function Player:draw() Player.super.draw(self) - self:drawMainHitbox() + self:drawHitboxes() utils.graphics.resetColor() end diff --git a/examples/gameplay/plateform/assets/monkey_lad.lua b/examples/gameplay/plateform/assets/monkey_lad.lua index a854bdd..89bced3 100644 --- a/examples/gameplay/plateform/assets/monkey_lad.lua +++ b/examples/gameplay/plateform/assets/monkey_lad.lua @@ -43,8 +43,8 @@ return { pauseAtEnd = false, }, ["punch"] = { - startAt = 10, - endAt = 10, + startAt = 11, + endAt = 11, loop = 1, speed = 0, pauseAtEnd = false, diff --git a/gamecore/modules/world/actors/actor2D.lua b/gamecore/modules/world/actors/actor2D.lua index 669f697..0ffeffd 100644 --- a/gamecore/modules/world/actors/actor2D.lua +++ b/gamecore/modules/world/actors/actor2D.lua @@ -34,7 +34,7 @@ local Hitbox = require(cwd .. "utils.hitbox2D") function Actor2D:new(world, type, x, y, w, h, isSolid) self:setCoordinate(x, y) Actor2D.super.new(self, world, type, isSolid) - self:initMainHitbox(w, h) + self:initHitboxes(w, h) end function BaseActor:destroy() @@ -178,14 +178,76 @@ end -- HITBOXES FUNCTIONS -- Functions related to actor hitboxes -function Actor2D:initMainHitbox(w, h) +function Actor2D:initHitboxes(w, h) self.w = w or 0 self.h = h or 0 + self:initMainHitbox() + + self.hitboxes = {} +end + +function Actor2D:initMainHitbox() self.mainHitbox = Hitbox(self, self.type, 0, 0, self.w, self.h, self.isSolid) self.world:registerBody(self.mainHitbox) end +function Actor2D:addHitbox(name, type, ox, oy, w, h, isSolid) + if (self.hitboxes[name] ~= nil) then + print("ERROR:", "The hitbox " .. name .. " already exists") + else + local hitbox = Hitbox(self, type, ox, oy, w, h, isSolid) + self.hitboxes[name] = hitbox + self.world:registerBody(self.hitboxes[name]) + return hitbox + end +end + +function Actor2D:checkHitboxCollisions(name, filter) + self:checkHitboxCollisionsAtPoint(name, self.x, self.y, filter) +end + +function Actor2D:checkHitboxCollisionsAtPoint(name, dx, dy, filter) + local x, y, cols, colNumber = dx, dy, {}, 0 + local filter = filter or self.filter + if (self.isDestroyed == false) and (self.hitboxes[name] ~= nil) then + x, y, cols, colNumber = self.hitboxes[name]:checkCollision(dx, dy, filter) + local type = self.hitboxes[name].type + + for i, col in ipairs(cols) do + self:hitboxResponse(name, type, col) + end + end + + return x, y, cols, colNumber +end + +function Actor2D:hitboxResponse(name, type, collision) + -- just a blank placeholder function +end + +function Actor2D:removeHitbox(name) + if (self.hitboxes[name] ~= nil) then + self.world:removeBody(self.hitboxes[name]) + self.hitboxes[name] = nil + end +end + +function Actor2D:purgeHitbox() + for k,v in pairs(self.hitboxes) do + self.world:removeBody(v) + end + self.hitboxes = {} +end + +function Actor2D:drawHitboxes() + for k,v in pairs(self.hitboxes) do + v:draw() + end + self.mainHitbox:draw() +end + + function Actor2D:drawMainHitbox() self.mainHitbox:draw() end From a3b6bcd4995257e872777162050bcec41b372086 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 23 Jun 2019 10:19:01 +0200 Subject: [PATCH 07/18] feat(world): add a frame hitbox data structure to process It'll allow us to create a way to process everyframe of an animation and change hitbox according to the animation. It should especially simplify the creation of battle system. --- examples/gameplay/plateform/actors/player.lua | 12 ++++----- gamecore/modules/world/actors/actor2D.lua | 27 +++++++++++++++++++ gamecore/modules/world/actors/baseactor.lua | 4 +++ 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/examples/gameplay/plateform/actors/player.lua b/examples/gameplay/plateform/actors/player.lua index 80eb06b..0c93e62 100644 --- a/examples/gameplay/plateform/actors/player.lua +++ b/examples/gameplay/plateform/actors/player.lua @@ -9,6 +9,8 @@ function Player:new(world, x, y, id) self.isPunching = false self.direction = 1 + + self.punchName = "" end function Player:updateStart(dt) @@ -31,18 +33,14 @@ function Player:updateStart(dt) if self.keys["A"].isDown then self.isPunching = true - if (self.direction == 1) then - self:addHitbox("punch", "punch", 16, 6, 12, 12, false) - else - self:addHitbox("punch", "punch", -12, 6, 12, 12, false) - end + self.punchName = self:addHitboxFromFrameData({"punch", 16, 6, 12, 12, false}) else self.isPunching = false - self:removeHitbox("punch") + self:removeHitbox(self.punchName) end if (self.isPunching) then - self:checkHitboxCollisions("punch") + self:checkHitboxCollisions(self.punchName) end if self.keys["start"].isPressed then diff --git a/gamecore/modules/world/actors/actor2D.lua b/gamecore/modules/world/actors/actor2D.lua index 0ffeffd..268af8a 100644 --- a/gamecore/modules/world/actors/actor2D.lua +++ b/gamecore/modules/world/actors/actor2D.lua @@ -187,6 +187,33 @@ function Actor2D:initHitboxes(w, h) self.hitboxes = {} end +function Actor2D:addHitboxFromFrameData(framedata, animationID, frameID, hitboxID) + local sx, sy = self:getSpriteScalling() + local type = framedata[1] + local ox = framedata[2] + local oy = framedata[3] + local w = framedata[4] + local h = framedata[5] + local isSolid = framedata[6] or false + local anim = animationID or "null" + local frame = frameID or 0 + local id = hitboxID or 0 + if (sx < 0) then + ox = self.w - ox - w + end + if (sy < 0) then + oy = self.h - oy - h + end + + if (type == "main") then + self.mainHitbox:modify(ox, oy, w, h) + else + local hitboxName = anim .. frame .. type .. id + self:addHitbox(hitboxName, type, ox, oy, w, h, isSolid) + return hitboxName + end +end + function Actor2D:initMainHitbox() self.mainHitbox = Hitbox(self, self.type, 0, 0, self.w, self.h, self.isSolid) self.world:registerBody(self.mainHitbox) diff --git a/gamecore/modules/world/actors/baseactor.lua b/gamecore/modules/world/actors/baseactor.lua index 5512449..ac4ce59 100644 --- a/gamecore/modules/world/actors/baseactor.lua +++ b/gamecore/modules/world/actors/baseactor.lua @@ -236,6 +236,10 @@ function BaseActor:setSpriteScallingY(sy) self.sprite.sy = sy end +function BaseActor:getSpriteScalling() + return self.sprite.sx, self.sprite.sy +end + function BaseActor:drawSprite(x, y, r, sx, sy, ox, oy, kx, ky) if (self.sprite.name ~= nil) then local x = x + self.sprite.ox From 8a5692c1a1292b966609e4b05773e2d567e7b9b6 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 23 Jun 2019 14:23:51 +0200 Subject: [PATCH 08/18] feat(assets): add a way to get current relative frame This function return the current frame relative to the first frame of the current animation --- CHANGELOG.md | 3 +++ gamecore/modules/assets/animator.lua | 4 ++++ gamecore/modules/assets/sprites.lua | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cfdb3e..53471b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **actor2D:** Add multiple hitbox support. +- **assets:** Add a way to get current relative frame + + ### Changed - **world2D:** Use a list for bodies (hitboxes, etc) and one other for actors diff --git a/gamecore/modules/assets/animator.lua b/gamecore/modules/assets/animator.lua index 1498153..6aced5a 100644 --- a/gamecore/modules/assets/animator.lua +++ b/gamecore/modules/assets/animator.lua @@ -102,6 +102,10 @@ function Animator:getFrame() return self.frame end +function Animator:getRelativeFrame() + return self.frame - (self.animationData.startAt) + 1 +end + function Animator:animationExist(name) return (self.sprite.data.animations[self.currentAnimation] ~= nil) end diff --git a/gamecore/modules/assets/sprites.lua b/gamecore/modules/assets/sprites.lua index ddf4f89..63676a2 100644 --- a/gamecore/modules/assets/sprites.lua +++ b/gamecore/modules/assets/sprites.lua @@ -74,6 +74,10 @@ function Sprite:getDimensions() return self.tileset:getDimensions() end +function Sprite:getRelativeFrame() + return self.animator:getRelativeFrame() +end + -- DRAW FUNCTIONS -- Draw sprites using these functions From 531f3c58031ac785a29fe4a67c173e4ee574a94e Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 23 Jun 2019 14:25:02 +0200 Subject: [PATCH 09/18] feat(assets): add more wrapper around animator functions in Sprite --- CHANGELOG.md | 1 + gamecore/modules/assets/sprites.lua | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53471b9..c07f35d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **assets:** Add a way to get current relative frame +- **assets:** Add more wrapper around animator functions in Sprite ### Changed diff --git a/gamecore/modules/assets/sprites.lua b/gamecore/modules/assets/sprites.lua index 63676a2..052f3f2 100644 --- a/gamecore/modules/assets/sprites.lua +++ b/gamecore/modules/assets/sprites.lua @@ -74,6 +74,14 @@ function Sprite:getDimensions() return self.tileset:getDimensions() end +function Sprite:getFrame() + return self.animator:getFrame() +end + +function Sprite:getAnimationDuration(animation) + return self.animator:getAnimationDuration(animation) +end + function Sprite:getRelativeFrame() return self.animator:getRelativeFrame() end From 6fb3fecc950a844208e96d293f6f19c9da04c440 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 23 Jun 2019 14:27:07 +0200 Subject: [PATCH 10/18] feat(assets): add more wrapper around sprite functions in BaseActor --- CHANGELOG.md | 2 ++ gamecore/modules/world/actors/baseactor.lua | 30 +++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c07f35d..7b7208a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **assets:** Add more wrapper around animator functions in Sprite +- **world:** Add more wrapper around sprite functions in BaseActor + ### Changed - **world2D:** Use a list for bodies (hitboxes, etc) and one other for actors diff --git a/gamecore/modules/world/actors/baseactor.lua b/gamecore/modules/world/actors/baseactor.lua index ac4ce59..c9703ab 100644 --- a/gamecore/modules/world/actors/baseactor.lua +++ b/gamecore/modules/world/actors/baseactor.lua @@ -240,6 +240,36 @@ function BaseActor:getSpriteScalling() return self.sprite.sx, self.sprite.sy end +function BaseActor:getFrame() + if (self.sprite.name ~= nil) then + if (self.sprite.clone ~= nil) then + self.sprite.clone:getFrame() + else + self.assets.sprites[self.sprite.name]:getFrame() + end + end +end + +function BaseActor:getRelativeFrame() + if (self.sprite.name ~= nil) then + if (self.sprite.clone ~= nil) then + self.sprite.clone:getRelativeFrame() + else + self.assets.sprites[self.sprite.name]:getRelativeFrame() + end + end +end + +function BaseActor:getAnimationDuration() + if (self.sprite.name ~= nil) then + if (self.sprite.clone ~= nil) then + self.sprite.clone:getAnimationDuration() + else + self.assets.sprites[self.sprite.name]:getAnimationDuration() + end + end +end + function BaseActor:drawSprite(x, y, r, sx, sy, ox, oy, kx, ky) if (self.sprite.name ~= nil) then local x = x + self.sprite.ox From dca4ece7fe403bc09a9c1e98fc97c0fd59a13a1d Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 23 Jun 2019 15:25:56 +0200 Subject: [PATCH 11/18] feat(assets): add a new getCurrentAnimation function --- CHANGELOG.md | 2 ++ gamecore/modules/assets/animator.lua | 4 ++++ gamecore/modules/assets/sprites.lua | 4 ++++ gamecore/modules/world/actors/baseactor.lua | 9 +++++++++ 4 files changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b7208a..18e70d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **world:** Add more wrapper around sprite functions in BaseActor +- **assets:** Add a new getCurrentAnimation function + ### Changed - **world2D:** Use a list for bodies (hitboxes, etc) and one other for actors diff --git a/gamecore/modules/assets/animator.lua b/gamecore/modules/assets/animator.lua index 6aced5a..17fa139 100644 --- a/gamecore/modules/assets/animator.lua +++ b/gamecore/modules/assets/animator.lua @@ -94,6 +94,10 @@ end -- INFO FUNCTIONS -- get information with these functions +function Animator:getCurrentAnimation() + return self.currentAnimation +end + function Animator:getAnimationDuration(animation) return (self.animationData.endAt - self.animationData.startAt) / self.animationData.speed end diff --git a/gamecore/modules/assets/sprites.lua b/gamecore/modules/assets/sprites.lua index 052f3f2..f33b919 100644 --- a/gamecore/modules/assets/sprites.lua +++ b/gamecore/modules/assets/sprites.lua @@ -66,6 +66,10 @@ end -- INFO FUNCTIONS -- get information with these functions +function Sprite:getCurrentAnimation() + return self.animator:getCurrentAnimation() +end + function Sprite:animationExist(name) return self.animator:animationExist(name) end diff --git a/gamecore/modules/world/actors/baseactor.lua b/gamecore/modules/world/actors/baseactor.lua index c9703ab..231d15f 100644 --- a/gamecore/modules/world/actors/baseactor.lua +++ b/gamecore/modules/world/actors/baseactor.lua @@ -236,6 +236,15 @@ function BaseActor:setSpriteScallingY(sy) self.sprite.sy = sy end +function BaseActor:getCurrentAnimation() + if (self.sprite.clone == nil) then + self.assets.sprites[self.sprite.name]:getCurrentAnimation() + else + self.sprite.clone:getCurrentAnimation() + end +end + + function BaseActor:getSpriteScalling() return self.sprite.sx, self.sprite.sy end From 5c5b3eed34a8017b8794f7d7b047191df732e398 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 23 Jun 2019 15:29:08 +0200 Subject: [PATCH 12/18] fix(assets): add "return" call that were forgotten --- gamecore/modules/world/actors/baseactor.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gamecore/modules/world/actors/baseactor.lua b/gamecore/modules/world/actors/baseactor.lua index 231d15f..d395cd6 100644 --- a/gamecore/modules/world/actors/baseactor.lua +++ b/gamecore/modules/world/actors/baseactor.lua @@ -238,9 +238,9 @@ end function BaseActor:getCurrentAnimation() if (self.sprite.clone == nil) then - self.assets.sprites[self.sprite.name]:getCurrentAnimation() + return self.assets.sprites[self.sprite.name]:getCurrentAnimation() else - self.sprite.clone:getCurrentAnimation() + return self.sprite.clone:getCurrentAnimation() end end @@ -252,9 +252,9 @@ end function BaseActor:getFrame() if (self.sprite.name ~= nil) then if (self.sprite.clone ~= nil) then - self.sprite.clone:getFrame() + return self.sprite.clone:getFrame() else - self.assets.sprites[self.sprite.name]:getFrame() + return self.assets.sprites[self.sprite.name]:getFrame() end end end @@ -262,9 +262,9 @@ end function BaseActor:getRelativeFrame() if (self.sprite.name ~= nil) then if (self.sprite.clone ~= nil) then - self.sprite.clone:getRelativeFrame() + return self.sprite.clone:getRelativeFrame() else - self.assets.sprites[self.sprite.name]:getRelativeFrame() + return self.assets.sprites[self.sprite.name]:getRelativeFrame() end end end @@ -272,9 +272,9 @@ end function BaseActor:getAnimationDuration() if (self.sprite.name ~= nil) then if (self.sprite.clone ~= nil) then - self.sprite.clone:getAnimationDuration() + return self.sprite.clone:getAnimationDuration() else - self.assets.sprites[self.sprite.name]:getAnimationDuration() + return self.assets.sprites[self.sprite.name]:getAnimationDuration() end end end From 3314f1e3f92d4e82df0be4c34e5fc9c39fe51f79 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 23 Jun 2019 15:32:25 +0200 Subject: [PATCH 13/18] improvement(actor): ignore by default collision with actor own hitboxes --- gamecore/modules/world/actors/baseactor.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gamecore/modules/world/actors/baseactor.lua b/gamecore/modules/world/actors/baseactor.lua index d395cd6..987fbea 100644 --- a/gamecore/modules/world/actors/baseactor.lua +++ b/gamecore/modules/world/actors/baseactor.lua @@ -87,7 +87,10 @@ end function BaseActor:setFilter() -- Init the bump filter self.filter = function(item, other) - if (other.isSolid) then + if (other.owner == self) then + -- ignore every collision with our own hitboxes + return nil + elseif (other.isSolid) then return "slide" else return "cross" From eafc266544f4892de8b8862581d41a5685b537fe Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 23 Jun 2019 15:39:57 +0200 Subject: [PATCH 14/18] fix(baseworld): make baseworld not crash when a body is loaded --- gamecore/modules/world/baseworld.lua | 68 +++++++++++++++++----------- 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/gamecore/modules/world/baseworld.lua b/gamecore/modules/world/baseworld.lua index 375b2dc..02007ad 100644 --- a/gamecore/modules/world/baseworld.lua +++ b/gamecore/modules/world/baseworld.lua @@ -121,32 +121,6 @@ function BaseWorld:removeActor(actor) end end -function BaseWorld:moveActor(actor, x, y, filter) - -- as the baseworld have no collision function, we return empty collision - -- datas, but from the same type than bump2D will return - return x, y, {}, 0 -end - -function BaseWorld:checkCollision(actor, x, y, filter) - -- as the baseworld have no collision function, we return empty collision - -- datas, but from the same type than bump2D will return - return x, y, {}, 0 -end - -function BaseWorld:queryRect(x, y, w, h) - local query = {} - local x2, y2 = x + w, y + h - for i,v in ipairs(self.actors) do - if (v.x >= x) and (v.x + v.w >= x1) and - (v.y >= y) and (v.y + v.h >= y1) then - - table.insert(query, v) - end - end - - return v -end - function BaseWorld:countActors() return #self.actors end @@ -174,6 +148,48 @@ function BaseWorld:getVisibleActors(id) return returnquery end +-- BODIES MANAGEMENT FUNCTIONS +-- Basic function to handle bodies. Empty function here as baseworld doesn't +-- handle bodies + +function BaseWorld:registerBody(body) + return nil +end + +function BaseWorld:updateBody(body) + return x, y, {}, 0 +end + +function BaseWorld:removeBody(body) + return nil +end + +function BaseWorld:moveActor(actor, x, y, filter) + -- as the baseworld have no collision function, we return empty collision + -- datas, but from the same type than bump2D will return + return x, y, {}, 0 +end + +function BaseWorld:checkCollision(actor, x, y, filter) + -- as the baseworld have no collision function, we return empty collision + -- datas, but from the same type than bump2D will return + return x, y, {}, 0 +end + +function BaseWorld:queryRect(x, y, w, h) + local query = {} + local x2, y2 = x + w, y + h + for i,v in ipairs(self.actors) do + if (v.x >= x) and (v.x + v.w >= x1) and + (v.y >= y) and (v.y + v.h >= y1) then + + table.insert(query, v) + end + end + + return v +end + -- INFO FUNCTIONS -- Give infos about the world From 41cbf408906542f52e5866699d2b9305d206b720 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 23 Jun 2019 15:41:30 +0200 Subject: [PATCH 15/18] fix(examples): call the right function in movable player example --- examples/gameplay/moveplayer/actors/parent.lua | 2 +- examples/gameplay/moveplayer/actors/wall.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gameplay/moveplayer/actors/parent.lua b/examples/gameplay/moveplayer/actors/parent.lua index 502d7b6..3ca81f5 100644 --- a/examples/gameplay/moveplayer/actors/parent.lua +++ b/examples/gameplay/moveplayer/actors/parent.lua @@ -7,7 +7,7 @@ function Parent:new(world, type, x, y, w, h, isSolid) end function Parent:draw() - self:drawHitbox() + self:drawMainHitbox() end return Parent diff --git a/examples/gameplay/moveplayer/actors/wall.lua b/examples/gameplay/moveplayer/actors/wall.lua index 2981cb4..bc35e3a 100644 --- a/examples/gameplay/moveplayer/actors/wall.lua +++ b/examples/gameplay/moveplayer/actors/wall.lua @@ -7,7 +7,7 @@ function Wall:new(world, x, y, w, h) end function Wall:draw() - self:drawHitbox() + self:drawMainHitbox() utils.graphics.resetColor( ) end From 3fd8d2feccd10b855589a754cae7768d6d2fcd2f Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 23 Jun 2019 15:44:46 +0200 Subject: [PATCH 16/18] fix(hitboxes): reset colors after the hitbox is drawn. --- gamecore/modules/world/actors/utils/hitbox2D.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/gamecore/modules/world/actors/utils/hitbox2D.lua b/gamecore/modules/world/actors/utils/hitbox2D.lua index 4f4953d..f20c8ff 100644 --- a/gamecore/modules/world/actors/utils/hitbox2D.lua +++ b/gamecore/modules/world/actors/utils/hitbox2D.lua @@ -102,6 +102,7 @@ function Hitbox2D:draw() local x, y = self:getPosition() love.graphics.setColor(self.debug.r, self.debug.g, self.debug.b, 1) utils.graphics.box(x, y, self.w, self.h) + utils.graphics.resetColor() end return Hitbox2D From 89b2ffe483ca962a8aca80c2a0eb0750439249fb Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 23 Jun 2019 15:45:34 +0200 Subject: [PATCH 17/18] feat(world): add a way to automatically load hitbox from a file --- CHANGELOG.md | 2 + examples/gameplay/plateform/actors/player.lua | 5 +- .../plateform/assets/playerhitbox.lua | 13 ++++++ gamecore/modules/world/actors/actor2D.lua | 46 +++++++++++++++++++ 4 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 examples/gameplay/plateform/assets/playerhitbox.lua diff --git a/CHANGELOG.md b/CHANGELOG.md index 18e70d3..7ed7e67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **assets:** Add a new getCurrentAnimation function +- **world:** Add a way to automatically load hitbox from a file + ### Changed - **world2D:** Use a list for bodies (hitboxes, etc) and one other for actors diff --git a/examples/gameplay/plateform/actors/player.lua b/examples/gameplay/plateform/actors/player.lua index 0c93e62..84e473a 100644 --- a/examples/gameplay/plateform/actors/player.lua +++ b/examples/gameplay/plateform/actors/player.lua @@ -11,6 +11,7 @@ function Player:new(world, x, y, id) self.direction = 1 self.punchName = "" + self:setHitboxFile("examples.gameplay.plateform.assets.playerhitbox") end function Player:updateStart(dt) @@ -33,14 +34,12 @@ function Player:updateStart(dt) if self.keys["A"].isDown then self.isPunching = true - self.punchName = self:addHitboxFromFrameData({"punch", 16, 6, 12, 12, false}) else self.isPunching = false - self:removeHitbox(self.punchName) end if (self.isPunching) then - self:checkHitboxCollisions(self.punchName) + --self:checkHitboxCollisions(self.punchName) end if self.keys["start"].isPressed then diff --git a/examples/gameplay/plateform/assets/playerhitbox.lua b/examples/gameplay/plateform/assets/playerhitbox.lua new file mode 100644 index 0000000..d60c018 --- /dev/null +++ b/examples/gameplay/plateform/assets/playerhitbox.lua @@ -0,0 +1,13 @@ +return { + ["idle"] = { + { + {"main", 0, 0, 16, 24, true} + } + }, + ["punch"] = { + { + {"main", 0, 0, 16, 24, true}, + {"punch", 16, 6, 12, 12, false} + } + } +} diff --git a/gamecore/modules/world/actors/actor2D.lua b/gamecore/modules/world/actors/actor2D.lua index 268af8a..b9fd140 100644 --- a/gamecore/modules/world/actors/actor2D.lua +++ b/gamecore/modules/world/actors/actor2D.lua @@ -55,6 +55,7 @@ function Actor2D:initMovement() end function Actor2D:autoMove(dt) + self:updateHitboxes() self.onGround = false self:applyGravity(dt) @@ -185,6 +186,51 @@ function Actor2D:initHitboxes(w, h) self:initMainHitbox() self.hitboxes = {} + self.hitboxListFile = "" + self.hitboxList = nil +end + +function Actor2D:setHitboxFile(file) + self.hitboxList = require(file) + self.hitboxListFile = file +end + +function Actor2D:getAutomaticHitboxLoading() + return (self.hitboxList ~= nil) +end + +function Actor2D:getHitboxFile() + return self.hitboxListFile +end + +function Actor2D:getHitboxList(animation, frame) + if (animation == nil) or (self.hitboxList == nil) then + return self.hitboxList + else + local list = self.hitboxList[animation] + + if (frame == nil) or (list == nil) then + return list + else + return list[frame] + end + end +end + +function Actor2D:updateHitboxes() + if (self.hitboxList ~= nil) then + self:purgeHitbox() + local animation, frame + animation = self:getCurrentAnimation() + frame = self:getRelativeFrame() + local hitboxList = self:getHitboxList(animation, frame) + + if (hitboxList ~= nil) then + for i,v in ipairs(hitboxList) do + self:addHitboxFromFrameData(v, animation, frame, i) + end + end + end end function Actor2D:addHitboxFromFrameData(framedata, animationID, frameID, hitboxID) From cace01cf3a2e52da4c7fd457fda074cfe4ed771b Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 23 Jun 2019 15:53:51 +0200 Subject: [PATCH 18/18] feat(world): add a way to check every hitbox collisions --- examples/gameplay/plateform/actors/player.lua | 2 +- gamecore/modules/world/actors/actor2D.lua | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/gameplay/plateform/actors/player.lua b/examples/gameplay/plateform/actors/player.lua index 84e473a..1c95872 100644 --- a/examples/gameplay/plateform/actors/player.lua +++ b/examples/gameplay/plateform/actors/player.lua @@ -39,7 +39,7 @@ function Player:updateStart(dt) end if (self.isPunching) then - --self:checkHitboxCollisions(self.punchName) + self:checkHitboxesCollisions() end if self.keys["start"].isPressed then diff --git a/gamecore/modules/world/actors/actor2D.lua b/gamecore/modules/world/actors/actor2D.lua index b9fd140..ef96360 100644 --- a/gamecore/modules/world/actors/actor2D.lua +++ b/gamecore/modules/world/actors/actor2D.lua @@ -276,6 +276,12 @@ function Actor2D:addHitbox(name, type, ox, oy, w, h, isSolid) end end +function Actor2D:checkHitboxesCollisions(filter) + for k,v in pairs(self.hitboxes) do + self:checkHitboxCollisionsAtPoint(k, self.x, self.y, filter) + end +end + function Actor2D:checkHitboxCollisions(name, filter) self:checkHitboxCollisionsAtPoint(name, self.x, self.y, filter) end