Пример #1
0
//Draw outputs the frame buffer to the console.
func (con *RogueConsole) Draw() {
	con.Visit(func(r rune, i int, row int, col int) {
		console.MoveTo(col, row)
		console.SetCharacterProperties(i)
		fmt.Print(string(r))
	})
}
Пример #2
0
func main() {
	numCols := 80
	numRows := 25

	console.SetTitle("lol I set the title too")
	console.ClearScreen(numCols, numRows)
	x, y := 0, 0
	console.MoveTo(x, y)
	sprite := "O"
	fmt.Print(sprite)
	console.MoveTo(numCols-1, numRows-1)
	_, info := console.GetScreenBufferInfo()

	for {
		isHit, event := console.GetKeyEX()
		if isHit && event.IsSpecial {
			console.MoveTo(x, y)
			fmt.Print(" ")

			switch event.SpecialChar {
			case console.ScArrowUp:
				y--
			case console.ScArrowLeft:
				x--
			case console.ScArrowDown:
				y++
			case console.ScArrowRight:
				x++
			case console.ScEsc:
				return
			}

			console.MoveTo(x, y)

			console.SetCharacterProperties(console.ChFgBlue | console.ChBgYellow | console.ChUnderline)
			fmt.Print(sprite)
			console.SetCharacterProperties(info.CharacterColor)

			console.MoveTo(numCols-1, numRows-1)
		}
	}
}