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.

DarkBASIC Professional Discussion / While loop not running?

Author
Message
CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 20th May 2011 22:05
Hello, I am trying to get a while loop to loop through all the object numbers then restart and do it again, to test this I added a Text statement which should be on all the time, considering it restarts, but the text never appears! (The COLLIDED one does when I touch the cube, though)



Always program as if the person maintaining your program is a psychopath that knows where you live
Jimpo
21
Years of Service
User Offline
Joined: 9th Apr 2005
Location:
Posted: 20th May 2011 22:07
Your loop checks 'x1' but you are only changing 'x' in the loop. It's just a simple typo.

No Time To Code
17
Years of Service
User Offline
Joined: 22nd Dec 2008
Location:
Posted: 20th May 2011 22:13
Also, it looks like ObjectNum is not defined so it equals 0. Since x is never <= 0 the loop won't run.

It is not from the benevolence of the butcher, the brewer, or the baker, that we expect our dinner, but from their regard to their own interest. --Adam Smith
CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 20th May 2011 22:48 Edited at: 20th May 2011 22:56
Haha, I can't believe I missed both of those

I'm trying to get collision working, so if my player (object 1) touches another object his position will be reset, but it's just showing a black screen with the new while loop, why?



Always program as if the person maintaining your program is a psychopath that knows where you live
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 21st May 2011 03:32
Still you're not changing the variable x1 in your while loop. And your assigning x, y and z to themselves.

Warning! May contain Nuts!
Wyldhunt
16
Years of Service
User Offline
Joined: 27th Sep 2009
Location: The Dark Side
Posted: 21st May 2011 20:30 Edited at: 21st May 2011 23:38
Try this. I haven't tested it in DBP yet, but you can probably get the idea from it if I made a typo.



EDIT:
Fixed a minor typo that I noticed... A couple of times.

Login to post a reply

Server time is: 2026-07-10 20:05:57
Your offset time is: 2026-07-10 20:05:57