Skip to content

Commit

Permalink
The snake now dies when hitting the scoreboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Bios-Marcel committed Dec 15, 2019
1 parent 5cf2b76 commit 2c2d8ad
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ func (state *gameState) updateSnake(screen tcell.Screen) {
}

//if the head is out of screen, we are dead
oldHeadChar, _, _, _ := screen.GetContent(oldHead.x, oldHead.y)
if oldHeadChar == 0 {
state.gameOver(screen)
if oldHead.y < 0 || oldHead.y >= state.height ||
oldHead.x < 0 || oldHead.x >= state.width {
state.gameOver(screen)
}

var heading direction
Expand Down Expand Up @@ -233,7 +233,7 @@ func (state *gameState) clearScreen(screen tcell.Screen) {
screen.SetCell(bodyPart.x+1, bodyPart.y, tcell.StyleDefault, ' ')
}

//Clear bottombar staring at 7, sicne we want to leave "Score: "
//Clear bottombar staring at 7, since we want to leave "Score: "
for i := 7; i < state.width; i++ {
screen.SetCell(i, state.height, tcell.StyleDefault, ' ')
}
Expand Down

0 comments on commit 2c2d8ad

Please sign in to comment.