R
Hast du mal eine KI deines Vertrauen gefragt, sie soll dir bitte ein Boilerplate-Skeleton schreiben? Ich glaube, damit kämst du schneller zum Ziel und gleichzeitig kann sie dir auch alles erklären... Beispielweise:
// main.cpp
#include <raylib.h>
int main()
{
const int WindowWidth = 750;
const int WindowHeight = 750;
const int FPS = 60;
InitWindow(WindowWidth, WindowHeight, "raylib C++ Boilerplate");
SetTargetFPS(FPS);
// Beispiel-State
Vector2 pos = { WindowWidth / 2.0f, WindowHeight / 2.0f };
Vector2 vel = { 250.0f, 180.0f }; // Pixel pro Sekunde
const float radius = 30.0f;
while (!WindowShouldClose())
{
// 1) Event Handling (hier nur Eingaben)
if (IsKeyPressed(KEY_SPACE))
{
// simple Demo: Geschwindigkeit invertieren
vel.x *= -1.0f;
vel.y *= -1.0f;
}
// 2) Updating State
float dt = GetFrameTime(); // Sekunden seit letztem Frame
pos.x += vel.x * dt;
pos.y += vel.y * dt;
// Bounce an den Rändern
if (pos.x - radius <= 0) { pos.x = radius; vel.x *= -1.0f; }
if (pos.x + radius >= WindowWidth) { pos.x = WindowWidth - radius; vel.x *= -1.0f; }
if (pos.y - radius <= 0) { pos.y = radius; vel.y *= -1.0f; }
if (pos.y + radius >= WindowHeight) { pos.y = WindowHeight - radius; vel.y *= -1.0f; }
// 3) Drawing
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Raylib Boilerplate", 10, 10, 20, DARKGRAY);
DrawCircleV(pos, radius, RED);
EndDrawing();
}
CloseWindow();
return 0;
}
Beispielsweise sieht deine while Bedingung noch verdächtig aus und es wird ja auch gar nichts gezeichnet...
Womit übersetzt du es?