Pong/src/Game.h

42 lines
830 B
C
Raw Normal View History

2024-01-29 19:18:38 +01:00
// SPDX-License-Identifier: BSD-2-Clause
2024-01-19 15:06:48 +01:00
#pragma
#include "SdlWrapper.h"
#include "SDL.h"
#include "VisibleObjects/Ball.h"
#include "VisibleObjects/PlayerPaddle.h"
#include "text/Score.h"
#include "text/TextScreen.h"
#include "text/OptionScreen.h"
#include "text/Score.h"
2024-01-29 19:06:02 +01:00
#include "text/ScrollOptionScreen.h"
2024-01-19 15:06:48 +01:00
2024-01-28 21:07:18 +01:00
enum class GameState {
START_SCREEN, GAME, END_SCREEN
};
2024-01-19 15:06:48 +01:00
class Game : public SdlWrapper {
private:
2024-01-19 18:41:26 +01:00
Score *score;
2024-01-19 15:06:48 +01:00
PlayerPaddle *leftPaddle, *rightPaddle;
2024-01-29 19:06:02 +01:00
OptionScreen *endScreen;
ScrollOptionScreen *startScreen;
2024-01-29 12:30:00 +01:00
Ball *ball;
2024-01-19 15:06:48 +01:00
2024-01-28 21:07:18 +01:00
protected:
GameState gameState;
2024-01-19 15:06:48 +01:00
public:
explicit Game(SDL_Point screenSize);
2024-01-19 15:06:48 +01:00
~Game() override;
2024-01-19 15:06:48 +01:00
void draw(SDL_Renderer *renderer) override;
2024-01-19 15:06:48 +01:00
void update() override;
2024-01-28 21:07:18 +01:00
bool handleEvents() override;
2024-01-19 15:06:48 +01:00
void handleGameEvent(SDL_Event &event);
2024-01-19 15:06:48 +01:00
};