snake/main.go

38 lines
711 B
Go
Raw Normal View History

package main
import (
"log"
)
2023-11-12 16:57:52 +01:00
type Position struct {
x int
y int
}
type Apple Position
//type Snake Position
func main() {
2023-11-12 16:01:06 +01:00
// Create channles to manage keypresses and the gamestate
keypresses := make(chan int)
gamestate := make(chan int)
2023-11-12 16:01:06 +01:00
// Initialize tcell and clean up when needed.
screen, style, err := initilize()
if err != nil {
log.Fatalln("Initlization error: ", err)
}
defer quit(screen)
2023-11-12 16:01:06 +01:00
// Spawn the Game Director in its own go routine
// We give it channels to control...
go gameDirector(screen, style, keypresses, gamestate)
2023-11-12 16:01:06 +01:00
// A simple function that captures keyboard presses...
// ...and sends it to the GameDirector.
keyboardProcessor(screen, keypresses, gamestate)
}