steel-lord/eventhandling.go
2019-06-27 20:29:15 -07:00

23 lines
429 B
Go

package main
import (
"github.com/kettek/goro"
)
// handleKeyEvent converts a KeyEvent into a corresponding Action.
func handleKeyEvent(ev goro.EventKey) Action {
switch ev.Key {
case goro.KeyUp:
return ActionMove{Y: -1}
case goro.KeyDown:
return ActionMove{Y: 1}
case goro.KeyRight:
return ActionMove{X: 1}
case goro.KeyLeft:
return ActionMove{X: -1}
case goro.KeyEscape:
return ActionQuit{}
}
return nil
}