@ultifinitus
Did you learn anything else particularly useful? |
Not really I'm sad to say. I used skills that I already knew. The practice with using vectors of objects was useful though since it's somewhat new to me. I kept things simple. Down and dirty, which is why development was quick.
How did you do your collision system? |
Thought I'd try keeping the collision tests really simple. I did like Xander314 described and treated everything as circles, except shots, which are small so I treated them as points. It works pretty well.
Here's the collision detection function for the player ship hitting an asteroid:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
bool ship::hitRock(ani& rAni)// asteroids are ani (simple animated) objects
{
// find square of center to center distance
float distSq = (posx-rAni.posx-rAni.szx/2.0f)*(posx-rAni.posx-rAni.szx/2.0f)
+ (posy-rAni.posy-rAni.szy/2.0f)*(posy-rAni.posy-rAni.szy/2.0f);
if( setNow == setG && distSq < (szx+rAni.szx)*(szx+rAni.szx)/4.0f )// setG = "normal" frame set
{
chSpeed = false;// thruster off
velx = rAni.velx;// explosion travels
vely = rAni.vely;// with rock
setNow = setK;// switch to explosion frame set
frIndex = 0;// start at 1st frame
return true;// hit
}
return false;// miss
}// end of hitRock()
|
The one for ship hit by a shot is simpler:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
bool ship::hitShot(shot& rShot)
{
float distSq = (posx-rShot.posx)*(posx-rShot.posx) + (posy-rShot.posy)*(posy-rShot.posy);
if( distSq < szx*szx/4.0f )
{
chSpeed = false;
velx = vely = 0.0f;// explosion in place
setNow = setK;
frIndex = 0;
rShot.inAir = false;// stops shot animation
return true;
}
else
return false;
}
|
The one for an asteroid hit by a shot is similar.
Asteroids.ccp has 1,026 lines of code. This is everything except the .h and .cpp files for the classes. There's probably at least another 1,000 lines of code in them (total, not each).
What did you do your graphics in/ how long did they take you? |
I used SFML in the game. I used Photoshop/Imageready to create the animations. This is very tedious. Each animation takes me an hour or two. I re-use them from game to game for this reason. Only one is new for this game (the player ship with a flickering rocket plume when it is accelerating).
@Xander314. The graphics I see at your site look great! I'll look into using blender3d. Anything that makes creating animations easier.
@Computergeek01: Your idea for control key usage sounds good. I'm not using keys to move the ship up/down/left/right though. The ship rotates (left/right arrow) and accelerates in the direction it is facing (up arrow). Any key (not used for something else) as fire? Why not.
I'm using the spacebar, which is pretty easy to find/hit.
Uh... dunno right now.
Do you ever suffer from post project completion euphoria/blues ?
It's a weird combination of "YEAH!!" and "What now? My project's done and I feel lost."