RayLib für Einsteiger
-
Hallo zusammen!
Ich bin Quer.- bzw. Neueinsteiger.
Ich wollt e mich mal an der "ralib.h" versuchen und scheitere schon beim ersten Anlauf.
#include <raylib.h> int main() { const int Window_Width = 750; const int Window_Height = 750; const int FPS = 12; InitWindow(Window_Width, Window_Height, "RayLib Test"); SetTargetFPS(FPS); // Simulation Loop while (WindowShouldClose()==false) { // 1. Event Handling // 2. Updating State // 3. Drawing BeginDrawing(); EndDrawing(); } CloseWindow(); }
Stattdessen dreht sich der Maus-Cursor (früher war das 'ne Sanduhr).Danke im voraus
Micha
-
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?