First, you will want to edit your player code with something like this:
on score_chain do
if chain==0 then
scorechain_bonus = 0
end
if chain>5 then
scorechain_bonus = 1
end
if chain>10 then
scorechain_bonus = 2
end
if chain>15 then
scorechain_bonus = 3
end
if chain>25 then
scorechain_bonus = 4
end
if chain>50 then
scorechain_bonus = 5
end
end
Then you want to create a item you can collect. I used the default disk item, so I didn't have to create anything, but add this code
on collect do
chain ++
tell event.player to
call "score_chain"
if scorechain_bonus==0 then
score += 1
elseif scorechain_bonus==1 then
score += 2
elseif scorechain_bonus==2 then
score += 4
elseif scorechain_bonus==3 then
score += 8
elseif scorechain_bonus==4 then
score += 16
elseif scorechain_bonus==5 then
score += 32
end
end
end
If you want the score to reset, you will also want to create a ground item. If you collect the item, you will want it to turn into the ground tile.
ground tile:
on collect do
scorechain_bonus = 0
chain = 0
end
Lastly, on the player code, add a draw event
on draw do
label "Score:{score}" at 0,0
if chain>5 then
label "Score chain X {scorechain_bonus}" at 5,14
else
end
end
This is what you should get. I forgot to change Credits to score, because I was using code from another one of my projects:
I even made a demo game with some humor thrown in. Source code included. You are free to use the source code and/or learn from it.
score-chain-demo_20220916041236.zip (34.8 KB)
sourcecode fixed.zip (3.2 KB)