Esempio n. 1
0
func main() {
	gotAttrs, initAttrs := console.GetScreenBufferInfo()
	if gotAttrs {
		defer console.SetScreenBufferInfo(initAttrs)
	}

	rCon := setup()
	console.SetCursorProperties(1, false)
	console.ClearScreen(80, 25)

	sprite := new(rc.Sprite)
	sprite.X = 4
	sprite.Y = 3

	spriteChars := rc.StringToArray(2, 2, "SSS ")
	rc.Replace(&spriteChars, ' ', rc.TransparancyChar)
	spriteColors := rc.FillArrayI(2, 2, console.ChFgCyan)
	spriteColors[0][1] = console.ChFgGreen | console.ChBgDarkMagenta
	sprite.SetGraphics(spriteChars, spriteColors)

	rCon.RegisterSprite(sprite, 0)

	rCon.Draw()

	for {
		isHit, char := console.GetKey()
		if isHit {

			char = strings.ToLower(char)
			switch char {
			case "w":
				if sprite.Y > 0 {
					sprite.Y--
				}
			case "a":
				if sprite.X > 0 {
					sprite.X--
				}
			case "s":
				if sprite.Y < rCon.EnvHeight {
					sprite.Y++
				}
			case "d":
				if sprite.X < rCon.EnvWidth {
					sprite.X++
				}
			case "q":
				return
			}

			rCon.Draw()
		}
	}
}
Esempio n. 2
0
// InitiVisual passes the form's visual context to
// the InitiVisual method of all controls.
func (form *Form) InitiVisual() {
	console.SetCursorProperties(1, false)
	form.forAllControls(func(control Control) {
		control.InitVisual(form.visual)
	})
}