Implementation of road intersections and road splitting (halfway)
This commit is contained in:
@@ -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,
|
||||
)
|
||||
}
|
||||
@@ -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}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user