Label Programs
splapoonCreated:
if i write something likeThats because you're using the PRINT command, instead of the SPSET command. This is kinda simple to get to work, first, hit the smile button at the keyboard. Next, go to the SPDEF section and select the sprite number you want to use. For example:@COM INPUT"CODE";RANDOMVARNAME$ IF RANDOMVARNAME$==PRINT THEN GOTO @PRINT IF RANDOMVARNAME$==SPRITE THEN GOTO @SPRITE GOTO @COM @PRINT PRINT "PRINT" GOTO @COM @SPRITE PRINT"SPRITE" GOTO @COMIf i type sprite, ill take me to print insted
SPSET 0'(Management number),0'(Strawberry sprite)The maximum amount of sprites you can get on-screen is 255, so you gotta be careful with that. If you want just to copy the code, just type this:
SPSET 0,0
Now lets say I have two labels. label 1 is called rps for a rock paper scissors game, label 2 is called write to print something. now if i type write to print something, instead taking me to write, it takes me to the rock paper scissors gameif i write something likeThats because you're using the PRINT command, instead of the SPSET command. This is kinda simple to get to work, first, hit the smile button at the keyboard. Next, go to the SPDEF section and select the sprite number you want to use. For example:@COM INPUT"CODE";RANDOMVARNAME$ IF RANDOMVARNAME$==PRINT THEN GOTO @PRINT IF RANDOMVARNAME$==SPRITE THEN GOTO @SPRITE GOTO @COM @PRINT PRINT "PRINT" GOTO @COM @SPRITE PRINT"SPRITE" GOTO @COMIf i type sprite, ill take me to print instedSPSET 0'(Management number),0'(Strawberry sprite)The maximum amount of sprites you can get on-screen is 255, so you gotta be careful with that. If you want just to copy the code, just type this:SPSET 0,0
At first: Welcome @splapoon
Its seems you are realy new at programming.
I'm not sure, but it sounds like you're having trouble while programming.
The Code is always executed from first line to the last line.
So you should stop/end the code after the Main-loop.
Please Note:
If you write programs without function, it does matter in which order the programs are written.
Okay hold on, I think everyone is working on different pages here.
if i write something likeThe only issue I'm seeing here is that PRINT and SPRITE should be in quotes as they are strings of text. After fixing that, it seems that this example works as it should. Note that in the examples listed here, I've renamed the RANDOMVARNAME$ into just V$ so it could fit on the screen easier. Maybe check these things:@COM INPUT"CODE";RANDOMVARNAME$ IF RANDOMVARNAME$==PRINT THEN GOTO @PRINT IF RANDOMVARNAME$==SPRITE THEN GOTO @SPRITE GOTO @COM @PRINT PRINT "PRINT" GOTO @COM @SPRITE PRINT"SPRITE" GOTO @COMIf i type sprite, ill take me to print insted
- Check to see that you're comparing against the word SPRITE, not the variable SPRITE. This code
IF V==SPRITE THEN GOTO @SPRITE 'won't work
won't work because it's checking if variable V (which isn't the same as V$) is equal to the uninitialized variable SPRITE, which is zero by default. The correct code in this case would beIF V$=="SPRITE" THEN GOTO @SPRITE
- Check to see if you're using the same variable in the INPUT and IF statements. They should both have the same type suffix (the little $ thing added onto the end, which says "this is a string")
- Check to see if the labels are correctly set to point to the right sections of code. I can't count how many times I've copy and pasted a bit of code only to forget to change it and have a mysterious bug crop up.
done = FALSE WHILE done == FALSE INPUT"CODE";cmd$ IF cmd$=="PRINT" THEN CMD_PRINT ELSEIF cmd$=="SPRITE" THEN CMD_SPRITE ELSEIF cmd$=="EXIT" THEN done = TRUE ELSE PRINT "Sorry, I didn't understand that." ENDIF WEND DEF CMD_PRINT PRINT "PRINT" END DEF CMD_SPRITE PRINT"SPRITE" ENDThe real Elephant in the room is that you shouldn't be programming with line labels for a variety of reasons. I can make a lengthy post why if you like otherwise I will spare you the rant. It has been gold plated a bit, but isn't the above a lot easier to read, understand, and maintain? While loops, For loops, and functions are your friends and are there to make your life better. The @COM versus @A issue in the last few posts would be a non existant problem if you weren't using GOTO and GOSUB. It takes very little time for GOTO to stab you in the back COMPATABILITY NOTE: For SmileBasic on switch use #TRUE and #FALSE instead of TRUE and FALSE
Ok, I know this is old but, I heard you want to make a rock-paper-scissors game. Its pretty simple to make without sprites. Haven't tested this code though:
@RPL GOTO @SELECTW @SELECTW @SELECTROCK PRINT ">Rock Paper Scissors IF BUTTON(0)==#A THEN W=1:GOTO @CPUSELECTW IF BUTTON(0)==#RIGHT THEN GOTO @SELECTPAPER IF BUTTON(0)==#LEFT THEN GOTO @SELECTSCISSORS GOTO @SELECTROCK @SELECTPAPER PRINT "Rock >Paper Scissors IF BUTTON(0)==#A THEN W=2:GOTO @CPUSELECTW IF BUTTON(0)==#LEFT THEN GOTO @SELECTROCK IF BUTTON(0)==#RIGHT THEN GOTO @SELECTSCISSORS GOTO @SELECTPAPER @SELECTSCISSORS PRINT "Rock Paper >Scissors IF BUTTON(0)==#A THEN W=3:GOTO @CPUSELECTW IF BUTTON(0)==#LEFT THEN GOTO @SELECTSCISSORS IF BUTTON(0)==#RIGHT THEN GOTO @SELECTROCK @CPUSELECTW WE=RND(4) IF WE==2 AND W==1 THEN PRINT "You got covered up! Enemy used paper. Try again!":GOTO @SELECTW IF WE==3 AND W==2 THEN PRINT "You have been chopped up! Enemy used scissors. Try again!":GOTO @SELECTW IF WE==1 AND W==3 THEN PRINT "You have been destroyed! Enemy used rock. Try again!":GOTO @SELECTW IF WE==1 AND W==2 THEN PRINT "The enemy got covered up! You used paper. You win!":GOTO @SELECTW IF WE==2 AND W==3 THEN PRINT "The enemy got chopped up! You used scissors. You win!":GOTO @SELECTW IF WE==3 AND W==1 THEN PRINT "The enemy has been destroyed! You used rock. You win!":GOTO @SELECTW IF WE==1 AND W==1 THEN PRINT "Shoot. No effect yet!":GOTO @SELECTW IF WE==2 AND W==2 THEN PRINT "Shoot. No effect yet!":GOTO @SELECTW IF WE==3 AND W==3 THEN PRINT "Shoot. No effect yet!":GOTO @SELECTW IF WE==4 THEN GOTO @CPUSELECTW GOTO @RPLAs I've stated, haven't tested this code. Please post the problems with it!
Ok, I know this is old but, I heard you want to make a rock-paper-scissors game. Its pretty simple to make without sprites. Haven't tested this code though:For conditions, it's best to use && instead of AND.@RPL IF WE==3 AND W==3 THEN PRINT "Shoot. No effect yet!":GOTO @SELECTW GOTO @RPLAs I've stated, haven't tested this code. Please post the problems with it!