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 0000000..688c1ff Binary files /dev/null and b/assets/ship.png differ 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