From 8ef4e4ea3ad645b51e2855f0d2efca9c9782c6d9 Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Sun, 29 Dec 2019 10:15:32 +0100 Subject: [PATCH] Changed movement animation again. Movement starts on KeyDownEvent instead of KeyCharEvent. --- alui/menu.go | 11 +++++++---- cmd/krampus19/entity.go | 2 +- cmd/krampus19/playlevel.go | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/alui/menu.go b/alui/menu.go index f4c29a7..37a4587 100644 --- a/alui/menu.go +++ b/alui/menu.go @@ -48,6 +48,13 @@ func (m *Menu) Handle(e allg5.Event) { } switch e := e.(type) { + case *allg5.KeyDownEvent: + switch e.KeyCode { + case allg5.KeyEscape: + if onEscape := m.OnEscape; onEscape != nil { + onEscape() + } + } case *allg5.KeyCharEvent: switch e.KeyCode { case allg5.KeyDown: @@ -58,10 +65,6 @@ func (m *Menu) Handle(e allg5.Event) { if onClick := m.buttons[m.active].OnClick; onClick != nil { onClick() } - case allg5.KeyEscape: - if onEscape := m.OnEscape; onEscape != nil { - onEscape() - } } case *allg5.MouseMoveEvent: for i, btn := range m.buttons { diff --git a/cmd/krampus19/entity.go b/cmd/krampus19/entity.go index 818e2cc..e13eda0 100644 --- a/cmd/krampus19/entity.go +++ b/cmd/krampus19/entity.go @@ -29,7 +29,7 @@ func newEntityMoveAnimation(e *entity, to geom.Point) *entityMoveAnimation { } func (a *entityMoveAnimation) Animate(start, now time.Duration) bool { - const duration = 270 * time.Millisecond + const duration = 210 * time.Millisecond progress := float32((now-start)*1000/duration) * .001 from, to := a.from.ToF32(), a.to.ToF32() diff --git a/cmd/krampus19/playlevel.go b/cmd/krampus19/playlevel.go index 1f8387e..a85f158 100644 --- a/cmd/krampus19/playlevel.go +++ b/cmd/krampus19/playlevel.go @@ -141,7 +141,7 @@ func (l *playLevel) Handle(e allg5.Event) { l.end.Handle(e) default: switch e := e.(type) { - case *allg5.KeyCharEvent: + case *allg5.KeyDownEvent: switch e.KeyCode { case allg5.KeyEscape: l.showMenu = true