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 Discussion / Why is this object not moving?

Author
Message
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 26th Nov 2004 00:42
Here is the code for the second level of my game...



as you can see, at the end of the code is a subroutine that moves objects 321 to 360, I have it so that this subroutine is called when the variable "timeleft(0)" is below zero, and thus the objects should start to move. however, they do not. Please look at this code and see if you can spot the error.

Guns arnt the problem, people are the problem, shoot all the people and guns arnt a problem anymore.
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 26th Nov 2004 01:38
Try putting text output in wave2a to prove it actually runs. Keep dividing until you conquer

BatVink
http://biglaugh.co.uk/catalog AMD 3000+ Barton, 512Mb Ram, 120 Gig Drive space, GeForce 5200 FX 128 Mb, Asus A7N8X Mobo.
Terms & Conditions apply
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 26th Nov 2004 03:50
Ok I tried that, and when the text was supposed to show, it did not, this leads me to believe the Subroutine is not working. SO what should I do now?

Guns arnt the problem, people are the problem, shoot all the people and guns arnt a problem anymore.
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 27th Nov 2004 21:12 Edited at: 27th Nov 2004 21:14
if it didn`t work then it wasnt called, so if you look at this bit....

if timeleft(0)<0
timeleft(0)=0
endif

if timeleft(0)<0
gosub wave2a
endif

Do you see the error?, in the first line you check for the timeleft variable being less than zero, if it is then you set it to zero, right after that you check if timeleft is less than zero again, it isn`t because you just set it to zero when the code went through the line above, so you never will "gosub wave2a", move the top "if" statement to after the second "if" statement, then you should get the function called when timeleft<0 THEN set timeleft to zero (actualy you can do this inside the same "if") eg:

if timeleft(0)<0
gosub wave2a <<< here the code will go off to wave2a, then it will return to the next line in the code (timeleft(0)=0)
timeleft(0)=0
endif

will do the same thing but with one test, makes your code faster for one, and saves you making errors with logic like you did above for 2, also note that the wave2a function will only get called once (when the value goes under the first time) after that you need to decrement timeleft again to trigger it to move again etc, hope that helps.

Mentor.

PC1: P4 3ghz, 1gig mem, 3x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 28th Nov 2004 00:07
Ok, thanks, one less problem in this project!

Guns arnt the problem, people are the problem, shoot all the people and guns arnt a problem anymore.

Login to post a reply

Server time is: 2025-05-24 17:06:01
Your offset time is: 2025-05-24 17:06:01