Skip to content

Commit

Permalink
better start and gameover screen
Browse files Browse the repository at this point in the history
  • Loading branch information
0riginaln0 committed Apr 6, 2024
1 parent 06d973d commit 80d20f6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
33 changes: 25 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ func anyInput() {
if (justPressed&w4.BUTTON_UP != 0 || justPressed&w4.BUTTON_DOWN != 0 ||
justPressed&w4.BUTTON_LEFT != 0 || justPressed&w4.BUTTON_RIGHT != 0) &&
(mode == "start" || mode == "game over") {
startscreenTimeout = 0
gameoverTimeout = 0
mode = "playing"
}

Expand Down Expand Up @@ -90,20 +92,35 @@ func winScreen() {
w4.Text("Take a break :)", 0, 110)
}

var gameoverTimeout = 0

func gameOver() {
gameoverTimeout += 1
w4.Text("GAME OVER", 30, 70)
w4.Text("good luck next time", 5, 90)
w4.Text(":)", 75, 120)
anyInput()
if gameoverTimeout >= 60 {

w4.Text("good luck next time", 5, 90)
}
if gameoverTimeout >= 120 {
w4.Text(":)", 75, 120)
}
if gameoverTimeout >= 180 {
anyInput()
}
}

var startscreenTimeout = 0

func startScreen() {
anyInput()
startscreenTimeout += 1
w4.Text("SNAKE", 30, 30)
w4.Text("Made by me", 20, 90)
w4.Text("github.com", 0, 110)
w4.Text("/", 75, 120)
w4.Text("0riginaln0", 80, 130)
if startscreenTimeout >= 90 {
w4.Text("Made by me", 20, 90)
w4.Text("github.com", 0, 110)
w4.Text("/", 75, 120)
w4.Text("0riginaln0", 80, 130)
anyInput()
}
}

func playing() {
Expand Down
6 changes: 3 additions & 3 deletions snake.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ type Snake struct {

func (s *Snake) Reset() {
s.Body = []Point{
{X: 12, Y: 10},
{X: 11, Y: 10},
{X: 10, Y: 10},
{X: 7, Y: 10},
{X: 6, Y: 10},
{X: 5, Y: 10},
}
s.Direction = Point{X: 1, Y: 0}
}
Expand Down

0 comments on commit 80d20f6

Please sign in to comment.