Resize sprites, tighten player hitbox, implement smarter collision.

This commit is contained in:
Anna Rose 2023-10-03 18:49:40 -04:00
parent eb6d37f99c
commit 9a26eb4b3a
5 changed files with 11 additions and 5 deletions

View File

@ -32,13 +32,18 @@ end
function Bullet:update()
local collisions = select(3, self:moveWithCollisions(self.x+self.vector.dx, self.y+self.vector.dy))
local realCollision = false
for i=1, #collisions, 1 do
-- anything the bullet can collide with should be damaged by it
-- anything the bullet can collide with should be damaged by it, but it has to hit an actual pixel
local obj = collisions[i].other
obj:damage(self.damage)
if self:alphaCollision(obj) then
obj:damage(self.damage)
realCollision = true
end
end
if #collisions >= 1 or self:outOfBounds() then
if realCollision or self:outOfBounds() then
self:remove()
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 651 B

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 761 B

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@ -53,7 +53,8 @@ function Kani:init(ui)
self.type = 'kani'
self:setGroupMask(0x2)
self:setCollidesWithGroupsMask(0xd)
self:setCollideRect(1,12,25,24)
self.reserveCharge = 100
-- controls the speed the crank recharges the player's reserves. A lower number allows faster charging.
@ -155,6 +156,6 @@ end
function Kani:runReady()
local collisions = Kani.super.runReady(self)
for i=0, #collisions, 1 do
-- handle player-triggered collisions
-- TODO: handle player-triggered collisions
end
end