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.
24 lines
467 B
24 lines
467 B
3 days ago
|
package main
|
||
|
|
||
|
|
||
|
func (game *Game) MoveEnemy(from Position, to Position) {
|
||
|
enemy, ok := game.Enemies[from]
|
||
|
if !ok { dbg.Fatal("no enemy at", from, "wtf") }
|
||
|
|
||
|
delete(game.Enemies, from)
|
||
|
game.Enemies[to] = enemy
|
||
|
}
|
||
|
|
||
|
func (game *Game) MovePlayer(x_delta int, y_delta int) {
|
||
|
target := Position{
|
||
|
game.Player.Pos.X + x_delta,
|
||
|
game.Player.Pos.Y + y_delta,
|
||
|
}
|
||
|
|
||
|
if game.Occupied(target) {
|
||
|
game.Attack(target)
|
||
|
} else {
|
||
|
game.Player.Pos = target
|
||
|
}
|
||
|
}
|