Skip to content

Commit

Permalink
Fix crash when too fast ShotSphere leaves the board
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubg1 committed Jan 15, 2021
1 parent 4f3c51d commit 2c875cd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ShotSphere.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ function ShotSphere:new(deserializationTable, shooter, pos, color, speed)
end

self.PIXELS_PER_STEP = 8

self.delQueue = false
end

function ShotSphere:update(dt)
Expand All @@ -31,7 +33,7 @@ function ShotSphere:update(dt)
else
-- move
self.steps = self.steps + self.speed * dt / self.PIXELS_PER_STEP
while self.steps > 0 and not self.hitSphere do self:moveStep() end
while self.steps > 0 and not self.hitSphere and not self.delQueue do self:moveStep() end
end
end

Expand Down Expand Up @@ -67,7 +69,9 @@ function ShotSphere:moveStep()
end

function ShotSphere:destroy()
if self.delQueue then return end
self._list:destroy(self)
self.delQueue = true
self.shooter.active = true
game:playSound("shooter_fill")
end
Expand Down

0 comments on commit 2c875cd

Please sign in to comment.