Resize sprites, tighten player hitbox, implement smarter collision.
This commit is contained in:
parent
eb6d37f99c
commit
9a26eb4b3a
|
@ -32,13 +32,18 @@ end
|
||||||
|
|
||||||
function Bullet:update()
|
function Bullet:update()
|
||||||
local collisions = select(3, self:moveWithCollisions(self.x+self.vector.dx, self.y+self.vector.dy))
|
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
|
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
|
local obj = collisions[i].other
|
||||||
obj:damage(self.damage)
|
if self:alphaCollision(obj) then
|
||||||
|
obj:damage(self.damage)
|
||||||
|
realCollision = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if #collisions >= 1 or self:outOfBounds() then
|
if realCollision or self:outOfBounds() then
|
||||||
self:remove()
|
self:remove()
|
||||||
end
|
end
|
||||||
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 |
|
@ -53,7 +53,8 @@ function Kani:init(ui)
|
||||||
self.type = 'kani'
|
self.type = 'kani'
|
||||||
self:setGroupMask(0x2)
|
self:setGroupMask(0x2)
|
||||||
self:setCollidesWithGroupsMask(0xd)
|
self:setCollidesWithGroupsMask(0xd)
|
||||||
|
self:setCollideRect(1,12,25,24)
|
||||||
|
|
||||||
self.reserveCharge = 100
|
self.reserveCharge = 100
|
||||||
|
|
||||||
-- controls the speed the crank recharges the player's reserves. A lower number allows faster charging.
|
-- controls the speed the crank recharges the player's reserves. A lower number allows faster charging.
|
||||||
|
@ -155,6 +156,6 @@ end
|
||||||
function Kani:runReady()
|
function Kani:runReady()
|
||||||
local collisions = Kani.super.runReady(self)
|
local collisions = Kani.super.runReady(self)
|
||||||
for i=0, #collisions, 1 do
|
for i=0, #collisions, 1 do
|
||||||
-- handle player-triggered collisions
|
-- TODO: handle player-triggered collisions
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user