diff --git a/main.odin b/main.odin index f19726e..1c2ce74 100644 --- a/main.odin +++ b/main.odin @@ -2,7 +2,6 @@ package main import "core:fmt" import "core:image/png" -import "util" import "vendor:sdl3" WIDTH :: 1600 @@ -25,29 +24,13 @@ main :: proc() { assert(window != nil) defer sdl3.DestroyWindow(window) - render := sdl3.CreateRenderer(window, "opengl") + render := sdl3.CreateRenderer(window, "vulkan") assert(render != nil) units := make([dynamic]Unit) - append( - &units, - Unit { - faction = Faction.Allied, - position = util.Position{x = 500, y = 500}, - velocity = DEFAULT_VELOCITY, - hp = 100, - }, - ) - append( - &units, - Unit { - faction = Faction.Enemy, - position = util.Position{x = 700, y = 700}, - velocity = DEFAULT_VELOCITY, - hp = 100, - }, - ) + append(&units, Unit{faction = Faction.Allied, position = Position{x = 500, y = 500}, hp = 100}) + append(&units, Unit{faction = Faction.Enemy, position = Position{x = 700, y = 700}, hp = 100}) input_state := make(map[sdl3.Scancode]bool) time := sdl3.GetTicksNS() @@ -56,12 +39,7 @@ main :: proc() { game := Game { render = render, units = units, - player = Unit { - faction = Faction.Player, - position = util.Position{x = 255, y = 255}, - velocity = DEFAULT_VELOCITY, - hp = 100, - }, + player = Unit{faction = Faction.Player, position = Position{x = 255, y = 255}, hp = 100}, time = time, delta = 0.0, input_state = input_state, diff --git a/util/math.odin b/math.odin similarity index 59% rename from util/math.odin rename to math.odin index 69b3642..a255820 100644 --- a/util/math.odin +++ b/math.odin @@ -1,9 +1,9 @@ -package util +package main Position :: struct { x, y: f32, } -Velocity :: struct { +Direction :: struct { x, y: f32, } diff --git a/movement.odin b/movement.odin index 2e75864..01ba0bd 100644 --- a/movement.odin +++ b/movement.odin @@ -1,10 +1,8 @@ package main import "core:fmt" -import "util" import "vendor:sdl3" -DEFAULT_VELOCITY: util.Velocity : util.Velocity{x = 0, y = 0} SPEED: f32 : 200 HandleInput :: proc(game: ^Game, event: sdl3.Event) { @@ -17,7 +15,6 @@ MovePlayer :: proc(game: ^Game) { y += game.input_state[sdl3.Scancode.S] ? SPEED : 0 x: f32 = game.input_state[sdl3.Scancode.A] ? -SPEED : 0 x += game.input_state[sdl3.Scancode.D] ? SPEED : 0 - game.player.velocity = util.Velocity{x, y} game.player.position.y += y * game.delta game.player.position.x += x * game.delta diff --git a/unit.odin b/unit.odin index 3bc6d29..1f8ca94 100644 --- a/unit.odin +++ b/unit.odin @@ -1,6 +1,5 @@ package main -import "util" import "vendor:sdl3" Faction :: enum { @@ -11,8 +10,7 @@ Faction :: enum { Unit :: struct { faction: Faction, - position: util.Position, - velocity: util.Velocity, + position: Position, hp: u32, } @@ -33,6 +31,6 @@ RenderUnit :: proc(unit: Unit, game: ^Game) { Projectile :: struct { faction: Faction, - position: util.Position, - direction: util.Velocity, + position: Position, + direction: Direction, }