Hi gamedev,
I have been bored on the programming lessons recently, so
i decided to make a bullet hell in c++ with sdl2.
The problem is, I don't know how to structure the code
so that it would work properly. Problems such as how to
control the bullets, how to spawn a enemy at the right time
needs to be solved.
Here is what i have come up with so far (psudoish);
class player
{
SDL_Texture * P_Texture;
SDL_Texture * Col_texture;
double mx; //x,y movement
double my;
SDL_Rect P_pos;
int hp;
int power;
int points;
void loop(double delta_time);
void render(SDL_Renderer * renderer);
};
class Enemy
{
int type;
SDL_Texture * texture;
int helth;
SDL_Rect pos;
SDL_Rect col;
void loop();
void render(SDL_Renderer * renderer);
};
struct Bullet
{
int type;
SDL_Texture * texture;
float rotation;
int helth;
SDL_Rect pos;
SDL_Rect col;
void render(SDL_Renderer * renderer);
void loop(double delta_time);
};
class game
{
player Player;
std::vector<Enemy> enemies;
std::vector<Bullet> bullets;
void even(SDL_Event * event)
{
// Handle events and
// Pass on events to underlaying code
}
void render(SDL_Renderer * renderer)
{
//Render
}
void loop()
{
/*
Update positions
Handle collisions
*/
}
};
So where do I go from here? I would like to be able to control the bullets
using different equations and spawn allot of them. The game doesn't have
to be advanced at all just spawn a bunch of enemies and bullets flying
in different directions.
Thanks for any help and sorry for my bad English