Hi everyone!
I'm sure this isn't as hard as it feels but for some reason I can't work out what I'm doing wrong!
Basically I want my player to select the location to start a countdown from, then race from there to the exit (which is in the top left corner near 0,0). The further away you start, the bigger your score.
This bit is okay. I just do:
flr(p.x-exit.x+p.y-exit.y) |
And I get a nice round number that I can add to the score (647 at spawn).
But that number is too small, so I want to multiply it by 100:
flr(p.x-exit.x+p.y-exit.y)*100 |
I expect this to give me 64700 at spawn, and yet the new output is -831?
What am I doing wrong? Please help!
Could you upload the cart or the full lua file? Also one thing I always do in this situation is add print statements for each of the variables in the equation. This will tell you if any of the variables have unexpected values.
[edit] Now that I think about it, 600*100 = 60,000. I think PICO-8 numbers wrap around a little above 32,000.
[edit2] If you like the look of the larger number, you might be able to just append "00" to the end of the number when you display the score.
You can see how it looks with the below code:
i = 600
j = i * 100
print(i)
print(j)
s = i.."00"
print(s)
Pico-8's numbers are 16.16 fixed point, with a maximum integer value of 32767. Basically, your number is too big.
See https://www.lexaloffle.com/bbs/?pid=139330#p for various solutions for displaying large scores
Thank you everyone for the help! I'll experiment with these new methods and see what works best for the game!
[Please log in to post a comment]