65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
package main
|
|
|
|
import "log"
|
|
import (
|
|
blt "bearlibterminal"
|
|
"ui"
|
|
"util"
|
|
"flag"
|
|
"io/ioutil"
|
|
"encoding/json"
|
|
"game"
|
|
)
|
|
|
|
var version = "0.0.0"
|
|
|
|
func main() {
|
|
log.Println("Starting...")
|
|
|
|
var configArg string = "./config.json"
|
|
flag.StringVar(&configArg, "cfg", configArg, "config file location")
|
|
flag.Parse()
|
|
|
|
// get config
|
|
data, err := ioutil.ReadFile(configArg)
|
|
if err != nil {
|
|
log.Fatalf("quoteCompressor can't read config at %s", configArg)
|
|
}
|
|
config := new(util.Config)
|
|
err = json.Unmarshal(data, config)
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
|
|
game.Init(config)
|
|
|
|
blt.Open()
|
|
//blt.Set("window: size=80x25, title="+config.Title+" v"+string(version)+"; font: ./fonts/Monaco-Linux.ttf, size=10")
|
|
blt.Set("window: size=100x47, title="+config.Title+" v"+string(version)+"; font: ./fonts/UbuntuMono-R.ttf, size=10;")
|
|
defer blt.Close()
|
|
blt.Print(1, 1, "Hello, [font=italic]world[/font]!")
|
|
blt.PrintExt(1, 6, 5, 4, 1, "Lorem ipsum dolor sit amet")
|
|
blt.Refresh()
|
|
|
|
|
|
mainLoop()
|
|
}
|
|
|
|
func mainLoop () {
|
|
|
|
var exit = false
|
|
|
|
for !exit {
|
|
var key, keycode = ui.ReadKey();
|
|
if key != "" {
|
|
blt.Print( 1, 3, "Key: ")
|
|
}
|
|
blt.Print( 1, 3, "Key: " + key )
|
|
exit, _ = util.InArray(keycode, []int{blt.TK_CLOSE, blt.TK_ESCAPE})
|
|
if (!exit) {
|
|
exit = key == "Ctrl+q"
|
|
}
|
|
blt.Refresh()
|
|
}
|
|
log.Println("Closing...")
|
|
} |