Car and pathfinding implementation setup

This commit is contained in:
2026-04-26 21:50:39 +02:00
parent ee34acae34
commit 697183f961
8 changed files with 39 additions and 7 deletions

View File

@@ -1,8 +1,10 @@
package vehicles
import "core:math/rand"
import rl "vendor:raylib"
import "../common"
import inf "../infrastructure"
Car :: struct {
// Fuel level 0-100%
@@ -16,14 +18,22 @@ Car :: struct {
origin: u32,
// Car's destination node
destination: Maybe(u32),
// Tracks on which node car has been last
node_pos: u32,
road_pos: Maybe(u32),
actual_pos: rl.Vector2,
}
// Constructor
car_init :: proc(nodes_len: u32) -> Car {
car_init :: proc(nodes: []inf.Node) -> Car {
rand_origin := rand.uint32_max(nodes_len)
return {
fuel_level = common.FUEL_MAX,
max_speed = common.CAR_MAX_SPEED,
origin = rand.uint32_max(nodes_len)
origin = rand_origin,
node_pos = rand_origin,
actual_pos =
}
}