Hey guys! Im new to smile basic and ive never tried basic. Im making a clicker like game by pressing buttons for points in a certain amount of time. when i run it nothing happens though. id like some help thanks.
Your code isn't looping until it gets to the timer loop. You're only looping @main if you push button 32. You need a VSYNC at the end of your loop or it will run too fast. Also, you should create a function for your timer and just put that in the main loop. Create function like this:
DEF TIMER
TIME=TIME+1
LOCATE 1,3
? TIME
END
Then just put the word TIMER in your main loop.
These are the simplest changes needed to make it work:
ACLS
TIME=60
SCORE=0
@MAIN
IF BUTTON()==32 THEN
SCORE=SCORE+1
ENDIF
TIME=TIME-1
CLS
PRINT SCORE
WAIT 1
GOTO @MAIN
That said, there's some stuff that can be improved upon:
You don't have to manually put in the numbers for different buttons, there's constants like #A, #B, #LEFT, #UP, and so on.
Also, something like BUTTON()==#A will be true every frame that A is held down, not just the first frame it's been pressed. You can write BUTTON(2)==#A instead of BUTTON()==#A to specifically look for presses.
Keep in mind that WAIT 1 waits for just one frame, which is 1/60 of a second. Because of this, TIME=60 will only be 60 frames, which is one second.
I would actually recommend using VSYNC instead of WAIT 1 here. The reasons why are kind of complicated, but VSYNC will make sure you have a consistent 60 FPS.