Compare commits
No commits in common. "60d71ae1c050d92d1398bcb7b31f595729dd2017" and "04928ab3c9707818ea85a035677731d125433c46" have entirely different histories.
60d71ae1c0
...
04928ab3c9
4 changed files with 9 additions and 36 deletions
30
main.odin
30
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,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package util
|
||||
package main
|
||||
|
||||
Position :: struct {
|
||||
x, y: f32,
|
||||
}
|
||||
|
||||
Velocity :: struct {
|
||||
Direction :: struct {
|
||||
x, y: f32,
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue