Archived

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

PhilVaz

Half of Asteroids

Recommended Posts

Here is one-half of asteroids using Win GDI only. I''ve got this far, the rest is downhill. The math is taken care of pre-computed with arrays. Easiest for me to handle. Good for beginners, straight C, I comment everything. Source RocksAndShip.cpp Executable RocksAndShip.exe There is some bug around the edges, the ship gets stuck. Game Design Notes Phil Porvaznik

Share this post


Link to post
Share on other sites
Rick Scott says,

<< That''s killer! Did you want me to tell you why the bug is there and how to fix it? Or are you keen on going it alone? >>

Thanks for all the comments! Its very basic colors, basic graphics, but a classic game. I''m 37 btw, so I remember the original. Next I wanna work on a "Crazy Climber" with a scrolling building, but gotta finish Vazteroids first.

Yes, if you can tell me what causes the ship to "stick" and flicker between left/right sides when its moving slow? I can probably figure it out with a little thought. Game should be done in a week or so, learning DirectSound so I can add multiple sounds playing at the same time.

The best 2D Asteroids clone I''ve seen is one that''s been around a while called "Spheres of Chaos" by an English chap. I have the full version he made available in 2000. Very killer asteroids clone.

Phil P

Share this post


Link to post
Share on other sites
It seems that as soon as the ship touches an edge of the screen, you move it to the opposite edge. But if it is moving slow enough, then it will be now laying on the opposite edge, and will be teleported back again to the other side.

Two solutions I would think of :
1°/ When you move the ship to the opposite edge, make sure it does not lay on the edge on that side too.
2°/ Use these math :

if( Ship.x > Screen.Width + Ship.Width) Ship.x -= Screen.Width;
if( Ship.x < -Ship.Width) Ship.y += Screen.Width;
if( Ship.y > Screen.Height + Ship.Height) Ship.y -= Screen.Height;
if( Ship.y < -Ship.Height) Ship.y += Screen.Height;

ToohrVyk

Share this post


Link to post
Share on other sites
Change this:


if (x < 50 || x > (WINDOW_WIDTH - 50)) x = WINDOW_WIDTH - x;
if (y < 50 || y > (WINDOW_HEIGHT - 50)) y = WINDOW_HEIGHT - y;


to this:


if (x < 50)
x = WINDOW_WIDTH - 50;
else if(x > (WINDOW_WIDTH - 50))
x = 50;

if (y < 50)
y = WINDOW_HEIGHT - 50;
else if(y > (WINDOW_HEIGHT - 50))
y = 50;

(Space it to your liking, of course) See if that works for ya

[edited by - Rick Scott on May 30, 2003 9:24:59 AM]

Share this post


Link to post
Share on other sites