mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
examples/blocks: Refactoring
This commit is contained in:
parent
581fbc4406
commit
12c224c14a
@ -29,7 +29,7 @@ var gamepadAbstractButtons = []abstractButton{
|
|||||||
type Input struct {
|
type Input struct {
|
||||||
keyStates [256]int
|
keyStates [256]int
|
||||||
gamepadButtonStates [256]int
|
gamepadButtonStates [256]int
|
||||||
gamepadAbstractButtonStates [16]int
|
gamepadAbstractButtonStates map[abstractButton]int
|
||||||
gamepadConfig gamepadConfig
|
gamepadConfig gamepadConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,6 +42,9 @@ func (i *Input) StateForGamepadButton(b ebiten.GamepadButton) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *Input) stateForGamepadAbstractButton(b abstractButton) int {
|
func (i *Input) stateForGamepadAbstractButton(b abstractButton) int {
|
||||||
|
if i.gamepadAbstractButtonStates == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
return i.gamepadAbstractButtonStates[b]
|
return i.gamepadAbstractButtonStates[b]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,6 +66,9 @@ func (i *Input) Update() {
|
|||||||
i.gamepadButtonStates[b]++
|
i.gamepadButtonStates[b]++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if i.gamepadAbstractButtonStates == nil {
|
||||||
|
i.gamepadAbstractButtonStates = map[abstractButton]int{}
|
||||||
|
}
|
||||||
for _, b := range gamepadAbstractButtons {
|
for _, b := range gamepadAbstractButtons {
|
||||||
if !i.gamepadConfig.IsButtonPressed(gamepadID, b) {
|
if !i.gamepadConfig.IsButtonPressed(gamepadID, b) {
|
||||||
i.gamepadAbstractButtonStates[b] = 0
|
i.gamepadAbstractButtonStates[b] = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user