add player
This commit is contained in:
parent
aab03eafef
commit
8babb48fd2
3 changed files with 21 additions and 2 deletions
|
@ -10,6 +10,7 @@ HEIGHT :: 900
|
|||
Game :: struct {
|
||||
render: ^sdl3.Renderer,
|
||||
units: [dynamic]Unit,
|
||||
player: Unit,
|
||||
}
|
||||
|
||||
main :: proc() {
|
||||
|
@ -23,13 +24,15 @@ main :: proc() {
|
|||
render := sdl3.CreateRenderer(window, "vulkan")
|
||||
|
||||
assert(render != nil)
|
||||
|
||||
units := make([dynamic]Unit)
|
||||
append(&units, Unit{faction = Faction.Player, position = Position{x = 500, y = 500}, 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})
|
||||
|
||||
game := Game {
|
||||
render = render,
|
||||
units = units,
|
||||
units = units,
|
||||
player = Unit{faction = Faction.Player, position = Position{x = 255, y = 255}, hp = 100},
|
||||
}
|
||||
|
||||
for {
|
||||
|
@ -57,6 +60,8 @@ RenderGame :: proc(game: Game) {
|
|||
RenderUnit(unit, game)
|
||||
}
|
||||
|
||||
RenderUnit(game.player, game)
|
||||
|
||||
sdl3.RenderPresent(game.render)
|
||||
|
||||
}
|
||||
|
|
|
@ -3,3 +3,7 @@ package main
|
|||
Position :: struct {
|
||||
x, y: f32,
|
||||
}
|
||||
|
||||
Direction :: struct {
|
||||
x, y: f32,
|
||||
}
|
||||
|
|
10
unit.odin
10
unit.odin
|
@ -4,6 +4,7 @@ import "vendor:sdl3"
|
|||
|
||||
Faction :: enum {
|
||||
Player,
|
||||
Allied,
|
||||
Enemy,
|
||||
}
|
||||
|
||||
|
@ -19,9 +20,18 @@ RenderUnit :: proc(unit: Unit, game: Game) {
|
|||
sdl3.SetRenderDrawColor(game.render, 0, 255, 0, 0)
|
||||
case Faction.Enemy:
|
||||
sdl3.SetRenderDrawColor(game.render, 255, 0, 0, 0)
|
||||
case Faction.Allied:
|
||||
sdl3.SetRenderDrawColor(game.render, 0, 0, 255, 0)
|
||||
}
|
||||
sdl3.RenderRect(
|
||||
game.render,
|
||||
&sdl3.FRect{x = unit.position.x, y = unit.position.y, w = 10, h = 10},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Projectile :: struct {
|
||||
faction: Faction,
|
||||
position: Position,
|
||||
direction: Direction,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue