some problems fixed
This commit is contained in:
40
src/graphics/GameRenderer.h
Normal file
40
src/graphics/GameRenderer.h
Normal file
@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
#include <SDL3/SDL.h>
|
||||
#include "../gameplay/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
|
||||
);
|
||||
|
||||
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);
|
||||
};
|
||||
Reference in New Issue
Block a user