constructor stucture fixes

This commit is contained in:
2023-06-30 17:44:19 +02:00
parent dec8ad2fe0
commit 0ed8cfb839
6 changed files with 63 additions and 53 deletions

View File

@@ -19,12 +19,12 @@ type KeyMap struct {
Action3 ebiten.Key
}
type Keyboard struct {
type Controller struct {
PressedKey ebiten.Key
KeyMap KeyMap
}
func (k *Keyboard) Watch() {
func (k *Controller) Watch() {
values := reflect.ValueOf(k.KeyMap)
for i := 0; i < values.NumField(); i++ {
@@ -36,34 +36,34 @@ func (k *Keyboard) Watch() {
}
}
func (k *Keyboard) UpPressed() bool {
func (k *Controller) UpPressed() bool {
return k.PressedKey == k.KeyMap.Up
}
func (k *Keyboard) DownPressed() bool {
func (k *Controller) DownPressed() bool {
return k.PressedKey == k.KeyMap.Down
}
func (k *Keyboard) RightPressed() bool {
func (k *Controller) RightPressed() bool {
return k.PressedKey == k.KeyMap.Right
}
func (k *Keyboard) LeftPressed() bool {
func (k *Controller) LeftPressed() bool {
return k.PressedKey == k.KeyMap.Left
}
func (k *Keyboard) Action0Pressed() bool {
func (k *Controller) Action0Pressed() bool {
return k.PressedKey == k.KeyMap.Action0
}
func (k *Keyboard) Action1Pressed() bool {
func (k *Controller) Action1Pressed() bool {
return k.PressedKey == k.KeyMap.Action1
}
func (k *Keyboard) Action2Pressed() bool {
func (k *Controller) Action2Pressed() bool {
return k.PressedKey == k.KeyMap.Action2
}
func (k *Keyboard) Action3Pressed() bool {
func (k *Controller) Action3Pressed() bool {
return k.PressedKey == k.KeyMap.Action3
}