LoginLogin

Title screen is incorrect, please help.

Root / General / [.]

SoupCreated:
k so i'm trying to make a game and i've gotten as far as the title screen. my current road-block is that i'm trying to have two separate things running at the same time on the title screen. i have a loop that detects the button input that lets you proceed past the title screen but i'm trying to have a sprite animate at the same time as that loop is active. lemme show you what the code looks like:
LOCATE 15,40:?"LR TO START" GOTO @LOOP:GOTO @SP3

@LOOP
IF BUTTON()==#L OR BUTTON()==#R THEN GOTO @START
GOTO @LOOP

@SP3
SPCHR 4,0,176,32:WAIT 50
SPCHR 4,0,208,176,32:WAIT 50
GOTO @SP3
i know i'm doing something wrong here but i don't know what because, as the name implies, i suck at programming. if someone could help correct this, i would really appreciate it.

It looks like you are very new to programming. Everyone is new at some point so let me be one of the first to say welcome to the group. As for your problem it is very common for new programmers, so you are far from alone. Judging from your code I think you should step back a bit and get some more book learning and practice in before you start your dream game. For the book learning, I think Randomous' tutorial series is a great start http://smilebasicsource.com/page?pid=402. I would like you to learn the various looping structures and how to make functions. GOTO causes nothing but pain. As for practice, I think my list is also good http://smilebasicsource.com/forum?fpid=25495#post_25495. If you can make it through those you should be in good shape. For the title screen animation, SPCHR is for defining how to make a Sprite instead of actually making one. SPSET let's you set up a Sprite. SPOFS let's you move it to a spot on screen. SPSHOW and SPHIDE will show or hide a Sprite. Finally SPCLR will get rid of a Sprite you no longer need. I think you will like the SPANIM command. You can see a list of commands at http://smilebasic.com/en/reference/. I am actually wondering if you want to look at the BG commands instead for the title screen. So now with all that out of the way, you are running into needing a Game Loop. https://en.m.wikipedia.org/wiki/Game_programming has pseudo code that looks like
while( user doesn't exit )
 check for user input
 run AI
 move enemies
 resolve collisions
 draw graphics
 play sounds 
end while
The idea is you need one big loop to update everything little by little instead of one loop after another. In fact I think you want two game loops, one for the title screen and another for the game. Hope that makes sense, let me know if you have questions.

It looks like you are very new to programming.
yeah i just started actually learning basic like a few days ago. thanks for the help, i'm gonna look over all this now and see if i can get it all to work.

k so i'm trying to make a game and i've gotten as far as the title screen. my current road-block is that i'm trying to have two separate things running at the same time on the title screen. i have a loop that detects the button input that lets you proceed past the title screen but i'm trying to have a sprite animate at the same time as that loop is active. lemme show you what the code looks like:
LOCATE 15,40:?"LR TO START" GOTO @LOOP:GOTO @SP3

@LOOP
IF BUTTON()==#L OR BUTTON()==#R THEN GOTO @START
GOTO @LOOP

@SP3
SPCHR 4,0,176,32:WAIT 50
SPCHR 4,0,208,176,32:WAIT 50
GOTO @SP3
i know i'm doing something wrong here but i don't know what because, as the name implies, i suck at programming. if someone could help correct this, i would really appreciate it.
Just to start you off: SmileBASIC is currently reading your code like this:
LOCATE 15,40
?"LR TO START"
GOTO @LOOP
GOTO @SP3

@LOOP
IF BUTTON()==#L OR BUTTON()==#R THEN
  GOTO @START
ENDIF
GOTO @LOOP

@SP3
SPCHR 4,0,176,32
WAIT 50
SPCHR 4,0,208,176,32
WAIT 50
GOTO @SP3
SmileBASIC has sort of a "invisible cursor" that starts at line 1 and moves down the program, running each command in its path. The colons you're using just separate two statements just like the enter key does, and it has no special function other than that. Notice with this gif that the cursor skips over and ignores the GOTO @SP3. This cursor concept isn't exclusive to SmileBASIC - all languages read programs line by line, and the only way to run code at the same time as other code is either by lying or using threads. (SmileBASIC doesn't have threads... but you can lie!) What I mean by "lying" is that you can do things one after another and fool people into thinking that you're doing multiple things at once!
WHILE TRUE ' run this code and repeat it until TRUE is false. (never)
  
  VSYNC ' wait one frame (IMPORTANT! otherwise cursor moves too fast and overwhelms the 3ds)
  CLS ' clear text screen
  GCLS ' clear graphics screen
  
  ?"HEY EVERYONE!"
  ?"LOOK!"
  ?"I'M DRAWING TWO CIRCLES AT ONCE!"
  
  ' Little do they know that I'm drawing circle 1 and THEN drawing circle 2.... Muahahahaha
  GCIRCLE 50, 50, 7, #RED
  GCIRCLE 200, 150, 10, #BLUE
  
WEND ' run the code above until that while is false
Very simple example, but you get the gist. also, what seggiepants said.

also, what seggiepants said.
XD
I think you will like the SPANIM command.
I agree with this. SPANIM may be hard to understand at first, but once you get the hang of it it is VERY useful. (me being one who just figured it out lol)

ok i kinda skimmed what seggiepants linked me to but it did get me on a better track and i concluded that for the title screen, i could use a WHILE/WEND loop and it works. now i just need to figure out SPANIM and i can get it in full working order and move on to the M E A T of the project. the code looks like this now:
A=0
WHILE A<1
IF BUTTON()==#A THEN A=1
WEND
it's definitely better than what i was trying to do before.

ok i kinda skimmed what seggiepants linked me to but it did get me on a better track and i concluded that for the title screen, i could use a WHILE/WEND loop and it works. now i just need to figure out SPANIM and i can get it in full working order and move on to the M E A T of the project. the code looks like this now:
A=0
WHILE A<1
IF BUTTON()==#A THEN A=1
WEND
it's definitely better than what i was trying to do before.
Oooh! Nice use of conditionals! I'll let you in on a secret: there's a command that can break out of any loop! It's called BREAK, and to use it in your example, you'd do this:
WHILE TRUE
 VSYNC 1 'Wait one frame
 IF BUTTON()==#A THEN BREAK
WEND
Also, note two things: 1. I added a VSYNC command, which waits a frame before moving on. This'll help conserve some battery power, because running one button check over and over is a bit hard on the CPU. 2. Since I added the BREAK, I changed the conditional to always be TRUE. Finally, for the SPANIM problem: Here's my guide and 12Me21's guide on SPANIM.

I'll let you in on a secret: there's a command that can break out of any loop! It's called BREAK
i think i'll add that. it would help to have this run as clean as possible.

Here is a (small) guide to SPANIM that includes 3 usages: GENERAL USAGE This command is very confusing to many people, but I am sure that's just because of the mini-guide SB gives you. It is very confusing with the instructions. 'ITEM 1: Animation data itself.' How do we do this? I will explain after the general stuff used in all SPANIM commands first. So in all usages for SPANIM you want your management number of the sprite to influence first. That is a number (0-511) that you associate with sprites when you create them. You would want to create them with SPSET first. Then you want your animation type next. Here are 3 of various different animation types and how to represent them in your code:
  • 0 or "XY" - Change the X,Y coordinates of the sprite
  • 4 or "R" - Change rotation of the sprite
  • 5 or "S" - change the magnification of the sprite
Time 1, Time 2, Time 3... So on up to 32 This is how long it takes to complete each piece of data. This is represented by number of frames. If your number is posotive, it'll jump around. If your number is negative, it'll be smooth. Like, if my number is posotive and I want it to go from one side of the screen to the other, it'll start on one side, then jump to the next suddenly. If it's negative, it'll immediately start moving, and get to its destination by the time I specified has passed. Keep in mind that it keeps an even pace, so you don't have to worry about that. FOR X,Y COORDINATES This one confused me. So you have SPANIM (sprite management number),(0 or "XY"),(Time1) and after Time1 you don't have Time2, you have Item1. For XY coordinates, this is represented as 2 different numbers. X coordinate (for it to be on screen for the whole time, 0-400) and Y coordinate (0-240 for it to be on screen whole time.) You would just do this: SPANIM MN,AD,T1,X,Y. MN is management number. AD is animation type. T1 is time 1. X is horizontal coordinate. Y is vertical coordinate. You can after item 1 repeat with time2 and data2. You would do it like this: SPANIM MN,AD,T1,X,Y,T2,X,Y T2 being time 2. Note that this time starts after time one is finished. Rotation This is easy. You only need one number for the data, and that's how many degrees it would rotate. SPANIM MN,AD,T1,R. R is how many degrees to rotate. I like to do -360 to 360. To rotate 360 degrees clockwise in a second:
SPSET 0,0'Make sprite
SPANIM 0,4,-60,360
and counterclockwise:
SPSET 0,0'Make sprite
SPANIM 0,"R",-60,-360
So that's magic. SCALE This one is easier than the last one for me. You only have one number, and that's how big it is in comparison to the original sprite size (how big the sprite is with only spset.) So 1 would be the original size, 2 would be double that, 4 would be double 2, and so on. So you would do a simple this if you want it to grow:
SPSET 0,0'Create sprite
SPANIM 0,"S",-60,4
And to jump to a scale:
SPSET 0,0'Create sprite
SPANIM 0,5,60,4
VSYNC 60
Conclusion That's SPANIM. One last thing, once you have all of your data, you can tack on a number of times to loop. This is optional, but looping can be useful. It is just a number of times you want the animation to repeat itself, and if you want it to repeat itself until you pause it with SPSTOP or destroy the sprite, you can tack on a 0.

k so i figured out spanim so the title screen's almost done. all i need is to make a character to play as and put him on the title screen then it's done.

k so i figured out spanim so the title screen's almost done. all i need is to make a character to play as and put him on the title screen then it's done.
Sounds fun!

https://smilebasicsource.com/forum?fpid=25828#post_25828 i made a thread for the game itself so i'm gonna be in there now.