render klotski board

This commit is contained in:
2026-02-17 13:27:12 +01:00
parent 017d11245c
commit 9d0afffb57
4 changed files with 101 additions and 11 deletions

View File

@ -7,8 +7,8 @@ constexpr int WIDTH = 800;
constexpr int HEIGHT = 800;
constexpr float VERTEX_SIZE = 50.0;
constexpr Color VERTEX_COLOR = {27, 188, 104, 255};
constexpr Color EDGE_COLOR = {20, 133, 38, 255};
constexpr Color VERTEX_COLOR = GREEN;
constexpr Color EDGE_COLOR = DARKGREEN;
constexpr float SIM_SPEED = 4.0;
constexpr float ROTATION_SPEED = 1.0;
@ -18,4 +18,7 @@ constexpr float DEFAULT_SPRING_CONSTANT = 1.5;
constexpr float DEFAULT_DAMPENING_CONSTANT = 0.1;
constexpr float DEFAULT_REST_LENGTH = 0.5;
constexpr int BOARD_PADDING = 5;
constexpr int BLOCK_PADDING = 5;
#endif

View File

@ -6,6 +6,7 @@
#include <raymath.h>
#include <vector>
#include "klotski.hpp"
#include "mass_springs.hpp"
using Edge3Set = std::vector<std::pair<Vector3, Vector3>>;
@ -19,10 +20,12 @@ private:
int width;
int height;
RenderTexture2D render_target;
RenderTexture2D klotski_target;
public:
Renderer(int width, int height) : width(width), height(height) {
render_target = LoadRenderTexture(width, height);
klotski_target = LoadRenderTexture(width, height);
}
Renderer(const Renderer &copy) = delete;
@ -30,7 +33,10 @@ public:
Renderer(Renderer &&move) = delete;
Renderer &operator=(Renderer &&move) = delete;
~Renderer() { UnloadRenderTexture(render_target); }
~Renderer() {
UnloadRenderTexture(render_target);
UnloadRenderTexture(klotski_target);
}
private:
auto Rotate(const Vector3 &a, const float cos_angle, const float sin_angle)
@ -49,6 +55,10 @@ public:
auto DrawMassSprings(const Edge2Set &edges, const Vertex2Set &vertices)
-> void;
auto DrawKlotski(State &state) -> void;
auto DrawTextures() -> void;
};
#endif