portals 1

This commit is contained in:
2026-06-13 17:58:04 -05:00
parent 49d32eedf5
commit 6818f0545a
9 changed files with 151 additions and 7 deletions
+20
View File
@@ -223,6 +223,26 @@ impl GameState {
Action::Scroll(lines) => {
new_scroll = Some(Scroll { source: ba.source, lines });
}
Action::Teleport { x, y } => {
if !board.in_bounds((x, y)) {
logs.push(LogLine::error(format!(
"teleport({x},{y}): out of bounds"
)));
} else {
let (ux, uy) = (x as usize, y as usize);
let source_solid = board.objects.get(&ba.source)
.map(|o| o.solid)
.unwrap_or(false);
if source_solid && board.solid_at(ux, uy).is_some() {
logs.push(LogLine::error(format!(
"teleport({x},{y}): destination is solid"
)));
} else if let Some(obj) = board.objects.get_mut(&ba.source) {
obj.x = ux;
obj.y = uy;
}
}
}
}
}
}