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 / Help with making a sprite bounce off the sides of the screen

Author
Message
negi
13
Years of Service
User Offline
Joined: 16th Feb 2011
Location:
Posted: 22nd Dec 2011 03:08
Hay

I have been making my own version of Asteroids, and want to make it so the asteroids bounce off the sides of the screen in a random direction. When I try that the sprite goes haywire and sometimes gets stuck in the side of the screen from time to time. I was hoping for a better solution to this problem.

here is the code for my asteroids class



any help would be great!

All is revealed with time.
vitinho444
14
Years of Service
User Offline
Joined: 12th Oct 2010
Location:
Posted: 22nd Dec 2011 15:58
You can try making invisible sprites on the limits of the screen, then check for collision (dbCollision) and then just use the dbRand maybe...

C++ Medium 3.5/5
www.oryzhon.com <-- My company's website (W.I.P)
negi
13
Years of Service
User Offline
Joined: 16th Feb 2011
Location:
Posted: 22nd Dec 2011 22:03
Ok I figured to out I was rotating the sprite too much

All is revealed with time.

Login to post a reply

Server time is: 2024-11-19 05:37:32
Your offset time is: 2024-11-19 05:37:32