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.

Dark GDK / Can't Rotate Sprite

Author
Message
Superdeath360
13
Years of Service
User Offline
Joined: 23rd Nov 2010
Location:
Posted: 8th Jun 2011 21:29 Edited at: 8th Jun 2011 21:32
So, with this code, I have no problem, the "tank" rotates perfectly as I press left and right buttons.


But when I add this to the end:

The tank no longer rotates.

I really can't find the problem, perhaps it is blindingly obvious...
OH, and the PointSprite function isn't mine..I've forgotten who I copied it from

herp derp
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 8th Jun 2011 22:15
Weird, but I have one guess. If sprite 4 does not exist, in the dbSpriteCollision command you are testing against a non-existent sprite. Dark GDK functions do not return error codes, but they are known to write error codes sometimes into the first four bytes of the stack, with the result that the value of the first variable of the main loop gets changed. In your case, the first variable is tank angle. If you write its value onto the screen, you may find that the tank angle variable gets changed to an error code.

There are two solutions: (a) test for collision only when the sprite exists, (b) add a dummy integer variable to the main loop before tank angle, e.g. int dummy = 0. Then the dummy gets corrupted and not your used variable.
Superdeath360
13
Years of Service
User Offline
Joined: 23rd Nov 2010
Location:
Posted: 8th Jun 2011 22:18
Thank you very much, Mireben! I made sure it only checks for sprite collision when sprite 4 exists, and the problem was fixed .

herp derp
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 8th Jun 2011 23:22
Nice, I'm glad that it worked!

Login to post a reply

Server time is: 2024-11-19 10:33:48
Your offset time is: 2024-11-19 10:33:48