Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

pat1926

Asteroids Clone

This topic is 5247 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was just wondering how you have the same effect as Asteroids, where the ship will pass from one edge of the screen and appears at the other. I would like the object to be half drawn on one side and the rest drawn on the other as it passes over. Is there a way to do this?

Share this post


Link to post
Share on other sites
Advertisement
When you update your ships position do a check like this.



// defines for a 640 x 480 screen

#define SCREEN_LEFT_COORD (0)
#define SCREEN_RIGHT_COORD (640)
#define SCREEN_TOP_COORD (0)
#define SCREEN_BOTTOM_COORD (480)


if (shipx < SCREEN_LEFT_COORD)
shipx += SCREEN_RIGHT_COORD;
if (shipx > SCREEN_RIGHT_COORD)
shipx -= SCREEN_LEFT_COORD;

if (shipy < SCREEN_TOP_COORD)
shipy += SCREEN_BOTTOM_COORD;
if (shipy > SCREEN_BOTTOM_COORD)
shipy -= SCREEN_TOP_COORD;


So you just check if the ship is outside your screen boundary and if it is, add the width of the screen onto it''s coordinate.

Hope that helped,
FReY

Share this post


Link to post
Share on other sites
I could put a question which is related with "wrapping". Should i clip the part which is out of sight? Or is it ok without clipping?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!