[SOLVED] Spawn entities along bezier curve
Posted: Sun Jan 23, 2011 1:40 pm
So over the past couple of months I've been trying to get my feet wet by writing a little shmup in C++/SDL. Things have been going pretty well up until this point and I've been able to implement a scrolling background, a player ship with a specified number of lives, explosion animations for enemies and for the player, 3 different weapon tiers, a basic HUD, etc...
The problem is I find my code becoming increasingly disorganized and at times somewhat "hackish". Lately I've been spending more time just trying to figure out how to design my classes so I can more easily accommodate things like a text file parser for level creation, ability for enemies and the player ship to take more than 1 hit before explosion, a scoring system, and so on. I really want to keep things simple seeing as though this is my first real game. Maybe I've gotten in over my head but I've gotten much farther than I thought I would.
Right now I'm trying to figure out a basic way to spawn waves of enemies. What I have so far is an enemy factory class with a generate wave member function. The class itself contains a std::vector that stores the enemies and a single formation is hard coded into the function. I KNOW there is a much better way of doing this, but I'm fairly new to this and the solution is eluding me as it stands. Below is a VERY basic start, but I am pretty sure I want to stay away from this way of doing it.
So i'm wondering, what is a better way of doing this? Or should I hard code each of enemy formation that I want and have them triggered by a text file that contains level definitions? I know these are some fairly basic things I'm dealing with but I'm having trouble wrapping my mind around the best way to implement this. Any help would be appreciated.
The problem is I find my code becoming increasingly disorganized and at times somewhat "hackish". Lately I've been spending more time just trying to figure out how to design my classes so I can more easily accommodate things like a text file parser for level creation, ability for enemies and the player ship to take more than 1 hit before explosion, a scoring system, and so on. I really want to keep things simple seeing as though this is my first real game. Maybe I've gotten in over my head but I've gotten much farther than I thought I would.
Right now I'm trying to figure out a basic way to spawn waves of enemies. What I have so far is an enemy factory class with a generate wave member function. The class itself contains a std::vector that stores the enemies and a single formation is hard coded into the function. I KNOW there is a much better way of doing this, but I'm fairly new to this and the solution is eluding me as it stands. Below is a VERY basic start, but I am pretty sure I want to stay away from this way of doing it.
Code: Select all
void Enemy_Factory::generateWave()
{
//I know the Enemy constructor is quite cryptic, this is what I meant by "hackish"
//below is a basic guide to the arguments it is taking
//Enemy(pointer to sdl surface, imageX, imageY, width, heigh, R, G, B, bitmap file, screenX, screenY, movement speed)
enemyList.push_back(new Enemy(m_graphics, 0, 0, 51, 46,
255, 0, 255,
"enemies.bmp", 0,
-50, m_maxSpeed));
enemyList.push_back(new Enemy(m_graphics, 0, 0, 51, 46,
255, 0, 255,
"enemies.bmp", 150,
-100, m_maxSpeed));
enemyList.push_back(new Enemy(m_graphics, 0, 0, 51, 46,
255, 0, 255,
"enemies.bmp", 300,
-150, m_maxSpeed));
enemyList.push_back(new Enemy(m_graphics, 0, 0, 51, 46,
255, 0, 255,
"enemies.bmp", 450,
-100, m_maxSpeed));
enemyList.push_back(new Enemy(m_graphics, 0, 0, 51, 46,
255, 0, 255,
"enemies.bmp", 600,
-50, m_maxSpeed));
}