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 / Extra addition? Or what?

Author
Message
sponge008
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: MA, USA
Posted: 20th Mar 2004 22:32







In this program (the beginnings of an Asteroids remake), there is a strange error. The "keepmoving" function, instead of making the ship keep moving because of zero gravity, for some reason, adds 320 and 240, respectively, to the ship's x and y coordinates, respectively. I've looked through the entire program and cannot see why this is. Do you people have any idea what is going on? (this is in DBPro)
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 21st Mar 2004 17:29
Keepmoving is not a function. Its a subroutine.

I think the cause of your problem is the logic of your keepmoving subroutine. You've got sprite 1,320,240,1 at the beginning of your extract. What is happening is that your code is always adding the 320 and 240 to the existing position of your sprite (sprite 1,sprite x(1)+movingx,sprite y(1)+movingy,1)

Thats because the movingx and movingy equations are always being calculated as 320 - 0 and 240 - 0. The x2 and y2 are always 0 because the programme never puts any information in them.

I see what you are trying to do with:

if whichxy=1 then whichxy=2
if whichxy=2 then whichxy=1

but it doesn't work. Look at it carefully. You are making whichxy 2 and then in the very next line you are making it 1 again.

Philip

What do you mean, bears aren't supposed to wear hats and a tie? P1.3ghz / 384 megs / GeForce MX 5200 128meg / WinXP home
sponge008
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: MA, USA
Posted: 23rd Mar 2004 00:10 Edited at: 23rd Mar 2004 00:14
Oh...oops! The word subroutine slipped my mind. Thanks for noticing, I am kicking myself right now.

Edit...ummm...sorry guys, but this still isn't working.


zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 23rd Mar 2004 02:44
Quote: "if whichxy=1 and changed=0
whichxy=2
changed=1
endif

if whichxy=2 and changed=0
whichxy=1
changed=1
endif

changed=0"


What does setting changed to 1 accomplish? You immediately set it back to zero. I'm sure you have a plan there, but it is missing something.
--
TAZ

sponge008
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: MA, USA
Posted: 23rd Mar 2004 18:02 Edited at: 23rd Mar 2004 18:04
Oh, you're right! This is an unexpected brain-breaker.

Edit: but it's supposed to be changed the next loop, which means that it should switch from 1 to 2 every other loop, and from 2 to 1 every other loop...what am I missing?
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 23rd Mar 2004 22:15 Edited at: 23rd Mar 2004 22:17
This will toggle whichxy every loop between 1 and 2.

if whichxy=1
whichxy=2
else
whichxy=1
endif

Basically, the value itself is the trigger for the IF statement.
--
TAZ

sponge008
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: MA, USA
Posted: 24th Mar 2004 00:42 Edited at: 24th Mar 2004 00:44
D'oh! I should have thought of that myself! Thanks a lot!

Edit: rats! It still doesn't work!!!!! OMG!!!!

sponge008
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: MA, USA
Posted: 25th Mar 2004 17:55
Guys, I'm really stuck. Does anyone have any ideas?
sponge008
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: MA, USA
Posted: 27th Mar 2004 02:40
Update: there is no reason for this not to work, yet it doesn't!!!!! What is wrong with the updated code?

Login to post a reply

Server time is: 2024-11-26 10:45:07
Your offset time is: 2024-11-26 10:45:07