This can be easily fixed:Sam Storms wrote:Very nice idea, I added it to my list for improvements for the next updateundef wrote:Nice idea!
I think apples shouldn't spawn in the same position twice in a row, what do you think?
A temporary speed up item could be interesting as well.
Ah, bug spotted, I've seen it a few times, but I wasn't able to properly fix it, so I thought instead of fixing it, I'll just change the color of the apple when that happens and it would add more than one point if the player eats it or subtract more than one point if the enemy eats it. So if I can't fix it, I'll probably end up doing that Thanks for trying it out. Cheers!
old:
Code: Select all
function Food:respawn()
math.randomseed(os.time())
f.x = math.random(gr.getWidth() - f.w)
f.y = math.random(gr.getHeight() - f.h)
if f.y < 32 then -- does not let food spawn outside the boundaries of the playing area
f.y = f.y + 32
end
end
Code: Select all
function Food:respawn()
--math.randomseed(os.time()) I would only do this once, when you load the game
local lastX, lastY = f.x, f.y
f.x = math.random(gr.getWidth() - f.w)
f.y = math.random(32, gr.getHeight() - f.h) -- is at least 32
if f.x==lastX and f.y==lastY then
f.x, f.y = -- put something deterministic here compared to the curent position, so that it is not only unlikely but IMPOSSIBLE
-- that the same position repeats twice in a row (if you just run math.random again it is unlikely but possible)
end
end