initial commit

This commit is contained in:
rich
2025-01-13 11:01:14 -05:00
parent 5526e76476
commit 5588eaa74d

57
main.cpp Normal file
View File

@@ -0,0 +1,57 @@
// ReWalker
// A random walker that moves around the screen
// Written using Redacted ReWindow https://git.redacted.cc/Redacted/ReWindow
// Written by Rich
// With help from (and thanks to) from Maxine, Josh and Bill
#include <rewindow/types/window.h>
#include <rewindow/logger/logger.h>
#include <GL/gl.h>
// define window size and dot size (dot size should be odd)
#define WIDTH 800
#define HEIGHT 600
#define DOT_SIZE 5
struct Walker {
float x, y;
Walker() : x(WIDTH / 2.0f), y(HEIGHT / 2.0f) {}
void step() {
float angle = static_cast<float>(rand()) / RAND_MAX * 360.0f;
angle = angle * M_PI / 180.0f;
float dx = std::cos(angle);
float dy = std::sin(angle);
x = std::clamp(x + dx, 0.0f, static_cast<float>(WIDTH - 1));
y = std::clamp(y + dy, 0.0f, static_cast<float>(HEIGHT - 1));
}
};
class RandomWalkerWindow : public ReWindow::RWindow {
public:
RandomWalkerWindow(const std::string& title, int width, int height)
: ReWindow::RWindow(title, width, height) {}
void OnRefresh(float elapsed) override {
glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // Clear with white
glClear(GL_COLOR_BUFFER_BIT);
GLSwapBuffers();
}
};
int main() {
std::unique_ptr<RandomWalkerWindow> window =
std::make_unique<RandomWalkerWindow>("Random Walker with ReWindow", WIDTH, HEIGHT);
window->SetRenderer(RenderingAPI::OPENGL);
window->Open();
while (!window->IsClosing()) {
window->ManagedRefresh();
}
return 0;
}