examples/snake: update comments (#2869)

This commit is contained in:
Ahmet Affan 2023-12-20 22:30:42 +03:00 committed by GitHub
parent b73d63da29
commit ef1fea890f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -102,6 +102,8 @@ func (g *Game) reset() {
}
func (g *Game) Update() error {
// Decide the snake's direction along with the user input.
// A U-turn is forbidden here (e.g. if the snake is moving in the left direction, the snake cannot go to the right direction immediately).
if inpututil.IsKeyJustPressed(ebiten.KeyArrowLeft) || inpututil.IsKeyJustPressed(ebiten.KeyA) {
if g.moveDirection != dirRight {
g.moveDirection = dirLeft