steel-lord/main.go

45 lines
918 B
Go
Raw Normal View History

2019-06-27 20:29:15 -07:00
package main
import (
"log"
"github.com/kettek/goro"
2019-06-28 16:37:33 -07:00
"steel/entity"
2019-06-27 20:29:15 -07:00
)
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.
2019-06-28 16:37:33 -07:00
player := entity.NewEntity(screen.Columns/2, screen.Rows/2, '@', goro.Style{Foreground: goro.ColorWhite})
2019-06-27 20:29:15 -07:00
// The game loop.
for {
// Draw screen.
2019-06-28 16:37:33 -07:00
screen.DrawRune(player.X, player.Y, player.Rune, player.Style)
2019-06-27 20:29:15 -07:00
screen.Flush()
2019-06-28 16:37:33 -07:00
screen.DrawRune(player.X, player.Y, ' ', goro.Style{})
2019-06-27 20:29:15 -07:00
// Handle events.
switch event := screen.WaitEvent().(type) {
case goro.EventKey:
switch action := handleKeyEvent(event).(type) {
case ActionMove:
2019-06-28 16:37:33 -07:00
player.Move(action.X, action.Y)
2019-06-27 20:29:15 -07:00
case ActionQuit:
goro.Quit()
}
case goro.EventQuit:
return
}
}
})
}