breakout/breakout.h

101 lines
3.7 KiB
C
Raw Permalink Normal View History

#ifndef __breakout_h__
#define __breakout_h__
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <time.h>
#include <SDL2/SDL.h>
#include "vector.h"
2018-01-18 11:45:19 +01:00
// Enums
typedef enum controlModeEnum {KeyboardControl = 0, MouseControl = 1} ControlMode;
// End Enums
// Structs
typedef struct ballStruct {
Vector Location, Momentum;
SDL_Rect TargetRect;
double Size, Rotation, RotationValue;
int TextureIndex;
2018-01-15 22:01:58 +01:00
double Speed;
} Ball; // Objekt für die Eigenschaften des Balls
typedef struct paddleStruct {
SDL_Rect TargetRect;
int TextureIndex;
2018-01-15 22:01:58 +01:00
int Speed;
double SteeringAngle;
2018-01-18 11:45:19 +01:00
ControlMode Mode;
} Paddle; // Objekt für die Eigenschaften des Paddles
typedef struct blockStruct {
SDL_Rect TargetRect;
2018-01-12 16:49:17 +01:00
int TextureIndex, HP;
} 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;
2018-01-23 11:08:15 +01:00
int BlockCount, Lives, StartCountdown, Frames, Score, DestroyedBlocks;
2018-01-21 15:33:09 +01:00
bool IsPaused, IsGameOver;
2018-01-15 22:01:58 +01:00
} Scenery; // Objekt für die Objekte und Eigenschaften einer Szenerie
// End Structs
// Prototypes
void BREAKOUT_INITIALIZE(SDL_Renderer * renderer);
void BREAKOUT_TogglePause(Scenery * scenery);
void BREAKOUT_KeyPressed(Scenery * scenery, SDL_KeyboardEvent * b);
2018-01-15 22:01:58 +01:00
Scenery BREAKOUT_CreateDefault();
void BREAKOUT_IncreaseScoreBy(Scenery * scenery, int scoreInc);
void TEXTURE_RenderCenteredSpriteSheet(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Rect * srcRect, float Scale);
void TEXTURE_RenderCentered(SDL_Renderer * renderer, SDL_Texture * texture, float Scale);
2018-01-15 22:01:58 +01:00
void BREAKOUT_Update(Scenery * scenery, const Uint8 * keystate);
void BREAKOUT_Draw(Scenery * scenery, SDL_Renderer * renderer);
void BREAKOUT_DrawLivesHUD(SDL_Renderer * renderer, Scenery * scenery);
void BREAKOUT_DEINITIALIZE();
2018-01-15 22:01:58 +01:00
void BREAKOUT_DestroyObject(Scenery * scenery);
void BALL_Initialize(SDL_Renderer * renderer);
Ball BALL_CreateDefault();
2018-01-21 15:33:09 +01:00
void BALL_ResetPosition(Ball * obj);
void BALL_DrawTexture(SDL_Renderer * renderer, SDL_Rect * dstRect, int index);
void BALL_Draw(SDL_Renderer * renderer, Ball * obj);
2018-01-11 16:47:40 +01:00
bool BALL_CollideWithRect(Ball * obj, SDL_Rect * rect);
bool RECT_Collide(SDL_Rect * rect1, SDL_Rect * rect2);
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);
void BALL_CollideWithBorders(Ball * obj);
void BALL_MoveAwayFromBoundaries(Ball * obj);
bool BALL_CollideWithPaddle(Ball * obj, Paddle * paddle);
2018-01-23 11:08:15 +01:00
void BALL_AdaptSpeedGradient(Ball * obj, int FrameCount);
2018-01-21 15:33:09 +01:00
void BALL_Update(Ball * obj, Scenery * scenery);
void BALL_DestroyObject(Ball * obj);
void BALL_Deinitialize();
void PADDLE_Initialize(SDL_Renderer * renderer);
Paddle PADDLE_CreateDefault();
2018-01-21 15:33:09 +01:00
void PADDLE_ResetPosition(Paddle * obj);
void PADDLE_DrawTexture(SDL_Renderer * renderer, SDL_Rect * dstRect, int index);
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);
2018-01-23 11:08:15 +01:00
void PADDLE_MoveSmooth(Paddle * obj);
void PADDLE_AdaptSpeedGradient(Paddle * obj, int FrameCount);
void PADDLE_Update(Paddle * obj, Scenery * scenery, const Uint8 * keystate);
void PADDLE_DestroyObject(Paddle * obj);
void PADDLE_Deinitialize();
void BLOCK_Initialize(SDL_Renderer * renderer);
Block BLOCK_CreateDefault() ;
void BLOCK_DrawTexture(SDL_Renderer * renderer, SDL_Rect * dstRect, int index);
void BLOCK_Draw(SDL_Renderer * renderer, Block * obj);
2018-01-12 16:49:17 +01:00
void BLOCK_DealDamage(Block * obj, int dmg);
void BLOCK_Update(Block * obj);
void BLOCK_DestroyObject(Block * obj);
void BLOCK_Deinitialize();
// End Prototypes
#endif // __breakout_h__