? How can i have two loops going at once? (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password
This website has been moved, please see this post

How can i have two loops going at once?

  • #1 ✎ 88 Jacklack3 Drawing I like to draw! Hobbies Day Person I like the warm sunshine and wake up early! Express Yourself Video Games I like to play video games! Hobbies I'm making a fan program to help me focus on projects, and so that i can still look at my 3ds showing a fan sprite. But i want the fan sprite to switch between frames using the SPCHR command and still play the beeps that make the fan sound. So how can i do this? Posted
  • #2 ✎ 1088 randomous Owner Robot Hidden Easter Eggs Second Year My account is over 2 years old Website Drawing I like to draw! Hobbies Instead of making two loops that each do one thing, you should instead think about one loop which does two things (or more). Basically everything in a game can go in one loop. For instance, you can do something like: WHILE WHATEVER CHANGE SPRITE PLAY SOUND WEND If you only want to play the sound sometimes, you can make a conditional: WHILE WHATEVER CHANGE SPRITE IF SHOULDPLAY THEN PLAY SOUND WEND Let's say that different sprites play different sounds. You could just use the character ID for the sprite you're setting as part of the check for playing a sound. The bottom line is: don't try to make multiple simultaneous loops. Many things can happen in a loop; you don't have to make a new one for each thing. Posted
  • #3 ✎ 88 Jacklack3 Drawing I like to draw! Hobbies Day Person I like the warm sunshine and wake up early! Express Yourself Video Games I like to play video games! Hobbies
    Instead of making two loops that each do one thing, you should instead think about one loop which does two things (or more). Basically everything in a game can go in one loop. For instance, you can do something like: WHILE WHATEVER CHANGE SPRITE PLAY SOUND WEND If you only want to play the sound sometimes, you can make a conditional: WHILE WHATEVER CHANGE SPRITE IF SHOULDPLAY THEN PLAY SOUND WEND Let's say that different sprites play different sounds. You could just use the character ID for the sprite you're setting as part of the check for playing a sound. The bottom line is: don't try to make multiple simultaneous loops. Many things can happen in a loop; you don't have to make a new one for each thing.
    Well the thing is that i want the fan sprite to change every 1 ms, but it would be to hard to go ahead and make the perfect timing in one loop. Plus i dont see how while would help.
    Posted
  • #4 ✎ 27 Ionesque You only want to change the sprite once per frame (The screen updates 60 times per second) any more is wasted processing power. If you want an example of managing many objects at once the Space Race program I wrote covers sprites animating many sprites once per 60, 30, and 15 frames per second with sound all at the same time. Posted