2017-12-26 23:24:29 +01:00
|
|
|
#ifndef __asteroids_h__
|
|
|
|
#define __asteroids_h__
|
|
|
|
|
|
|
|
#include "vector.h"
|
|
|
|
|
|
|
|
// Enums
|
|
|
|
typedef enum bullettype { AllyBullet = 0, EnemyBullet = 1 } BulletType;
|
|
|
|
// End Enums
|
|
|
|
|
|
|
|
// Structs
|
|
|
|
typedef struct bulletStruct {
|
|
|
|
double Rotation;
|
|
|
|
Vector Location, Momentum;
|
|
|
|
SDL_Rect TargetRect;
|
|
|
|
int Lifetime;
|
|
|
|
bool IsDestroyed;
|
|
|
|
BulletType Type;
|
|
|
|
} Bullet;
|
|
|
|
|
|
|
|
typedef struct enemyStruct {
|
|
|
|
bool IsDead;
|
|
|
|
Vector Location, Momentum;
|
|
|
|
SDL_Rect TargetRect;
|
|
|
|
int WeaponCooldown, lastBulletIndex, DeadTime, TurnCooldown;
|
|
|
|
Bullet * Bullets;
|
|
|
|
} Enemy;
|
|
|
|
|
2017-12-27 00:57:22 +01:00
|
|
|
typedef struct shipStruct {
|
2017-12-26 23:24:29 +01:00
|
|
|
bool TurnRightButtonPressed, TurnLeftButtonPressed, ForwardButtonPressed, ShootButtonPressed, IsDead;
|
|
|
|
double Rotation;
|
|
|
|
Vector FacingDirection, Location, Momentum;
|
|
|
|
SDL_Rect TargetRect_Gliding, TargetRect_Accelerating, TargetRect_Explosion;
|
|
|
|
int WeaponCooldown, lastBulletIndex, DeadTime;
|
|
|
|
Bullet * Bullets;
|
|
|
|
} Ship;
|
|
|
|
|
|
|
|
typedef struct asteroidStruct {
|
|
|
|
double Rotation, Size, RotationValue;
|
|
|
|
Vector Location, Momentum;
|
|
|
|
SDL_Rect TargetRect, SourceRect;
|
|
|
|
bool IsDestroyed;
|
|
|
|
int Health;
|
|
|
|
} Asteroid;
|
|
|
|
// End Structs
|
|
|
|
|
|
|
|
// Prototypes
|
2017-12-27 22:01:59 +01:00
|
|
|
void ASTEROIDS_InitializeGame(SDL_Renderer * renderer, int width, int height);
|
|
|
|
void ASTEROIDS_DeinitializeGame();
|
|
|
|
void BULLET_Initialize(SDL_Renderer * renderer);
|
2017-12-26 23:24:29 +01:00
|
|
|
void BULLET_Deinitialize();
|
|
|
|
Bullet BULLET_Fire(Vector location, double direction, BulletType type);
|
2017-12-28 22:17:04 +01:00
|
|
|
void BULLET_UpdateAlly(Bullet * bul, Asteroid * asts, int * astCount, Enemy * enemies, int * enemyCount);
|
|
|
|
void BULLET_UpdateEnemy(Bullet * bul, Ship * shp, int * shpCount);
|
|
|
|
void BULLET_Draw(Bullet * bul, SDL_Renderer * renderer);
|
|
|
|
void ASTEROID_Initialize(SDL_Renderer * renderer);
|
2017-12-26 23:24:29 +01:00
|
|
|
Asteroid ASTEROID_CreateRandom();
|
|
|
|
bool ASTEROID_TryDestroy(Asteroid * asts, int * astCount, int index);
|
|
|
|
Asteroid ASTEROID_CreateFromSplit(Asteroid * creator);
|
|
|
|
bool ASTEROID_CanSplit(Asteroid * ast);
|
|
|
|
bool RECT_CircleCollide(SDL_Rect * rect1, SDL_Rect * rect2);
|
|
|
|
double distance(SDL_Rect * r1, SDL_Rect * r2);
|
2017-12-28 22:17:04 +01:00
|
|
|
void ASTEROID_Deinitialize();
|
2017-12-26 23:24:29 +01:00
|
|
|
void ASTEROID_Update(Asteroid * ast);
|
|
|
|
void ASTEROID_Draw(Asteroid * ast, SDL_Renderer * renderer);
|
2017-12-28 22:17:04 +01:00
|
|
|
void ENEMY_Initialize(SDL_Renderer * renderer);
|
2017-12-26 23:24:29 +01:00
|
|
|
Enemy ENEMY_GetDefault();
|
2017-12-28 22:17:04 +01:00
|
|
|
void ENEMY_Deinitialize();
|
2017-12-26 23:24:29 +01:00
|
|
|
void ENEMY_DestroyObject(Enemy * enm);
|
|
|
|
void ENEMY_Update(Enemy * enm, Ship * targets, int targetCount);
|
|
|
|
void ENEMY_Draw(Enemy * enm, SDL_Renderer * renderer);
|
2017-12-28 22:17:04 +01:00
|
|
|
void SHIP_Initialize(SDL_Renderer * renderer);
|
2017-12-26 23:24:29 +01:00
|
|
|
Ship SHIP_CreateDefault();
|
2017-12-28 22:17:04 +01:00
|
|
|
void SHIP_Deinitialize();
|
2017-12-26 23:24:29 +01:00
|
|
|
void SHIP_DestroyObject(Ship * shp);
|
|
|
|
void SHIP_Update(Ship * shp, Uint8 * keystate, Asteroid * asts, int * astCount, Enemy * enemies, int * enemyCount);
|
|
|
|
void SHIP_Draw(Ship * shp, SDL_Renderer * renderer);
|
|
|
|
// End Prototypes
|
|
|
|
|
|
|
|
#endif // __asteroids_h__
|