43 lines
1.5 KiB
C++
43 lines
1.5 KiB
C++
#pragma once
|
|
#include <SDL3/SDL.h>
|
|
#include "../../gameplay/core/Game.h"
|
|
|
|
// Forward declarations
|
|
class FontAtlas;
|
|
class LineEffect;
|
|
|
|
/**
|
|
* GameRenderer - Utility class for rendering the Tetris game board and HUD.
|
|
*
|
|
* This class encapsulates all the game-specific rendering logic that was
|
|
* previously in main.cpp, making it reusable across different contexts.
|
|
*/
|
|
class GameRenderer {
|
|
public:
|
|
// Render the complete playing state including game board, HUD, and effects
|
|
static void renderPlayingState(
|
|
SDL_Renderer* renderer,
|
|
Game* game,
|
|
FontAtlas* pixelFont,
|
|
LineEffect* lineEffect,
|
|
SDL_Texture* blocksTex,
|
|
float logicalW,
|
|
float logicalH,
|
|
float logicalScale,
|
|
float winW,
|
|
float winH,
|
|
bool showExitConfirmPopup,
|
|
int exitPopupSelectedButton = 1, // 0=YES, 1=NO
|
|
bool suppressPauseVisuals = false
|
|
);
|
|
|
|
private:
|
|
// Helper functions for drawing game elements
|
|
static void drawBlockTexture(SDL_Renderer* renderer, SDL_Texture* blocksTex, float x, float y, float size, int blockType);
|
|
static void drawPiece(SDL_Renderer* renderer, SDL_Texture* blocksTex, const Game::Piece& piece, float ox, float oy, float tileSize, bool isGhost = false);
|
|
static void drawSmallPiece(SDL_Renderer* renderer, SDL_Texture* blocksTex, PieceType pieceType, float x, float y, float tileSize);
|
|
|
|
// Helper function for drawing rectangles
|
|
static void drawRect(SDL_Renderer* renderer, float x, float y, float w, float h, SDL_Color c);
|
|
};
|