mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
example/blocks: Add comments
This commit is contained in:
parent
4e432ca816
commit
507fc7cbbb
@ -124,6 +124,8 @@ func (c *gamepadConfig) Scan(gamepadID int, b virtualGamepadButton) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsButtonPressed returns a boolean value indicating whether
|
||||
// the given virtual button b is pressed.
|
||||
func (c *gamepadConfig) IsButtonPressed(b virtualGamepadButton) bool {
|
||||
c.initializeIfNeeded()
|
||||
|
||||
@ -131,6 +133,7 @@ func (c *gamepadConfig) IsButtonPressed(b virtualGamepadButton) bool {
|
||||
if ok {
|
||||
return ebiten.IsGamepadButtonPressed(0, bb)
|
||||
}
|
||||
|
||||
a, ok := c.axes[b]
|
||||
if ok {
|
||||
v := ebiten.GamepadAxis(0, a.id)
|
||||
@ -143,7 +146,7 @@ func (c *gamepadConfig) IsButtonPressed(b virtualGamepadButton) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Name returns the button's name.
|
||||
// Name returns the pysical button's name for the given virtual button.
|
||||
func (c *gamepadConfig) ButtonName(b virtualGamepadButton) string {
|
||||
c.initializeIfNeeded()
|
||||
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
)
|
||||
|
||||
// Input manages the input state including gamepads and keyboards.
|
||||
type Input struct {
|
||||
keyStates map[ebiten.Key]int
|
||||
anyGamepadButtonPressed bool
|
||||
@ -27,6 +28,7 @@ type Input struct {
|
||||
gamepadConfig gamepadConfig
|
||||
}
|
||||
|
||||
// StateForKey returns time length indicating how long the key is pressed.
|
||||
func (i *Input) StateForKey(key ebiten.Key) int {
|
||||
if i.keyStates == nil {
|
||||
return 0
|
||||
@ -34,6 +36,8 @@ func (i *Input) StateForKey(key ebiten.Key) int {
|
||||
return i.keyStates[key]
|
||||
}
|
||||
|
||||
// IsAnyGamepadButtonPressed returns a boolean value indicating
|
||||
// whether any gamepad button is pressed.
|
||||
func (i *Input) IsAnyGamepadButtonPressed() bool {
|
||||
return i.anyGamepadButtonPressed
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user