|
Post by spectreman on Mar 29, 2020 14:07:45 GMT
Hi, I am doing a game that have the score, but also need a count down time that is constantly drained every frame or incresed when an enemy is hit.
My problem is that global variables only have a range from 0 to 250. I even tried to work within this values, but the number go to 999 when got subtract bellow 100 and go to 255 when subtract bellow 10.
There are any other to work with numbers beside global variables? Thks.
|
|
|
Post by AndyJF on Mar 29, 2020 20:38:44 GMT
I can tell you how I implemented a countdown timer in my game. I used 2 variables - one that started at 256 and went down by one each loop, each time it reached zero I would subtract one from the second variable and then reset the first variable to 256. This gave me a slow countdown that lasted roughly one second.
|
|
|
Post by spectreman on Mar 29, 2020 23:30:51 GMT
I can tell you how I implemented a countdown timer in my game. I used 2 variables - one that started at 256 and went down by one each loop, each time it reached zero I would subtract one from the second variable and then reset the first variable to 256. This gave me a slow countdown that lasted roughly one second. Thanks. I ended using this method of subtracting another variable inside the looping to delay the countdown speed: youtu.be/iFkQNAIQTe4?t=182One problem I still got is that the display number bellow 10 is showed as 90,80,70... I had to detect when was bellow 10 and diplay a column to the right while displaying a variable with value zero in the original column.
|
|
|
Post by alessandro on Mar 30, 2020 16:09:26 GMT
Hi spectreman, in order to avoid values less than 10 to be displayed on the left column you should do the following.
Let's assume that you would like to display the H variable at line 13 and column 28 when it is more than 9, therefore when it's less than 10 you should display it at column 29 and put a zero character (or a blank space if you prefer) at column 28. The "0" character in this example is stored as the text message number 0.
LET LINE 13 ; set line IF H <= 9 ; is H equal to or less than 9? LET COLUMN 28 ; if yes, point to the left column MESSAGE 0 ; print message number 0 (the "0" character in this case) LET COLUMN 29 ; point to the right column ELSE ; in this case, H is more than 9 LET COLUMN 28 ; point the left column ENDIF DISPLAY H ; print the value of H
|
|