From 55a1f6917e6ada6557c76f7f513452950ab47a98 Mon Sep 17 00:00:00 2001 From: bossy Date: Fri, 3 Jul 2026 20:17:31 +0300 Subject: [PATCH] add towers --- .gitignore | 2 ++ Makefile | 2 +- src/main.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 567609b..902f3c7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ build/ +.cache/ +compile_commands.json diff --git a/Makefile b/Makefile index a57b9f5..fc4c862 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -build/game: +build/game: src/* mkdir -p build gcc -o build/game src/* \ -I./raylib-6.0_linux_amd64/include \ diff --git a/src/main.c b/src/main.c index 0064a55..34fbf6b 100644 --- a/src/main.c +++ b/src/main.c @@ -1,15 +1,56 @@ #include "raylib.h" +static void DrawLevel() +{ + const Vector3 towerSize = (Vector3){ 16.0f, 32.0f, 16.0f }; + + Vector3 towerPos = (Vector3){ 16.0f, 16.0f, 16.0f }; + DrawCubeV(towerPos, towerSize, RED); + DrawCubeWiresV(towerPos, towerSize, BLACK); + + towerPos.x *= -1; + DrawCubeV(towerPos, towerSize, RED); + DrawCubeWiresV(towerPos, towerSize, BLACK); + + towerPos.z *= -1; + DrawCubeV(towerPos, towerSize, RED); + DrawCubeWiresV(towerPos, towerSize, BLACK); + + towerPos.x *= -1; + DrawCubeV(towerPos, towerSize, RED); + DrawCubeWiresV(towerPos, towerSize, BLACK); +} + int main() { InitWindow(800, 600, "Super cool game"); SetTargetFPS(60); + Camera3D camera = { 0 }; + camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; + camera.target = (Vector3){ 0.0f, 12.0f, 0.0f }; + camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; + camera.fovy = 60.0f; + camera.projection = CAMERA_PERSPECTIVE; + while (!WindowShouldClose()) { + UpdateCamera(&camera, CAMERA_FREE); + DisableCursor(); + if(IsKeyPressed(KEY_Z)) camera.target = (Vector3){0.0f, 0.0f, 0.0f}; + BeginDrawing(); - ClearBackground(RED); + ClearBackground(RAYWHITE); + + BeginMode3D(camera); + DrawGrid(20, 10.0f); + DrawLevel(); + EndMode3D(); + + DrawFPS(10, 10); + EndDrawing(); } CloseWindow(); + return 0; }