2018-01-09 13:22:10 +01:00
|
|
|
#ifndef __breakout_h__
|
|
|
|
#define __breakout_h__
|
2018-01-11 01:06:55 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <SDL2/SDL.h>
|
2018-01-09 13:22:10 +01:00
|
|
|
|
|
|
|
#include "vector.h"
|
|
|
|
|
2018-01-18 11:45:19 +01:00
|
|
|
// Enums
|
|
|
|
typedef enum controlModeEnum {KeyboardControl = 0, MouseControl = 1} ControlMode;
|
|
|
|
// End Enums
|
|
|
|
|
2018-01-09 13:22:10 +01:00
|
|
|
// Structs
|
|
|
|
typedef struct ballStruct {
|
|
|
|
Vector Location, Momentum;
|
|
|
|
SDL_Rect TargetRect;
|
2018-01-10 22:49:37 +01:00
|
|
|
double Size, Rotation, RotationValue;
|
|
|
|
int TextureIndex;
|
2018-01-15 22:01:58 +01:00
|
|
|
double Speed;
|
2018-01-10 22:49:37 +01:00
|
|
|
} Ball; // Objekt für die Eigenschaften des Balls
|
2018-01-09 13:22:10 +01:00
|
|
|
|
|
|
|
typedef struct paddleStruct {
|
|
|
|
SDL_Rect TargetRect;
|
2018-01-11 01:06:55 +01:00
|
|
|
int TextureIndex;
|
2018-01-15 22:01:58 +01:00
|
|
|
int Speed;
|
|
|
|
double SteeringAngle;
|
2018-01-18 11:45:19 +01:00
|
|
|
ControlMode Mode;
|
2018-01-10 22:49:37 +01:00
|
|
|
} Paddle; // Objekt für die Eigenschaften des Paddles
|
2018-01-09 13:22:10 +01:00
|
|
|
|
|
|
|
typedef struct blockStruct {
|
|
|
|
SDL_Rect TargetRect;
|
2018-01-12 16:49:17 +01:00
|
|
|
int TextureIndex, HP;
|
2018-01-10 22:49:37 +01:00
|
|
|
} Block; // Objekt für die Eigenschaften des Paddles
|
2018-01-15 22:01:58 +01:00
|
|
|
|
|
|
|
typedef struct sceneryStruct {
|
|
|
|
Ball ball;
|
|
|
|
Paddle paddle;
|
|
|
|
Block * blocks;
|
|
|
|
int BlockCount; // Move to scenery
|
|
|
|
} Scenery; // Objekt für die Objekte und Eigenschaften einer Szenerie
|
2018-01-09 13:22:10 +01:00
|
|
|
// End Structs
|
|
|
|
|
|
|
|
// Prototypes
|
2018-01-10 15:37:55 +01:00
|
|
|
void BREAKOUT_INITIALIZE(SDL_Renderer * renderer, int width, int height);
|
2018-01-15 22:01:58 +01:00
|
|
|
Scenery BREAKOUT_CreateDefault();
|
2018-01-11 18:45:00 +01:00
|
|
|
void BREAKOUT_ChangeSize(int width, int height);
|
2018-01-15 22:01:58 +01:00
|
|
|
void BREAKOUT_Update(Scenery * scenery, const Uint8 * keystate);
|
|
|
|
void BREAKOUT_Draw(Scenery * scenery, SDL_Renderer * renderer);
|
2018-01-10 23:40:17 +01:00
|
|
|
void BREAKOUT_DEINITIALIZE();
|
2018-01-15 22:01:58 +01:00
|
|
|
void BREAKOUT_DestroyObject(Scenery * scenery);
|
2018-01-10 23:40:17 +01:00
|
|
|
void BALL_Initialize(SDL_Renderer * renderer);
|
|
|
|
Ball BALL_CreateDefault();
|
|
|
|
void BALL_Draw(SDL_Renderer * renderer, Ball * obj);
|
2018-01-11 16:47:40 +01:00
|
|
|
bool BALL_CollideWithRect(Ball * obj, SDL_Rect * rect);
|
2018-01-11 14:12:30 +01:00
|
|
|
bool RECT_Collide(SDL_Rect * rect1, SDL_Rect * rect2);
|
2018-01-12 10:47:14 +01:00
|
|
|
void BALL_SteerMomentum(Ball * obj, Paddle * paddle);
|
2018-01-12 14:04:44 +01:00
|
|
|
void RECT_SetTargetPos(SDL_Rect * rect, Vector * Location);
|
|
|
|
SDL_Point BALL_GetCenter(Ball * obj);
|
2018-01-15 22:01:58 +01:00
|
|
|
void BALL_Update(Ball * obj, Paddle * paddle, Block * blocks, int BlockCount);
|
2018-01-10 23:40:17 +01:00
|
|
|
void BALL_DestroyObject(Ball * obj);
|
|
|
|
void BALL_Deinitialize();
|
2018-01-11 01:06:55 +01:00
|
|
|
void PADDLE_Initialize(SDL_Renderer * renderer);
|
|
|
|
Paddle PADDLE_CreateDefault();
|
|
|
|
void PADDLE_Draw(SDL_Renderer * renderer, Paddle * obj);
|
2018-01-15 22:01:58 +01:00
|
|
|
bool KeyPressed(const Uint8 * keystate, Uint8 * keyArray);
|
|
|
|
void INT_Constrain(int * variable, int min, int max);
|
|
|
|
void DOUBLE_Constrain(double * variable, double min, double max);
|
|
|
|
void PADDLE_Update(Paddle * obj, const Uint8 * keystate);
|
2018-01-11 01:06:55 +01:00
|
|
|
void PADDLE_DestroyObject(Paddle * obj);
|
|
|
|
void PADDLE_Deinitialize();
|
2018-01-12 10:47:14 +01:00
|
|
|
void BLOCK_Initialize(SDL_Renderer * renderer);
|
|
|
|
Block BLOCK_CreateDefault() ;
|
|
|
|
void BLOCK_Draw(SDL_Renderer * renderer, Block * obj);
|
2018-01-12 16:49:17 +01:00
|
|
|
void BLOCK_DealDamage(Block * obj, int dmg);
|
2018-01-12 10:47:14 +01:00
|
|
|
void BLOCK_Update(Block * obj);
|
|
|
|
void BLOCK_DestroyObject(Block * obj);
|
|
|
|
void BLOCK_Deinitialize();
|
2018-01-09 13:22:10 +01:00
|
|
|
// End Prototypes
|
|
|
|
|
|
|
|
#endif // __breakout_h__
|