Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Functional game loop
package main
import "fmt"
type coords struct {
x int
y int
type apple struct {
position coords
type gameState struct {
apple apple
func logic(state *gameState) { = + 1
func gameLoop(running bool, state *gameState) bool {
if running == false {
return false
return gameLoop(running, state)
func main() {
// set the initial game state
state := gameState{
apple: apple{
position: coords{
x: 2,
y: 2,
gameLoop(true, &state)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.