For things like this, what I’d introduce is a score colour variable, which you can change. I’d also create a score colour timer variable, which will be 30.
I imagine you’re printing the score as
print(score,0,0,7) (or another colour)
At the start of the code print
scorecolour=7
scorecolourtimer=0
Then on the update print
scorecolourtimer-=1
if (scorecolourtimer<0)
scorecolour=7
end
Then when you collect the apple:-
scorecolour=10 -- or any other colour
scorecolourtimer=30
It’s not working, must have misplaced something. Here’s all my code:
function _init()
x=63
y=85
fx=rnd(45) - 85
fy=85
score=0
time=0
reset_apple()
gameover=false
scorecolor=7
scoretimer=30
end
function _update()
–player movement
move_plr()
if not gameover then
scoretimer-=1
if (scoretimer<0) then
scorecolor=7
end
–fox movement
fx=fx+1
reset_fox()
if abs(x-fx)<4 and abs(y-fy)<4 then
score=score-2
end
ay=ay+1
time=time+1
–catch the apple
if abs(x-ax)<4 and abs(y-ay)<4 and randomapple<1.5 then
reset_apple()
score=score+1
scorecolor= 10
scorecolortimer= 30
elseif abs(x-ax)<4 and abs(y-ay)<4 and randomapple>1.5 and randomapple<1.85 then
reset_apple()
score=score+2
scorecolor= 10
scorecolortimer= 30
end
if abs(x-ax)<4 and abs(y-ay)<4 and randomapple>1.85 then
reset_apple()
time=time-450
end
if randomapple>1.5 then
ay=ay+1.08
end
if abs(ay)>120 then
reset_apple()
end
else
end
if time==2970 then
gameover=true
end
end
The next thing to do is limit the time the bucket can hover. Otherwise a player can just hold x and avoid the fox the whole time. Hmm… I’m not sure where to start with that.
Almost done! Just trying to figure out how to make a sound effect (a very short tune) play only once when gameover = true. The current code is calling it every frame and making it sound like a continuous buzz.