diff --git a/examples/game/player.tm b/examples/game/player.tm index 5909ae6..91f7a17 100644 --- a/examples/game/player.tm +++ b/examples/game/player.tm @@ -12,7 +12,7 @@ struct Player(pos,prev_pos:Vec2): FRICTION := 0.99 SIZE := Vec2(30, 30) - func update(p:&Player): + func update(p:@Player): target_x := inline C:Num { (Num_t)((IsKeyDown(KEY_A) ? -1 : 0) + (IsKeyDown(KEY_D) ? 1 : 0)) } diff --git a/examples/game/world.tm b/examples/game/world.tm index 71c14bf..4df7f15 100644 --- a/examples/game/world.tm +++ b/examples/game/world.tm @@ -38,18 +38,18 @@ func solve_overlap(a_pos:Vec2, a_size:Vec2, b_pos:Vec2, b_size:Vec2 -> Vec2): return Vec2(0, 0) -struct World(player:@Player, goal:@Box, boxes:[@Box], dt_accum=0.0, won=no): +struct World(player:@Player, goal:@Box, boxes:@[@Box], dt_accum=0.0, won=no): DT := 1./60. - CURRENT := @World(@Player(Vec2(0,0), Vec2(0,0)), @Box(Vec2(0,0), Vec2(0,0), Color.GOAL), [:@Box]) + CURRENT := @World(@Player(Vec2(0,0), Vec2(0,0)), @Box(Vec2(0,0), Vec2(0,0), Color.GOAL), @[:@Box]) STIFFNESS := 0.3 - func update(w:&World, dt:Num): + func update(w:@World, dt:Num): w.dt_accum += dt while w.dt_accum > 0: w:update_once() w.dt_accum -= World.DT - func update_once(w:&World): + func update_once(w:@World): w.player:update() if solve_overlap(w.player.pos, Player.SIZE, w.goal.pos, w.goal.size) != Vec2(0,0): @@ -57,11 +57,11 @@ struct World(player:@Player, goal:@Box, boxes:[@Box], dt_accum=0.0, won=no): # Resolve player overlapping with any boxes: for i in 3: - for b in w.boxes: + for b in w.boxes[]: w.player.pos += STIFFNESS * solve_overlap(w.player.pos, Player.SIZE, b.pos, b.size) - func draw(w:&World): - for b in w.boxes: + func draw(w:@World): + for b in w.boxes[]: b:draw() w.goal:draw() w.player:draw() @@ -71,17 +71,17 @@ struct World(player:@Player, goal:@Box, boxes:[@Box], dt_accum=0.0, won=no): DrawText("WINNER", GetScreenWidth()/2-48*3, GetScreenHeight()/2-24, 48, (Color){0,0,0,0xFF}); } - func load_map(w:&World, map:Text): + func load_map(w:@World, map:Text): if map:has($/[]/): map = map:replace_all({$/[]/: "#", $/@{1..}/: "@", $/ /: " "}) - w.boxes = [:@Box] + w.boxes = @[:@Box] box_size := Vec2(50., 50.) for y,line in map:lines(): for x,cell in line:split(): if cell == "#": pos := Vec2((Num(x)-1) * box_size.x, (Num(y)-1) * box_size.y) box := @Box(pos, size=box_size, color=Color.GRAY) - (&w.boxes):insert(box) + w.boxes:insert(box) else if cell == "@": pos := Vec2((Num(x)-1) * box_size.x, (Num(y)-1) * box_size.y) pos += box_size/2. - Player.SIZE/2. diff --git a/examples/tomodeps/tomodeps.tm b/examples/tomodeps/tomodeps.tm index 907734a..1565575 100644 --- a/examples/tomodeps/tomodeps.tm +++ b/examples/tomodeps/tomodeps.tm @@ -25,7 +25,7 @@ func _get_file_dependencies(file:Path -> {Dependency}): deps:add(Dependency.Module(module_name)) return deps -func _build_dependency_graph(dep:Dependency, dependencies:&{Dependency:{Dependency}}): +func _build_dependency_graph(dep:Dependency, dependencies:@{Dependency:{Dependency}}): return if dependencies:has(dep) dependencies:set(dep, {:Dependency}) # Placeholder @@ -56,8 +56,8 @@ func _build_dependency_graph(dep:Dependency, dependencies:&{Dependency:{Dependen _build_dependency_graph(dep2, dependencies) func get_dependency_graph(dep:Dependency -> {Dependency:{Dependency}}): - graph := {:Dependency:{Dependency}} - _build_dependency_graph(dep, &graph) + graph := @{:Dependency:{Dependency}} + _build_dependency_graph(dep, graph) return graph func _printable_name(dep:Dependency -> Text): @@ -70,7 +70,7 @@ func _printable_name(dep:Dependency -> Text): else: return "$(\x1b)[31;1m$(f.text_content) (not found)$(\x1b)[m" -func _draw_tree(dep:Dependency, dependencies:{Dependency:{Dependency}}, already_printed:&{Dependency}, prefix="", is_last=yes): +func _draw_tree(dep:Dependency, dependencies:{Dependency:{Dependency}}, already_printed:@{Dependency}, prefix="", is_last=yes): if already_printed:has(dep): say(prefix ++ (if is_last: "└── " else: "├── ") ++ _printable_name(dep) ++ " $\x1b[2m(recursive)$\x1b[m") return @@ -86,13 +86,13 @@ func _draw_tree(dep:Dependency, dependencies:{Dependency:{Dependency}}, already_ _draw_tree(child, dependencies, already_printed, child_prefix, is_child_last) func draw_tree(dep:Dependency, dependencies:{Dependency:{Dependency}}): - printed := {:Dependency} + printed := @{:Dependency} say(_printable_name(dep)) printed:add(dep) deps := dependencies:get(dep) or {:Dependency} for i,child in deps.items: is_child_last := (i == deps.length) - _draw_tree(child, dependencies, already_printed=&printed, is_last=is_child_last) + _draw_tree(child, dependencies, already_printed=printed, is_last=is_child_last) func main(files:[Text]): if files.length == 0: