alchemyst/main.go
2018-07-31 21:00:16 +03:00

119 lines
2.5 KiB
Go

package main
import "log"
import (
blt "bearlibterminal"
"ui"
"util"
"game"
"fmt"
)
var version = "0.0.0"
func main() {
defer shutdown()
log.Println("Starting...")
config := util.LoadConfig()
var testState = game.Init(config)
var test = game.Item{
&game.Mob{
game.Identifiable{
1,
"testitem1",
},
'!',
1,
1,
"test potion",
game.MapColor{1,254,254, 254},
game.MapColor{1, 0, 0, 0},
false,
},
12}
testState.Level.Mobs = append(testState.Level.Mobs, test.Mob)
var actor = game.Monster{
&game.Mob{
game.Identifiable{
2,
"testactor2",
},
'A',
1,
1,
"Actor for testing",
game.MapColor{1, 233, 254,254},
game.MapColor{1, 0, 0, 0},
true,
},
[]*game.Coords{},
game.MonsterInventory{
1,
100,
[]*game.Item{},
},
1,
500,
}
fmt.Printf("%v", testState)
test.Pickup(&actor)
fmt.Printf("%v", testState)
fmt.Printf("%v", actor)
fmt.Printf("%v", test)
test.Drop(&actor)
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: ./resources/fonts-bitmap/ibmnew8x12.png, size=8x12;")
blt.Print(1, 1, "Hello, [font=italic]world[/font]!")
blt.Print(1, 4, "Testing line-spacing")
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.ClearArea(0,3, 80, 1)
}
switch key {
case "F10":
blt.Set("window: size=100x47; font: ./resources/fonts-ttf/UbuntuMono-R.ttf, size=10;")
case "Ctrl+q":
fallthrough
case "Escape":
exit = true
default:
blt.Print( 1, 3, "Key: " + key )
}
if keycode ==blt.TK_CLOSE {
exit = true
}
blt.Refresh()
}
}
func shutdown() {
log.Println("Here we must save state, but it is not done yet")
log.Println("Exiting application...")
blt.Close()
}