extract render into its own procedure
This commit is contained in:
parent
d5e67552d4
commit
aab03eafef
1 changed files with 11 additions and 8 deletions
19
main.odin
19
main.odin
|
@ -21,8 +21,8 @@ main :: proc() {
|
|||
defer sdl3.DestroyWindow(window)
|
||||
|
||||
render := sdl3.CreateRenderer(window, "vulkan")
|
||||
assert(render != nil)
|
||||
|
||||
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.Enemy, position = Position{x = 700, y = 700}, hp = 100})
|
||||
|
@ -45,15 +45,18 @@ main :: proc() {
|
|||
}
|
||||
}
|
||||
|
||||
sdl3.SetRenderDrawColor(render, 0, 0, 0, 0)
|
||||
sdl3.RenderClear(render)
|
||||
RenderGame(game)
|
||||
}
|
||||
}
|
||||
|
||||
for unit in game.units {
|
||||
RenderUnit(unit, game)
|
||||
}
|
||||
|
||||
sdl3.RenderPresent(render)
|
||||
RenderGame :: proc(game: Game) {
|
||||
sdl3.SetRenderDrawColor(game.render, 0, 0, 0, 0)
|
||||
sdl3.RenderClear(game.render)
|
||||
|
||||
for unit in game.units {
|
||||
RenderUnit(unit, game)
|
||||
}
|
||||
|
||||
sdl3.RenderPresent(game.render)
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue