#1✎ 416ElzoBroFirst DayJoined on the very first day of SmileBASIC SourceWebsiteVideo GamesI like to play video games!HobbiesDrawingI like to draw!Hobbieswhen do something like
@TITLE
PRINT"Title Screen"
B=BUTTON(2)
IF B AND A GOTO @MENU1
@MENU1
BEEP
PRINT"HI"
For some reason it prints the title but then the program just ends any help? *~*
Posted
when do something like
@TITLE
PRINT"Title Screen"
B=BUTTON(2)
IF B AND A GOTO @MENU1
@MENU1
BEEP
PRINT"HI"
For some reason it prints the title but then the program just ends any help? *~*
Yeah, because the program reaches the end.
@TITLE
PRINT"Title Screen"
B=BUTTON(2)
IF B AND A GOTO @MENU1
GOTO @TITLE
@MENU1
BEEP
PRINT"HI"
GOTO @MENU1
You may want to put CLS and VSYNC or WAIT.
Posted
#3✎ 246AveryFirst WeekJoined in the very first week of SmileBASIC SourceWebsiteThird YearMy account is over 3 years oldWebsiteDisguisedHiddenWebsite
@TITLE
PRINT"Title Screen"
B=BUTTON(2)
IF B AND A GOTO @MENU1
@MENU1
BEEP
PRINT"HI"
Your problem is the program keeps running past the IF statement onto the rest of the program.
I think you're expecting the IF statement to hold the program from continuing.
Instead of your IF statement, replace it with this.
REPEAT:UNTIL B AND A
This will hold the program until "B AND A" evaluates to TRUE.
EDIT:
I made a mistake!
REPEAT:B=BUTTON(2):UNTIL B AND A
This is the line you need!
The other one freezes the program because the variable B never updates.
Actually, I think the best way to do it is this:
@TITLE
PRINT"Title Screen"
REPEAT:UNTIL BUTTON(2) AND A
BEEP
PRINT"HI"
You can get rid of the B= and @MENU1 lines because they're unnecessary to my eyes.
Posted
Edited
by Avery