A Go version of the https://lcthw.dev/learn-code-the-hard-way/curseyou-python-rogue that makes a tiny Rogue in Go.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
767 B
35 lines
767 B
1 day ago
|
--- 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, '#')
|
||
|
+}
|