Minor style fixes (early returns) (#1792)

This commit is contained in:
Trevor Slocum 2021-09-03 08:22:37 -07:00 committed by GitHub
parent e5c051a437
commit ffe9a6f72d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 9 deletions

View File

@ -114,12 +114,11 @@ func vecToDir(dx, dy int) (Dir, bool) {
return DirUp, true return DirUp, true
} }
return DirDown, true return DirDown, true
} else { }
if dx < 0 { if dx < 0 {
return DirLeft, true return DirLeft, true
} }
return DirRight, true return DirRight, true
}
} }
// Update updates the current input states. // Update updates the current input states.

View File

@ -211,9 +211,8 @@ func (c *gamepadConfig) IsButtonPressed(b virtualGamepadButton) bool {
v := ebiten.GamepadAxisValue(c.gamepadID, a.id) v := ebiten.GamepadAxisValue(c.gamepadID, a.id)
if a.positive { if a.positive {
return axisThreshold <= v && v <= 1.0 return axisThreshold <= v && v <= 1.0
} else {
return -1.0 <= v && v <= -axisThreshold
} }
return -1.0 <= v && v <= -axisThreshold
} }
return false return false
} }
@ -254,9 +253,8 @@ func (c *gamepadConfig) ButtonName(b virtualGamepadButton) string {
if ok { if ok {
if a.positive { if a.positive {
return fmt.Sprintf("Axis %d+", a.id) return fmt.Sprintf("Axis %d+", a.id)
} else {
return fmt.Sprintf("Axis %d-", a.id)
} }
return fmt.Sprintf("Axis %d-", a.id)
} }
return "" return ""