finish title screen, fix game logic, add textures, somehow forgot the T tetromino lol

This commit is contained in:
Rene Kievits
2024-10-14 22:45:46 +02:00
parent 190f81176d
commit 24c8c3fe2c
25 changed files with 399 additions and 79 deletions

View File

@@ -12,6 +12,24 @@ extern "C" {
#include "GameBoard.hpp"
enum class TetrisAssets {
BORDER,
SINGLE,
I,
I_MID,
I_START,
I_END,
I_MIDR,
I_STARTR,
I_ENDR,
J,
L,
O,
S,
Z,
T,
};
class Renderer {
private:
void drawGrid(const GameBoard& gameBoard);
@@ -19,19 +37,34 @@ private:
void drawTetromino(const Tetromino& tetromino);
void drawScoreboard(int score, int level);
shared_ptr<SDL_Renderer> renderer;
int blockSize;
TetrisAssets shapeToAsset(const TetrominoShape shape);
unordered_map<TetrominoShape, SDL_Texture*> textures;
shared_ptr<SDL_Renderer> renderer;
int blockSize;
int offsetX;
int offsetY;
int screenSpacing = 50;
int windowHeight = 0;
int windowWidth = 0;
unordered_map<TetrisAssets, SDL_Texture*> textures;
public:
Renderer(shared_ptr<SDL_Renderer> renderer);
Renderer(shared_ptr<SDL_Renderer> renderer, int w, int h);
void setRenderer(shared_ptr<SDL_Renderer> renderer);
void renderBoard(const GameBoard& gb);
bool loadTexture(const string& filePath, const TetrominoShape shape);
void renderTexture(const TetrominoShape shape, int x, int y, int width, int height);
bool loadTexture(const string& filePath, const TetrisAssets shape);
void renderTexture(const TetrisAssets shape, int x, int y, int width, int height);
void renderStartScreen( );
void renderGameOver(int score, int level);
void renderText(string text, int x, int y, int size, SDL_Color color);
const int getBlockSize( ) const;
void setBlockSize(int newBlockSize);
void setOffset(int newX, int newY);
const int getOffsetX( ) const;
const int getOffsetY( ) const;
void setWindowSize(int w, int h);
};