removing unnecssary score pending

This commit is contained in:
Juan 2025-08-07 12:26:28 -04:00
parent eb1a82d1f3
commit 409800a54f

View file

@ -7,7 +7,6 @@ function Cleaver:new()
instance.images = {} instance.images = {}
instance.state = "idle" instance.state = "idle"
instance.timer = 0 instance.timer = 0
instance.scorePending = false
instance.score = 0 instance.score = 0
return instance return instance
end end
@ -35,10 +34,6 @@ function Cleaver:update(dt)
self.state = "idle" self.state = "idle"
self.currentImage = self.images.idle self.currentImage = self.images.idle
self.timer = 0 self.timer = 0
if self.scorePending then
self.score = self.score + 1
self.scorePending = false
end
end end
end end
end end
@ -57,7 +52,6 @@ function Cleaver:mousepressed(button)
self.state = "windup" self.state = "windup"
self.currentImage = self.images.windup self.currentImage = self.images.windup
self.timer = 0 self.timer = 0
self.scorePending = false
end end
end end
@ -67,13 +61,13 @@ function Cleaver:mousereleased(button)
self.state = "chop" self.state = "chop"
self.currentImage = self.images.chop self.currentImage = self.images.chop
self.timer = 0 self.timer = 0
self.scorePending = true
-- Check if the cleaver is hovering over a meat instance -- Check if the cleaver is hovering over a meat instance
local x, y = love.mouse.getPosition() local x, y = love.mouse.getPosition()
for i, meat in ipairs(instances.meats) do for i, meat in ipairs(instances.meats) do
if x >= meat.x and x <= meat.x + meat.currentImage:getWidth() and y >= meat.y and y <= meat.y + meat.currentImage:getHeight() then if x >= meat.x and x <= meat.x + meat.currentImage:getWidth() and y >= meat.y and y <= meat.y + meat.currentImage:getHeight() then
-- Remove the meat instance from the table -- Remove the meat instance from the table
table.remove(instances.meats, i) table.remove(instances.meats, i)
self.score = self.score + 1
break break
end end
end end