Source File: curse-you-go-rogue/02_mazes_and_enemies/map.go.diff
--- 01_the_screen/map.go 2025-10-06 23:32:48.943928000 -0400
+++ 02_mazes_and_enemies/map.go 2025-10-06 23:33:02.887088700 -0400
@@ -22,4 +22,5 @@
func (game *Game) Occupied(pos Position) bool {
+ _, is_enemy := game.Enemies[pos]
is_player := pos == game.Player.Pos
@@ -27,4 +28,5 @@
return !game.Inbounds(pos, 1) ||
game.Level[pos.Y][pos.X] == WALL ||
+ is_enemy ||
is_player
}
@@ -35,2 +37,19 @@
}
}
+
+func (game *Game) Neighbors(near Position) []Position {
+ result := make([]Position, 0, 4)
+ points := compass(near, 2)
+
+ for _, pos := range points {
+ if game.Inbounds(pos, 0) {
+ result = append(result, pos)
+ }
+ }
+
+ return result
+}
+
+func (game *Game) NewMap() {
+ game.FillMap(game.Level, '#')
+}