Replaced all u32 instances with uint, implemented road length,
implemented basic pathing checks/algorithms, implemented entities id display for easier debugging
This commit is contained in:
@@ -18,14 +18,14 @@ Car :: struct {
|
||||
// Car's current node/road
|
||||
pos: common.Car_Position,
|
||||
// Car's destination node
|
||||
destination: Maybe(u32),
|
||||
destination: Maybe(uint),
|
||||
|
||||
// tracks absolute pos (within canvas)
|
||||
absolute_pos: rl.Vector2,
|
||||
}
|
||||
|
||||
// Constructor
|
||||
car_init :: proc(spawn_node: u32, nodes: []inf.Node) -> Car {
|
||||
car_init :: proc(spawn_node: uint, nodes: []inf.Node) -> Car {
|
||||
return {
|
||||
fuel_level = common.FUEL_MAX,
|
||||
max_speed = common.CAR_MAX_SPEED,
|
||||
@@ -38,13 +38,13 @@ car_init :: proc(spawn_node: u32, nodes: []inf.Node) -> Car {
|
||||
}
|
||||
|
||||
// Updates (origin and destination) node reference
|
||||
car_update_node_reference :: proc(self: ^Car, old_ref: u32, new_ref: u32) {
|
||||
car_update_node_reference :: proc(self: ^Car, old_ref: uint, new_ref: uint) {
|
||||
if self.pos.type == .Node && self.pos.ref == old_ref do self.pos.ref = new_ref
|
||||
if self.destination == old_ref do self.destination = new_ref
|
||||
}
|
||||
|
||||
// Prints car's route
|
||||
car_print_route :: proc(id: Maybe(u32) = nil, self: ^Car) {
|
||||
car_print_route :: proc(id: Maybe(uint) = nil, self: ^Car) {
|
||||
val, ok := self.destination.?
|
||||
destination := ok ? fmt.aprintf("N%d", val) : "/"
|
||||
source_type := self.pos.type == .Node ? 'N' : 'R'
|
||||
|
||||
Reference in New Issue
Block a user