From 474cb11d0cd7b64247b99e95bfb8f29a48eac369 Mon Sep 17 00:00:00 2001 From: Nefrace Date: Sun, 7 Apr 2024 22:12:13 +0300 Subject: [PATCH] Init 2 --- .gitignore | 1 + assets/ship.png | Bin 0 -> 574 bytes ols.json | 20 ++++++++++++++++++++ src/main.odin | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 .gitignore create mode 100644 assets/ship.png create mode 100644 ols.json create mode 100644 src/main.odin diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e9669d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +src.bin diff --git a/assets/ship.png b/assets/ship.png new file mode 100644 index 0000000000000000000000000000000000000000..688c1ff1e61392a25fcb93009eaceb57c0c6fac5 GIT binary patch literal 574 zcmV-E0>S->P) z;=`qN(#*!z+hZPwn3&B`0TU^XP%Y;}Ipd>Hl+Pi>NxHfV=f%hKZ8?c>zuU0%f$7@BI6?z#6AtVJ~jF$l- zUA)25AVhjQnI1Q9J=PTxO#+^@#xJozSp!*8(5Mcanw>?*26EYL0DGa&* zJ7>%6tvyu@aL3Kobhp=|>4*X(!s#eSKSguFJSE7foe0$c5#zazhnHDcr2`18_4eW8 z zr`iFHn0JLXD799`h<6D}Zf^q!Px# M07*qoM6N<$g7HiEZU6uP literal 0 HcmV?d00001 diff --git a/ols.json b/ols.json new file mode 100644 index 0000000..80dbfb7 --- /dev/null +++ b/ols.json @@ -0,0 +1,20 @@ +{ + "$schema": "https://raw.githubusercontent.com/DanielGavin/ols/master/misc/ols.schema.json", + "enable_document_symbols": true, + "enable_hover": true, + "enable_snippets": true, + "collections": [ + { + "name": "core", + "path": "/home/vlad/dev/builds/Odin/core" + }, + { + "name": "vendor", + "path": "/home/vlad/dev/builds/Odin/vendor" + }, + { + "name": "src", + "path": "src" + } + ] +} \ No newline at end of file diff --git a/src/main.odin b/src/main.odin new file mode 100644 index 0000000..0e9cda2 --- /dev/null +++ b/src/main.odin @@ -0,0 +1,49 @@ +package main + +import rl "vendor:raylib" +import "core:math" + +Object :: struct { + position: [2]f32, + velocity: [2]f32, +} + +Player :: struct { + using object: Object, + direction: f32, +} + +main :: proc() { + rl.InitWindow(800, 600, "Torpedo Bots") + rl.SetTargetFPS(60) + + ship := rl.LoadTexture("assets/ship.png") + defer rl.UnloadTexture(ship) + player := Player{} + + for !rl.WindowShouldClose() { + delta := rl.GetFrameTime() + if rl.IsKeyDown(rl.KeyboardKey.UP) { + player.velocity = rl.Vector2MoveTowards(player.velocity, 300 * rl.Vector2Rotate({1,0}, math.to_radians(player.direction)), 700 * delta) + + } + if rl.IsKeyDown(rl.KeyboardKey.LEFT) { + player.direction -= 360 * delta + } + if rl.IsKeyDown(rl.KeyboardKey.RIGHT) { + player.direction += 360 * delta + } + player.position += player.velocity * delta + + + using rl + { + BeginDrawing() + ClearBackground(RAYWHITE) + + DrawTexturePro(ship, {0, 0, 32, 32}, {player.position.x, player.position.y, 32, 32}, {16, 16}, player.direction + 90, WHITE) + EndDrawing() + } + + } +} \ No newline at end of file