Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / While loops

Author
Message
cryptojoe
12
Years of Service
User Offline
Joined: 27th Sep 2012
Location: Michigan U.S.A
Posted: 14th Jan 2013 20:57 Edited at: 14th Jan 2013 20:59
I have a while loop that looks like this;


the compiler tells me that the "endwhile" is a command out of place... what have I done wrong?
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 14th Jan 2013 21:12
You are missing an endif command to go with "if getSpriteCurrentFrame(1) >= 6".

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Ranietz
AGK Gold Backer
20
Years of Service
User Offline
Joined: 2nd Sep 2004
Location: Norway
Posted: 14th Jan 2013 21:13 Edited at: 14th Jan 2013 21:14
You are missing an "endif".

Maybe this will work?


Edit: Ancient Lady beat me to it.
Josk
16
Years of Service
User Offline
Joined: 2nd Apr 2008
Location:
Posted: 14th Jan 2013 21:14
Missed out an Endif.
cryptojoe
12
Years of Service
User Offline
Joined: 27th Sep 2012
Location: Michigan U.S.A
Posted: 14th Jan 2013 21:23
I see it now ... don't know how I missed that...
cryptojoe
12
Years of Service
User Offline
Joined: 27th Sep 2012
Location: Michigan U.S.A
Posted: 14th Jan 2013 21:43 Edited at: 14th Jan 2013 21:54
code compiles, but sprite dose not move
this code was originally a bunch of if, endif statements that worket, but I want to make them into a while loop that I can use as a subroutine...

this is what the original code looks like


and this is the code I have now that dose not work... I know I have done something wrong,but what?

*EDIT
I got it, it needs a "Sync()" in the while loop... thats why its not updateing the screen...
Impetus73
13
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 17th Jan 2013 09:31
This is a bad way to code, this means that the rest of your game stops while the sprite is moving to the right. You should replace the while loop with an if, so it's only checked once per loop of the whole program.

----------------
AGK programmer
Did Amiga / AMOS programming in the 90's.
cryptojoe
12
Years of Service
User Offline
Joined: 27th Sep 2012
Location: Michigan U.S.A
Posted: 17th Jan 2013 16:20 Edited at: 17th Jan 2013 16:34
I did abandon the while loop and went back to if statements...

now I'm stuck on getting a the sprite to jump...
http://forum.thegamecreators.com/?m=forum_view&t=202861&b=41

I have a subroutine that compiles and runs but, it appears to do nothing... "I do not know how thats possible " and the fact that it appears to do nothing is making it impossible for me to debug...
Impetus73
13
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 18th Jan 2013 12:46
I'll need the whole project to debug that, since your only posting random parts... if you email it to: support@minportal.net I'll tell you why it does not work, and then I'll delete the files after.

----------------
AGK programmer
Did Amiga / AMOS programming in the 90's.
cryptojoe
12
Years of Service
User Offline
Joined: 27th Sep 2012
Location: Michigan U.S.A
Posted: 22nd Jan 2013 17:55
I'm more than happy to share my project... this is just a hobby project...

main.agc


setup.agc


subroutines.agc


fuctions.agc
Impetus73
13
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 22nd Jan 2013 21:35
When the program jumps to the sprite_jumpR: subroutine, it never gets back, because the myTime# and startTime# never changes, so the while loop goes forever, and keeps sending the same values to a function, over and over, and you expect a different result over time That's the definition of madness, by the way :-p

I'm afraid this code is so broken, I would have to rewrite most of it, to get it to work as you expect. Maybe you should try a new project, and only focus on making a jumping sprite, then add walking afterwards. Training makes master!, as we say in Norway.

----------------
AGK programmer
Did Amiga / AMOS programming in the 90's.
cryptojoe
12
Years of Service
User Offline
Joined: 27th Sep 2012
Location: Michigan U.S.A
Posted: 22nd Jan 2013 22:01
Madness...LOL...

yha I may have to start with making a sprite jump... I just hate to start the whole thing over...
cryptojoe
12
Years of Service
User Offline
Joined: 27th Sep 2012
Location: Michigan U.S.A
Posted: 22nd Jan 2013 22:11
the first 2 lines of sprite_jumpR:


come from this agk demo,
http://www.thegamecreators.com/news/2012/07/pardon-me-i-just-berped/

and the demo works just fine, puzzeling...
Impetus73
13
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 23rd Jan 2013 03:49
Oh, you need to add myTime# = Timer() just after the sync() in the subroutine.

It at least jumps some after this, but it's far from done

----------------
AGK programmer
Did Amiga / AMOS programming in the 90's.
cryptojoe
12
Years of Service
User Offline
Joined: 27th Sep 2012
Location: Michigan U.S.A
Posted: 29th Jan 2013 05:05
ok...I see... thank you...

Login to post a reply

Server time is: 2024-11-24 09:03:31
Your offset time is: 2024-11-24 09:03:31