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));
}