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.

Newcomers DBPro Corner / For x Next x loop isn't moving my object all of a sudden.

Author
Message
Jjsaro
5
Years of Service
User Offline
Joined: 21st May 2014
Location:
Posted: 23rd Jun 2014 16:54
*Siderant: New forumer wait time will probably render this problem outdated by the time it's actually posted. I will probably have figured this problem out or will have died of a rage heart attack while you are reading this.

So, I have an object that is supposed to drop off the screen. It is hidden until activated because it's the first frame of animation that is separated from the original object its tied to. Anyway this loop proved to do absolutely nothing upon running it-

I know the loop runs because the texture 7 changes but the plane object 9 does not move at all. I had it on a parabola equation and got frustrated but even after converting it to this simple diagonal movement it does nothing. I don't know if it's the show command that locks it. If it's at all relevant all objects are set in this loop at the start. set object x,1,1,0
Lucas Tiridath
AGK Developer
11
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 24th Jun 2014 14:09
Your for loop wont work because by default, for loops in DBP move forwards and check whether x > final. Therefore x = 5, 5 > -700, thus the loop never runs. What you need to do is to specify the step as -1 like so.


Hope that helps.

Jjsaro
5
Years of Service
User Offline
Joined: 21st May 2014
Location:
Posted: 26th Jun 2014 00:16
Thanks, it did help. (I basically just dicked around playing minecraft for a few days instead of working on my game to make myself feel like this post wasn't a waste of my time.)
luskos
12
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 27th Aug 2014 19:58
Reading the descriptions of a command in help files (F1) helps a lot sometimes, but you need to pay attention.

FOR

Description

The FOR command requires a variable and two values to begin the loop. The variable stores the first value, and is incremented each loop until it reaches the second value. The size of the increment is determined by the STEP value. The NEXT command is placed to mark the end of the loop. As the variable increments during the loop, you can use its value in many ways. Optionally, you can count in descending order by specifying a high first number, a low second number and a negative step value.

Coding is My Kung Fu!
And My Kung Fu is better than Yours!

Login to post a reply

Server time is: 2020-01-20 18:53:54
Your offset time is: 2020-01-20 18:53:54