I'm trying to implement a system where the player only has limited moves on the board before they lose.
This is what I have so far:
on draw do
label "fuel:" at 2,1
label "{fuel}" at 5,1
end
on update do
if event.dx==-1 then
fuel--
elseif event.dx==1 then
fuel--
elseif event.dy==-1 then
fuel--
elseif event.dy==1 then
fuel--
else
end
if fuel==-10 then
fin "You ran out of fuel and broke down!"
end
The problem is 'fuel' by default starts at 0 and counts down into negative numbers. I've tried using
on draw do
fuel = 10
But this stops it from counting down and just leaves a static number 10 on screen and never calls the 'fin' command. Is there a way to make the fuel counter start at a positive number and count down, ending the game at 0?