Implementation of road intersections and road splitting (halfway)

This commit is contained in:
2026-04-24 18:22:55 +02:00
parent 91e205869c
commit b9b7f610ac
5 changed files with 103 additions and 21 deletions

View File

@@ -1,19 +1,26 @@
package infrastructure
import "../common"
import rl "vendor:raylib"
Node :: struct {
id: u32,
enabled: bool,
pos: rl.Vector2,
roads: [dynamic]u32,
}
node_init :: proc(new_id: u32, new_pos: rl.Vector2) -> Node {
node_init :: proc(new_pos: rl.Vector2) -> Node {
return {
id = new_id,
enabled = true,
pos = new_pos,
roads = nil,
}
}
node_within_snapping_radius :: proc(self: ^Node, pos: rl.Vector2) -> bool {
return rl.CheckCollisionPointCircle(
pos,
self.pos,
common.NODE_SNAP_RADIUS * common.NODE_RADIUS,
)
}

View File

@@ -1,13 +1,11 @@
package infrastructure
Road :: struct {
id: u32,
nodes: [2]u32,
}
road_init :: proc(new_id: u32, start: u32, end: u32) -> Road {
road_init :: proc(start: u32, end: u32) -> Road {
return {
id = new_id,
nodes = {start, end}
}
}