examples/runes: Trim the text if it has too many lines

This commit is contained in:
Hajime Hoshi 2017-08-16 00:17:07 +09:00
parent 3f52fb951b
commit 193e473381

View File

@ -31,9 +31,14 @@ var (
func update(screen *ebiten.Image) error {
text += string(ebiten.InputChars())
ss := strings.Split(text, "\n")
if len(ss) > 10 {
text = strings.Join(ss[len(ss)-10:], "\n")
}
if ebiten.IsKeyPressed(ebiten.KeyEnter) && !strings.HasSuffix(text, "\n") {
text += "\n"
}
counter++
if ebiten.IsRunningSlowly() {