2025-06-16 03:14:07 +01:00

50 lines
1.6 KiB
C++

#ifndef RENDER_HPP
#define RENDER_HPP
// Include necessary headers
#include "assets.hpp"
#include "input.hpp"
#include <SDL3/SDL.h>
// Structs
struct Color {
Uint8 r;
Uint8 g;
Uint8 b;
Uint8 a;
Color(Uint8 r = 0, Uint8 g = 0, Uint8 b = 0, Uint8 a = 255) : r(r), g(g), b(b), a(a) {}
};
// Classes
class Engine {
public:
Engine(const char* windowTitle, int windowWidth, int windowHeight, int windowFlags);
Engine(const char* windowTitle, int windowWidth, int windowHeight)
: Engine(windowTitle, windowWidth, windowHeight, 0) {}
~Engine();
void targetFPS(int fps);
void startFrame();
void clearScreen(const Color& color);
void draw(SDL_Surface* surface, Rect destRect);
void draw(SDL_Surface* surface, Rect srcRect, Rect destRect);
void draw(Tile tile, Rect destRect);
void draw(SDL_Surface* surface, Vector2 pos) { draw(surface, Rect(pos.x, pos.y, surface->w, surface->h)); }
void draw(SDL_Surface* surface, Rect srcRect, Vector2 pos) { draw(surface, srcRect, Rect(pos.x, pos.y, srcRect.width, srcRect.height)); }
void draw(Tile tile, Vector2 pos) { draw(tile, Rect(pos.x, pos.y, tile.srcRect.width, tile.srcRect.height)); }
void present();
Input input; // Input handler
AssetManager assets; // Asset manager
private:
SDL_Window* window;
SDL_Renderer* renderer;
int targetFPSValue = 60; // Target frames per second
Uint64 frameStartTime = 0; // Start time of the current frame
Uint64 frameEndTime = 0; // End time of the current frame
Uint64 frameDuration = 0; // Duration of the current frame in milliseconds
};
#endif