Skip to content

Instantly share code, notes, and snippets.

@sevvie
Created September 22, 2012 02:25
Show Gist options
  • Save sevvie/3764917 to your computer and use it in GitHub Desktop.
Save sevvie/3764917 to your computer and use it in GitHub Desktop.
Useless example in Go, for the $GB
package main
import( "fmt"; "time" )
// type Board
// The game board
type Board struct {
tiles [][]int
}
type Tile struct {
id int
terrain int
}
// type Gear
// Gears are the abstract 'parts' of an Engine, that may or may not
// require updating each tick.
type Gear struct {
}
// type Engine
// The engine runs the system. Simple enough.
type Engine struct {
isRunning bool
gears []Gear
}
func (e Engine) Run() {
e.Startup()
for e.isRunning {
// Update everything and redraw.
}
e.Teardown()
}
func (e Engine) EnableRunning() {
e.isRunning = true
}
func (e Engine) DisableRunning() {
e.isRunning = false
}
func (e Engine) ToggleRunning() {
e.isRunning = !e.isRunning
}
func (e Engine) Startup() {
}
func (e Engine) Teardown() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment