Author |
Message |
NewbiwTech
|
Posted: Sat Nov 20, 2010 12:19 pm Post subject: How to enter different loops with user inputs? |
|
|
What is it you are trying to achieve?
I am trying to create an user input animation with sprites. (Maplestory animation) I have different loops for different keys.
I have loops for when (KEY_RIGHT_ARROW) is pressed, etc.
What is the problem you are having?
Turing doesn't respond as soon as i press the right arrow key, i have to hold it for few sec then it performs the loop action.
I am also trying to have the loop to stop when the right arrow key is NOT being pressed. (Thus going back to standing still animation loop)
and also jumping from one animation loop to another when the user presses a corresponding key.
For example, moving to the right animation loop -> moving to the LEFT animation loop (when left arrow key is pressed)
Describe what you have tried to solve this problem
So far i have standing still animation loop with (exit when chars (KEY_RIGHT_ARROW))
So that once the right arrow key is pressed it changes to the moving to the right animation.
Please specify what version of Turing you are using
version 4.1.1
This may sound confusing, so i will provide specific information / situation when you guys need it. Thanks! |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
TokenHerbz
![](http://compsci.ca/v3/uploads/user_avatars/717170395558e628d9452b.jpg)
|
Posted: Sat Nov 20, 2010 1:07 pm Post subject: RE:How to enter different loops with user inputs? |
|
|
sounds like you have like 5 loops inside your main loop... You don't need a loop for each "direction" your drawing, try to accomplish this removing those loops and if you still have trouble post again and I'll give you a bit more advice... ![Smile Smile](http://compsci.ca/v3/images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
NewbiwTech
|
Posted: Sat Nov 20, 2010 2:17 pm Post subject: Re: How to enter different loops with user inputs? |
|
|
My sprite animations are done by different frames,
and in order for the sprite to move, im using var xValue := xValue +20 inside my loops.
If i remove the loops, i can't continuously move the sprite when the key is being pressed. Is there another way of accomplishing what i'm doing without loops? |
|
|
|
|
![](images/spacer.gif) |
RandomLetters
|
Posted: Sat Nov 20, 2010 2:23 pm Post subject: RE:How to enter different loops with user inputs? |
|
|
As TokenHerbz said, it is best to try to have just one loop, with all the movement in it.
I'm not very familiar with turing syntax but you could try something like
if moveleft then
...
end if
if moveright then
...
end if
if up then...
All in one loop.
Or if you have animations in each loop then you can have them as procedures, and call them from your main loop.
proc moveleft
...
end moveleft
and in your main loop:
moveleft
moveright etc... |
|
|
|
|
![](images/spacer.gif) |
NewbiwTech
|
Posted: Sat Nov 20, 2010 3:25 pm Post subject: Re: How to enter different loops with user inputs? |
|
|
Thank you for the procedures command, helped me a lot. Now the only problem is since my frames have a 0.5 sec delay in between each, even if i press the right key, the whole loops has to go through itself again until it reaches the procedure part. Is there any way to remove the delay of 3sconds by making the procedure occur instantly when the key is hit? |
|
|
|
|
![](images/spacer.gif) |
TokenHerbz
![](http://compsci.ca/v3/uploads/user_avatars/717170395558e628d9452b.jpg)
|
Posted: Sat Nov 20, 2010 4:58 pm Post subject: RE:How to enter different loops with user inputs? |
|
|
yes you probably have delay(##) several times in your code, check for that, otherwise it could be how your "drawing" the movements. If you post the code I'll take a look...
you only need one procedure to draw your images, not several. lets not over complicate things now ... (not that its actually making it more complicated...) |
|
|
|
|
![](images/spacer.gif) |
NewbiwTech
|
Posted: Sat Nov 20, 2010 5:05 pm Post subject: Re: How to enter different loops with user inputs? |
|
|
thanks for the help every1.
@Token, what you said solved the last bit of my problem. I reduced the delay between the frames and now it doesn't have the delay when i press a key.
And now i have 1 loop with if statment and procedures that makes my sprites run smoothly. Thanks!! |
|
|
|
|
![](images/spacer.gif) |
TokenHerbz
![](http://compsci.ca/v3/uploads/user_avatars/717170395558e628d9452b.jpg)
|
Posted: Sat Nov 20, 2010 5:54 pm Post subject: RE:How to enter different loops with user inputs? |
|
|
if you have a delay in your code, there shouldn't be multiple ones. However I'm still interested in seeing some code not to criticize . |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
NewbiwTech
|
Posted: Sat Nov 20, 2010 7:08 pm Post subject: Re: How to enter different loops with user inputs? |
|
|
procedure standing
Sprite.Show (standing1)
delay (100)
Sprite.Hide (standing1)
Sprite.Show (standing2)
delay (200)
Sprite.Hide (standing2)
Sprite.Show (standing3)
delay (200)
Sprite.Hide (standing3)
Sprite.Show (standing2)
delay (200)
Sprite.Hide (standing2)
end standing
Since its maplestory animated, i have 3 different frames showing the "standing" animation. |
|
|
|
|
![](images/spacer.gif) |
TokenHerbz
![](http://compsci.ca/v3/uploads/user_avatars/717170395558e628d9452b.jpg)
|
Posted: Sun Nov 21, 2010 11:49 am Post subject: RE:How to enter different loops with user inputs? |
|
|
I guess if that works, i've not used sprites but i don't think i would go about doing it that way. I for one dislike using mutliple delays unless its for a good reason, one which in your program you don't NEED to use. You should have variables to know "which way" your characters faceing, when hes standing still, alternating threw those standing images. and when hes moving, it draws the moving animations also alternating. if you get what i mean, if not let me know i'll give you a run down and example.
I'll take a look into sprites to however i think its basically the same thing as using images. |
|
|
|
|
![](images/spacer.gif) |
|