Example #1
0
func NewGame(config *gutil.LuaConfig) *Game {
	g := Game{config: config}
	g.Objects = game.NewGameObjectMap()

	g.CloseChan = make(chan bool, 1)

	g.player = game.NewGameObject("")

	g.mainpanel = panel.MainScreen()
	g.panels = make(map[string]panel.Panel)

	g.panels["stats"] = NewStatsPanel()
	g.panels["view"] = NewViewPanel(&g)
	g.panels["log"] = NewLogPanel()
	g.panels["player"] = NewPlayerPanel(&g)
	g.panels["chat"] = NewChatPanel(&g, &g.Terminal)

	g.logpanel = g.panels["log"].(*LogPanel)
	g.chatpanel = g.panels["chat"].(*ChatPanel)

	//g.chatbox = NewChatBuffer(&g, &g.Terminal)

	//g.Objects = append(g.Objects, g.Player.GameObject)

	return &g
}
Example #2
0
func main() {
	termbox.Init()
	defer termbox.Close()
	m := panel.MainScreen()
	var p panel.Panel = newOcto()
loop:
	for {
		m.Clear().Write(help)
		panel.DrawAll(panels...)
		if len(panels) > 0 {
			p.SetBorder(termbox.Cell{'d', 2, 0})
		}
		termbox.Flush()

		switch ev := termbox.PollEvent(); ev.Type {
		case termbox.EventKey:
			switch ev.Key {
			case termbox.KeyEsc:
				break loop
			case termbox.KeyTab:
				p.SetBorder(termbox.Cell{'s', 0, 0})
				p = panels[0]
				Top(p)
			case termbox.KeyArrowDown:
				p.Move(0, 1)
			case termbox.KeyArrowUp:
				p.Move(0, -1)
			case termbox.KeyArrowLeft:
				p.Move(-1, 0)
			case termbox.KeyArrowRight:
				p.Move(1, 0)
			case termbox.KeyInsert:
				p.SetBorder(termbox.Cell{'s', 0, 0})
				p = newOcto()
				Top(p)
			case termbox.KeyDelete:
				if len(panels) > 0 {
					panels = panels[:len(panels)-1]
					if len(panels) > 0 {
						p = panels[0]
						Top(p)
					}
				}
			}
		}
	}
}
Example #3
0
func main() {
	termbox.Init()
	defer termbox.Close()
	m := panel.MainScreen()

	for _, s := range strings.Split(example, "\n") {
		helper.ScrollWriteUpwards(m, s)
		termbox.Flush()
		time.Sleep(time.Millisecond * 500)
	}
	for _, s := range strings.Split(example, "\n") {
		helper.ScrollWrite(m, s)
		termbox.Flush()
		time.Sleep(time.Millisecond * 500)
	}
	helper.ScrollWrite(m, "And that's\neverything\nfor now.")
	termbox.Flush()
	time.Sleep(time.Millisecond * 2000)
}