Added score; Keep track of movement;
This commit is contained in:
parent
ee47329732
commit
579dcbd41c
1
game.go
1
game.go
@ -47,6 +47,7 @@ func initialize() (Game, error) {
|
|||||||
x: 40,
|
x: 40,
|
||||||
y: 12,
|
y: 12,
|
||||||
},
|
},
|
||||||
|
score: 0,
|
||||||
moves: 0,
|
moves: 0,
|
||||||
teleports: 0,
|
teleports: 0,
|
||||||
},
|
},
|
||||||
|
@ -10,41 +10,50 @@ func (g *Game) movePlayer(game *Game, press int) {
|
|||||||
if press == Left {
|
if press == Left {
|
||||||
if game.player.position.x != 2 {
|
if game.player.position.x != 2 {
|
||||||
game.player.position.x--
|
game.player.position.x--
|
||||||
|
game.player.moves++
|
||||||
}
|
}
|
||||||
} else if press == Right {
|
} else if press == Right {
|
||||||
if game.player.position.x != 78 {
|
if game.player.position.x != 78 {
|
||||||
game.player.position.x++
|
game.player.position.x++
|
||||||
|
game.player.moves++
|
||||||
}
|
}
|
||||||
} else if press == Up {
|
} else if press == Up {
|
||||||
if game.player.position.y != 1 {
|
if game.player.position.y != 1 {
|
||||||
game.player.position.y--
|
game.player.position.y--
|
||||||
|
game.player.moves++
|
||||||
}
|
}
|
||||||
} else if press == Down {
|
} else if press == Down {
|
||||||
if game.player.position.y != 22 {
|
if game.player.position.y != 22 {
|
||||||
game.player.position.y++
|
game.player.position.y++
|
||||||
|
game.player.moves++
|
||||||
}
|
}
|
||||||
} else if press == upleft {
|
} else if press == upleft {
|
||||||
if game.player.position.x != 2 && game.player.position.y != 1 {
|
if game.player.position.x != 2 && game.player.position.y != 1 {
|
||||||
game.player.position.x--
|
game.player.position.x--
|
||||||
game.player.position.y--
|
game.player.position.y--
|
||||||
|
game.player.moves++
|
||||||
}
|
}
|
||||||
} else if press == upright {
|
} else if press == upright {
|
||||||
if game.player.position.x != 78 && game.player.position.y != 1 {
|
if game.player.position.x != 78 && game.player.position.y != 1 {
|
||||||
game.player.position.x++
|
game.player.position.x++
|
||||||
game.player.position.y--
|
game.player.position.y--
|
||||||
|
game.player.moves++
|
||||||
}
|
}
|
||||||
} else if press == downright {
|
} else if press == downright {
|
||||||
if game.player.position.x != 78 && game.player.position.y != 22 {
|
if game.player.position.x != 78 && game.player.position.y != 22 {
|
||||||
game.player.position.x++
|
game.player.position.x++
|
||||||
game.player.position.y++
|
game.player.position.y++
|
||||||
|
game.player.moves++
|
||||||
}
|
}
|
||||||
} else if press == downleft {
|
} else if press == downleft {
|
||||||
if game.player.position.x != 2 && game.player.position.y != 22 {
|
if game.player.position.x != 2 && game.player.position.y != 22 {
|
||||||
game.player.position.x--
|
game.player.position.x--
|
||||||
game.player.position.y++
|
game.player.position.y++
|
||||||
|
game.player.moves++
|
||||||
}
|
}
|
||||||
} else if press == teleport {
|
} else if press == teleport {
|
||||||
game.teleport(game)
|
game.teleport(game)
|
||||||
|
game.player.teleports++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user