Original Post
🔒 Locked
Asteroids Clone
Advertisement
When you update your ships position do a check like this.
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
// 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
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement