31 lines
689 B
Go
31 lines
689 B
Go
// An amateurs approach to the game of Snake
|
|
package main
|
|
|
|
import (
|
|
"log"
|
|
)
|
|
|
|
// main function
|
|
func main() {
|
|
|
|
// Create channles to manage keypresses and the gamestate
|
|
keypresses := make(chan int)
|
|
gamestate := make(chan int)
|
|
|
|
// Initialize tcell and clean up when needed.
|
|
screen, style, err := initilize()
|
|
if err != nil {
|
|
log.Fatalln("Initlization error: ", err)
|
|
}
|
|
defer quit(screen)
|
|
|
|
// Spawn the Game Director in its own go routine
|
|
// We give it channels to control...
|
|
go gameDirector(screen, style, keypresses, gamestate)
|
|
|
|
// A simple function that captures keyboard presses...
|
|
// ...and sends it to the GameDirector.
|
|
keyboardProcessor(screen, keypresses, gamestate)
|
|
|
|
}
|