diff options
| author | ilotterytea <iltsu@alright.party> | 2024-12-11 11:50:06 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-12-11 11:50:06 +0500 |
| commit | 80c74c80615693cf4b8a5090121dad8d14ccfb0f (patch) | |
| tree | 35eded3126e68e182b51314ed80407da099352e5 /src/main.c | |
| parent | cbeb0314a90edb5ce28df2a8892160c0023320cb (diff) | |
feat: mouse can control the world view
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -5,6 +5,7 @@ #include "time.h" int main(int argc, char *argv[]) { + bool mouse_control = false; srand(time(0)); InitWindow(800, 600, "hyperspace (demo)"); @@ -31,13 +32,27 @@ int main(int argc, char *argv[]) { star->position = Generate3DPosition(); } - StarUpdate(star); + float screen_center_x = + mouse_control ? GetMouseX() : GetScreenWidth() / 2.0; + float screen_center_y = + mouse_control ? GetMouseY() : GetScreenHeight() / 2.0; + + StarUpdate(star, screen_center_x, screen_center_y); DrawRectangle(star->renderPosition.x, star->renderPosition.y, star->size.x, star->size.y, star->color); } EndDrawing(); + + // Listening for input + if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) { + mouse_control = !mouse_control; + if (mouse_control) + HideCursor(); + else + ShowCursor(); + } } return 0; |
