improve Unit and utilities
This commit is contained in:
parent
60d71ae1c0
commit
1a24af7230
3 changed files with 36 additions and 35 deletions
23
unit.odin
23
unit.odin
|
@ -3,6 +3,10 @@ package main
|
|||
import "util"
|
||||
import "vendor:sdl3"
|
||||
|
||||
DEFAULT_HP :: 100
|
||||
DEFAULT_VELOCITY: util.Velocity : util.Velocity{x = 0, y = 0}
|
||||
DEFAULT_SPEED: f32 : 200
|
||||
|
||||
Faction :: enum {
|
||||
Player,
|
||||
Allied,
|
||||
|
@ -13,6 +17,7 @@ Unit :: struct {
|
|||
faction: Faction,
|
||||
position: util.Position,
|
||||
velocity: util.Velocity,
|
||||
speed: f32,
|
||||
hp: u32,
|
||||
}
|
||||
|
||||
|
@ -31,6 +36,24 @@ RenderUnit :: proc(unit: Unit, game: ^Game) {
|
|||
)
|
||||
}
|
||||
|
||||
NewUnit :: proc {
|
||||
NewUnitBase,
|
||||
NewUnitHp,
|
||||
NewUnitAll
|
||||
}
|
||||
|
||||
NewUnitBase :: proc(faction: Faction, position: util.Position) -> Unit {
|
||||
return Unit{faction, position, DEFAULT_VELOCITY, DEFAULT_SPEED, DEFAULT_HP}
|
||||
}
|
||||
|
||||
NewUnitHp :: proc(faction: Faction, position: util.Position, hp: u32) -> Unit {
|
||||
return Unit{faction, position, DEFAULT_VELOCITY, DEFAULT_SPEED, hp}
|
||||
}
|
||||
|
||||
NewUnitAll :: proc(faction: Faction, position: util.Position, speed: f32, hp: u32) -> Unit {
|
||||
return Unit{faction, position, DEFAULT_VELOCITY, speed, hp}
|
||||
}
|
||||
|
||||
Projectile :: struct {
|
||||
faction: Faction,
|
||||
position: util.Position,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue