asteroids/asteroids.h

80 lines
2.7 KiB
C

#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;
typedef struct shipStruct {
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
void ASTEROIDS_InitializeGame(SDL_Renderer * renderer, int width, int height);
void ASTEROIDS_DeinitializeGame();
void BULLET_Initialize(SDL_Renderer * renderer);
void BULLET_Deinitialize();
Bullet BULLET_Fire(Vector location, double direction, BulletType type);
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);
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);
void ASTEROID_Deinitialize();
void ASTEROID_Update(Asteroid * ast);
void ASTEROID_Draw(Asteroid * ast, SDL_Renderer * renderer);
void ENEMY_Initialize(SDL_Renderer * renderer);
Enemy ENEMY_GetDefault();
void ENEMY_Deinitialize();
void ENEMY_DestroyObject(Enemy * enm);
void ENEMY_Update(Enemy * enm, Ship * targets, int targetCount);
void ENEMY_Draw(Enemy * enm, SDL_Renderer * renderer);
void SHIP_Initialize(SDL_Renderer * renderer);
Ship SHIP_CreateDefault();
void SHIP_Deinitialize();
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__