|
|
@@ -110,7 +110,6 @@ func DrawMainMenu(s tcell.Screen, defStyle tcell.Style, old_session bool) bool{
|
|
|
for {
|
|
|
s.Clear()
|
|
|
title_size := drawTitle(s, 10, 2, frame, defStyle, cats)
|
|
|
- frame = (frame + 1) % 2
|
|
|
xmax,ymax := s.Size()
|
|
|
// Draw Menu
|
|
|
if menu {
|
|
|
@@ -149,6 +148,7 @@ func DrawMainMenu(s tcell.Screen, defStyle tcell.Style, old_session bool) bool{
|
|
|
// Poll event (this can be in a select statement as well)
|
|
|
select{
|
|
|
case <- ticker.C:
|
|
|
+ frame = (frame + 1) % 2
|
|
|
continue
|
|
|
case ev := <-s.EventQ():
|
|
|
// Process event
|
|
|
@@ -222,19 +222,20 @@ func GetFoodPositions(x1,y1,x2,y2,level int) []*coords{
|
|
|
return res
|
|
|
}
|
|
|
|
|
|
-func DrawFood(s tcell.Screen, y1, y2 int, food_positions []*coords, defStyle tcell.Style) {
|
|
|
+func DrawFood(s tcell.Screen, y1, y2 int, food_positions []*coords, defStyle tcell.Style, decrement bool) {
|
|
|
xmax, ymax := s.Size()
|
|
|
for _, food_pos := range food_positions {
|
|
|
if food_pos.y > y1 && food_pos.y < (y2-1) {
|
|
|
drawText(s,food_pos.x,food_pos.y,xmax,ymax,defStyle,"@")
|
|
|
}
|
|
|
- if food_pos.y < (y2-1) {
|
|
|
+ if food_pos.y < (y2-1) && decrement {
|
|
|
food_pos.y += 1
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
func main() {
|
|
|
// Initialize screen
|
|
|
defStyle := tcell.StyleDefault.Background(color.Black).Foreground(color.NewHexColor(0xf3e5ab))
|
|
|
@@ -271,6 +272,8 @@ func main() {
|
|
|
var food_positions []*coords
|
|
|
speed := 0
|
|
|
message := randomQuote(fallingQuotes)
|
|
|
+ duration := time.Duration(1000/level)
|
|
|
+ ticker := time.NewTicker(duration * time.Millisecond)
|
|
|
game_loop:
|
|
|
go_to_menu := false
|
|
|
for {
|
|
|
@@ -323,7 +326,7 @@ game_loop:
|
|
|
new_level = false
|
|
|
}
|
|
|
|
|
|
- DrawFood(s,y1,y2,food_positions,defStyle)
|
|
|
+ DrawFood(s,y1,y2,food_positions,defStyle, false)
|
|
|
|
|
|
|
|
|
// Draw UI
|
|
|
@@ -334,11 +337,10 @@ game_loop:
|
|
|
drawText(s, x1, y2 + 1, xmax, ymax, defStyle, fmt.Sprintf("Vanilla: \"%s\"", message))
|
|
|
|
|
|
s.Show()
|
|
|
- ticker := time.NewTicker((1000) * time.Millisecond)
|
|
|
defer ticker.Stop()
|
|
|
select{
|
|
|
case <- ticker.C:
|
|
|
- DrawFood(s,y1,y2,food_positions,defStyle)
|
|
|
+ DrawFood(s,y1,y2,food_positions,defStyle,true)
|
|
|
s.Sync()
|
|
|
case ev := <- s.EventQ():
|
|
|
// Process event
|