Documentation
¶
Index ¶
- Variables
- func Capture(screen image.Image)
- func CursorPosition() (x, y int)
- func GetCustomCommand(name string) func(CommandContext)
- func IsKeyJustPressed(key ebiten.Key) bool
- func IsKeyJustReleased(key ebiten.Key) bool
- func IsKeyPressed(key ebiten.Key) bool
- func IsMouseButtonJustPressed(button ebiten.MouseButton) bool
- func IsMouseButtonJustReleased(button ebiten.MouseButton) bool
- func IsMouseButtonPressed(button ebiten.MouseButton) bool
- func KeyPressDuration(key ebiten.Key) int
- func ListCustomCommands() []string
- func MouseButtonPressDuration(button ebiten.MouseButton) int
- func Register(name string, handler func(CommandContext))
- func RegisterStateExporter(name string, root any)
- func SetMode(mode Mode)
- func Unregister(name string) bool
- func Update() bool
- func Wheel() (x, y float64)
- type CommandContext
- type Mode
- type StateQueryPath
Constants ¶
This section is empty.
Variables ¶
var ErrPathNotFound = errors.New("path not found")
ErrPathNotFound is returned when a state query path cannot be resolved. This occurs when:
- The path references a non-existent field
- An array index is out of bounds
- A map key does not exist
- The path traverses a nil pointer
var StateExporterPathPrefix = ".state."
Functions ¶
func Capture ¶
Capture processes screenshots for injection. Panic when using the patch integration method.
func CursorPosition ¶
func CursorPosition() (x, y int)
CursorPosition wraps ebiten.CursorPosition, respecting the current mode. Panic when using the patch integration method.
func GetCustomCommand ¶ added in v0.3.0
func GetCustomCommand(name string) func(CommandContext)
GetCustomCommand returns the handler for a custom command. Returns nil if the command is not registered. This is primarily for internal use.
func IsKeyJustPressed ¶ added in v0.2.0
IsKeyJustPressed wraps inpututil.IsKeyJustPressed, respecting the current mode. Panic when using the patch integration method.
func IsKeyJustReleased ¶ added in v0.2.0
IsKeyJustReleased wraps inpututil.IsKeyJustReleased, respecting the current mode. Panic when using the patch integration method.
func IsKeyPressed ¶
IsKeyPressed wraps ebiten.IsKeyPressed, respecting the current mode. Panic when using the patch integration method.
func IsMouseButtonJustPressed ¶ added in v0.2.0
func IsMouseButtonJustPressed(button ebiten.MouseButton) bool
IsMouseButtonJustPressed wraps inpututil.IsMouseButtonJustPressed, respecting the current mode. Panic when using the patch integration method.
func IsMouseButtonJustReleased ¶ added in v0.2.0
func IsMouseButtonJustReleased(button ebiten.MouseButton) bool
IsMouseButtonJustReleased wraps inpututil.IsMouseButtonJustReleased, respecting the current mode. Panic when using the patch integration method.
func IsMouseButtonPressed ¶
func IsMouseButtonPressed(button ebiten.MouseButton) bool
IsMouseButtonPressed wraps ebiten.IsMouseButtonPressed, respecting the current mode. Panic when using the patch integration method.
func KeyPressDuration ¶ added in v0.2.0
KeyPressDuration wraps inpututil.KeyPressDuration, respecting the current mode. Panic when using the patch integration method.
func ListCustomCommands ¶ added in v0.3.0
func ListCustomCommands() []string
ListCustomCommands returns a list of all registered custom command names.
func MouseButtonPressDuration ¶ added in v0.2.0
func MouseButtonPressDuration(button ebiten.MouseButton) int
MouseButtonPressDuration wraps inpututil.MouseButtonPressDuration, respecting the current mode. Panic when using the patch integration method.
func Register ¶ added in v0.3.0
func Register(name string, handler func(CommandContext))
Register registers a custom command handler. The name must be unique; registering a duplicate name will override. The handler receives a CommandContext containing the request and a Respond method.
Example:
autoebiten.Register("getPlayerInfo", func(ctx autoebiten.CommandContext) {
info := getPlayerInfo() // user-defined function
ctx.Respond(fmt.Sprintf("Health: %d, Mana: %d", info.Health, info.Mana))
})
func RegisterStateExporter ¶ added in v0.5.0
RegisterStateExporter registers a custom command that exposes game state via reflection-based path queries. The path uses dot notation:
- "Player.X" - access struct field
- "Inventory.0.Name" - access array/slice index
- "Skills.Sword" - access map key
Game state can be retrieved by calling the testkit.StateQuery function ¶
In game:
type Player struct {
X float64
Y float64
Health int
}
type Game struct {
Player Player
}
func main() {
var g := Game{Player: Player{X: 0, Y: 0, Health: 100}}
RegisterStateExporter("mystate", &g)
}
In test:
func TestPlayerMovement(t *testing.T) {
game := testkit.Launch(t, "./mygame")
defer game.Shutdown()
game.HoldKey(ebiten.KeyD, 10)
x, _ := game.StateQuery("mystate", "Player.X")
assert.Equal(t, 10, x)
}
func Unregister ¶ added in v0.3.0
Unregister removes a custom command handler. Returns true if the command was found and removed, false otherwise.
Types ¶
type CommandContext ¶ added in v0.3.0
CommandContext provides context for custom command execution. It contains the request data and a method to send the response.
type Mode ¶
type Mode int
Mode represents the input handling mode.
const ( // InjectionOnly mode returns only injected input results. InjectionOnly Mode = iota // InjectionFallback mode returns injected results if available, // otherwise falls back to ebiten's native input handling. InjectionFallback // Passthrough mode only uses ebiten's native input handling. Passthrough )
type StateQueryPath ¶ added in v0.5.0
type StateQueryPath struct {
// contains filtered or unexported fields
}
StateQueryPath represents a parsed state query path. It can be used for repeated queries against different roots.
func ParseStateQueryPath ¶ added in v0.5.0
func ParseStateQueryPath(path string) (*StateQueryPath, error)
ParseStateQueryPath parses a state query path for reuse.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package autoui provides EbitenUI automation helpers for autoebiten.
|
Package autoui provides EbitenUI automation helpers for autoebiten. |
|
internal
Package internal provides helper functions for autoui package.
|
Package internal provides helper functions for autoui package. |
|
cmd
|
|
|
autoebiten
command
|
|
|
docgen
command
internal/docgen/cmd/generate.go
|
internal/docgen/cmd/generate.go |
|
examples
|
|
|
autoui
command
Example demonstrating autoui integration with autoebiten.
|
Example demonstrating autoui integration with autoebiten. |
|
crash_diagnostic
command
|
|
|
custom_commands
command
|
|
|
simple
command
|
|
|
state_exporter
Package state_exporter provides a sample game with state exporting capabilities.
|
Package state_exporter provides a sample game with state exporting capabilities. |
|
state_exporter/cmd
command
|
|
|
internal
|
|
|
custom
Package custom provides custom command registration and execution.
|
Package custom provides custom command registration and execution. |
|
Package testkit provides a testing framework for autoebiten games.
|
Package testkit provides a testing framework for autoebiten games. |
|
internal/testgames/custom
command
|
|
|
internal/testgames/simple
command
|
|
|
internal/testgames/stateful
command
|