From 193e473381f81c91743f0759763ee528d635f9a5 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 16 Aug 2017 00:17:07 +0900 Subject: [PATCH] examples/runes: Trim the text if it has too many lines --- examples/runes/main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/runes/main.go b/examples/runes/main.go index 030353af3..95cfd63ff 100644 --- a/examples/runes/main.go +++ b/examples/runes/main.go @@ -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() {