steel-lord/main.go
2019-06-28 23:38:16 -07:00

52 lines
1013 B
Go

package main
import (
"log"
"github.com/kettek/goro"
"steel/entity"
)
func main() {
// Initialize goro!
if err := goro.InitTCell(); err != nil {
log.Fatal(err)
}
goro.Run(func(screen *goro.Screen) {
// Screen configuration.
screen.SetTitle("Steel Lord")
screen.SetSize(60, 14)
// Our initial variables.
player := entity.NewEntity(screen.Columns/2, screen.Rows/2, '@', goro.Style{Foreground: goro.ColorWhite})
npc := entity.NewEntity(screen.Columns/2-5, screen. Rows/2, '@', goro.Style{Foreground: goro.ColorYellow})
entities := []*entity.Entity{
player,
npc,
}
// The game loop.
for {
// Draw screen.
DrawAll(screen, entities)
ClearAll(screen, entities)
// Handle events.
switch event := screen.WaitEvent().(type) {
case goro.EventKey:
switch action := handleKeyEvent(event).(type) {
case ActionMove:
player.Move(action.X, action.Y)
case ActionQuit:
goro.Quit()
}
case goro.EventQuit:
return
}
}
})
}