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