spx

package module
v2.0.0-pre.46 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2026 License: Apache-2.0 Imports: 41 Imported by: 1

README

spx - A Scratch Compatible 2D Game Engine

Build Status Go Report Card GitHub release Language Scratch diff

How to build

How to run games powered by XGo spx engine?

  • Install go (version == 1.21.3)
  • Install python (version >= 3.8)
  • Install scons (version == 4.7.0) (for engine development, optional)
  • Install make
  • Install mingw-w64 (Windows only)
  • Add the Go environment's bin directory to the system PATH.
    export PATH=$PATH:$GOPATH/bin
  • Download XGo and build it. See https://github.com/goplus/xgo#how-to-build.
  • Download spx and build it.
    # please use Git Bash to run the following commands in windows platform
    git clone https://github.com/goplus/spx.git
    cd spx
    git checkout dev
    make setup
    
    # run the demo
    spx run -path tutorial/00-Hello
    
  • Build a game and run.
    • cd game-root-dir
    • xgo run .

Games powered by spx

Tutorials

tutorial/01-Weather

Screen Shot1 Screen Shot2

Through this example you can learn how to listen events and do somethings.

Here are some codes in Kai.spx:

onStart => {
	say "Where do you come from?", 2
	broadcast "1"
}

onMsg "2", => {
	say "What's the climate like in your country?", 3
	broadcast "3"
}

onMsg "4", => {
	say "Which seasons do you like best?", 3
	broadcast "5"
}

We call onStart and onMsg to listen events. onStart is called when the program is started. And onMsg is called when someone calls broadcast to broadcast a message.

When the program starts, Kai says Where do you come from?, and then broadcasts the message 1. Who will recieve this message? Let's see codes in Jaime.spx:

onMsg "1", => {
	say "I come from England.", 2
	broadcast "2"
}

onMsg "3", => {
	say "It's mild, but it's not always pleasant.", 4
	# ...
	broadcast "4"
}

Yes, Jaime recieves the message 1 and says I come from England.. Then he broadcasts the message 2. Kai recieves it and says What's the climate like in your country?.

The following procedures are very similar. In this way you can implement dialogues between multiple actors.

tutorial/02-Dragon

Screen Shot1

Through this example you can learn how to define variables and show them on the stage.

Here are all the codes of Dragon:

var (
	score int
)

onStart => {
	score = 0
	for {
		turn rand(-30, 30)
		step 5
		if touching("Shark") {
			score++
			play chomp, true
			step -100
		}
	}
}

We define a variable named score for Dragon. After the program starts, it moves randomly. And every time it touches Shark, it gains one score.

How to show the score on the stage? You don't need write code, just add a stageMonitor object into assets/index.json:

{
  "zorder": [
    {
      "type": "monitor",
      "name": "dragon",
      "size": 1,
      "target": "Dragon",
      "val": "getVar:score",
      "color": 15629590,
      "label": "score",
      "mode": 1,
      "x": 5,
      "y": 5,
      "visible": true
    }
  ]
}
tutorial/03-Clone

Screen Shot1

Through this example you can learn:

  • Clone sprites and destory them.
  • Distinguish between sprite variables and shared variables that can access by all sprites.

Here are some codes in Calf.spx:

var (
	id int
)

onClick => {
	clone
}

onCloned => {
	gid++
	...
}

When we click the sprite Calf, it receives an onClick event. Then it calls clone to clone itself. And after cloning, the new Calf sprite will receive an onCloned event.

In onCloned event, the new Calf sprite uses a variable named gid. It doesn't define in Calf.spx, but in main.spx.

Here are all the codes of main.spx:

var (
	Arrow Arrow
	Calf  Calf
	gid   int
)

run "res", {Title: "Clone and Destory (by XGo)"}

All these three variables in main.spx are shared by all sprites. Arrow and Calf are sprites that exist in this project. gid means global id. It is used to allocate id for all cloned Calf sprites.

Let's back to Calf.spx to see the full codes of onCloned:

onCloned => {
	gid++
	id = gid
	step 50
	say id, 0.5
}

It increases gid value and assigns it to sprite id. This makes all these Calf sprites have different id. Then the cloned Calf moves forward 50 steps and says id of itself.

Why these Calf sprites need different id? Because we want destory one of them by its id.

Here are all the codes in Arrow.spx:

onClick => {
	broadcastAndWait "undo"
	gid--
}

When we click Arrow, it broadcasts an "undo" message (NOTE: We pass the second parameter true to broadcast to indicate we wait all sprites to finish processing this message).

All Calf sprites receive this message, but only the last cloned sprite finds its id is equal to gid then destroys itself. Here are the related codes in Calf.spx:

onMsg "undo", => {
	if id == gid {
		destroy
	}
}
tutorial/04-Bullet

Screen Shot1

Through this example you can learn:

  • How to keep a sprite following mouse position.
  • How to fire bullets.

It's simple to keep a sprite following mouse position. Here are some related codes in MyAircraft.spx:

onStart => {
	for {
		# ...
		setXYpos mouseX, mouseY
	}
}

Yes, we just need to call setXYpos mouseX, mouseY to follow mouse position.

But how to fire bullets? Let's see all codes of MyAircraft.spx:

onStart => {
	for {
		wait 0.1
		Bullet.clone
		setXYpos mouseX, mouseY
	}
}

In this example, MyAircraft fires bullets every 0.1 seconds. It just calls Bullet.clone to create a new bullet. All the rest things are the responsibility of Bullet.

Here are all the codes in Bullet.spx:

onCloned => {
	setXYpos MyAircraft.xpos, MyAircraft.ypos+5
	show
	for {
		wait 0.04
		changeYpos 10
		if touching(Edge) {
			destroy
		}
	}
}

When a Bullet is cloned, it calls setXYpos MyAircraft.xpos, MyAircraft.ypos+5 to follow MyAircraft's position and shows itself (the default state of a Bullet is hidden). Then the Bullet moves forward every 0.04 seconds and this is why we see the Bullet is flying.

At last, when the Bullet touches screen Edge or any enemy (in this example we don't have enemies), it destroys itself.

These are all things about firing bullets.

Documentation

Index

Constants

View Source
const (
	GopPackage = true
	Gop_sched  = "Sched,SchedNow"
)
View Source
const (
	DbgFlagLoad dbgFlags = 1 << iota
	DbgFlagInstr
	DbgFlagEvent
	DbgFlagPerf
	DbgFlagAll = DbgFlagLoad | DbgFlagInstr | DbgFlagEvent | DbgFlagPerf
)
View Source
const (
	MOUSE_BUTTON_LEFT   int64 = 1
	MOUSE_BUTTON_RIGHT  int64 = 2
	MOUSE_BUTTON_MIDDLE int64 = 3
)
View Source
const (
	Prev switchAction = -1
	Next switchAction = 1
)
View Source
const (
	Front layerAction = -1
	Back  layerAction = 1
)
View Source
const (
	Forward  dirAction = -1
	Backward dirAction = 1
)
View Source
const (
	Mouse      specialObj = -5
	Edge       specialObj = touchingAllEdges
	EdgeLeft   specialObj = touchingScreenLeft
	EdgeTop    specialObj = touchingScreenTop
	EdgeRight  specialObj = touchingScreenRight
	EdgeBottom specialObj = touchingScreenBottom
)
View Source
const (
	StateDie   string = "die"
	StateTurn  string = "turn"
	StateGlide string = "glide"
	StateStep  string = "step"
)
View Source
const (
	AnimChannelFrame string = "@frame"
	AnimChannelTurn  string = "@turn"
	AnimChannelGlide string = "@glide"
	AnimChannelMove  string = "@move"
)
View Source
const (
	RectCollider      ColliderShapeType = ColliderShapeType(physicsColliderRect)
	CircleCollider    ColliderShapeType = ColliderShapeType(physicsColliderCircle)
	CapsuleCollider   ColliderShapeType = ColliderShapeType(physicsColliderCapsule)
	PolygonCollider   ColliderShapeType = ColliderShapeType(physicsColliderPolygon)
	TriggerExtraPixel float64           = 2.0
)

Variables

This section is empty.

Functions

func Exit__0

func Exit__0(code int)

Exit__0 exits the program with the specified exit code.

func Exit__1

func Exit__1()

Exit__1 exits the program with exit code 0.

func Forever

func Forever(call func())

Forever executes a function indefinitely

func Iround

func Iround(v float64) int

Iround returns an integer value, while math.Round returns a float value.

func Rand__0

func Rand__0(from, to int) float64

Rand__0 returns a random integer between from and to (inclusive).

func Rand__1

func Rand__1(from, to float64) float64

Rand__1 returns a random float64 between from and to.

func Repeat

func Repeat(loopCount int, call func())

Repeat executes a function for a specified number of times

func RepeatUntil

func RepeatUntil(condition func() bool, call func())

RepeatUntil executes a function until a condition is met

func Sched

func Sched() int

Sched performs scheduling with timeout check

func SchedNow

func SchedNow() int

SchedNow performs immediate scheduling without timeout check

func SetDebug

func SetDebug(flags dbgFlags)

SetDebug sets debug flags for the game

func WaitUntil

func WaitUntil(condition func() bool)

WaitUntil waits until a condition is met

func XGot_Game_Main

func XGot_Game_Main(game Gamer, sprites ...Sprite)

XGot_Game_Main is required by XGo compiler as the entry of a .gmx project.

func XGot_Game_Reload

func XGot_Game_Reload(game Gamer, index any) (err error)

XGot_Game_Reload reloads the game with new configuration

func XGot_Game_Run

func XGot_Game_Run(game Gamer, resource any, gameConf ...*Config)

XGot_Game_Run runs the game using the builder pattern

func XGot_Game_XGox_GetWidget

func XGot_Game_XGox_GetWidget[T any](sg ShapeGetter, name WidgetName) *T

GetWidget returns the widget instance (in given type) with given name. It panics if not found.

func XGot_SpriteImpl_Clone__0

func XGot_SpriteImpl_Clone__0(sprite Sprite)

func XGot_SpriteImpl_Clone__1

func XGot_SpriteImpl_Clone__1(sprite Sprite, data any)

Types

type BackdropName

type BackdropName = string

type Camera

type Camera interface {
	ViewportRect() (float64, float64, float64, float64)
	SetZoom(scale float64)
	Zoom() float64
	Xpos() float64
	Ypos() float64
	SetXYpos(x float64, y float64)
	ChangeXYpos(x float64, y float64)
	Follow__0(sprite Sprite)
	Follow__1(sprite SpriteName)
}

type ColliderShapeType

type ColliderShapeType = int64

type Color

type Color struct {
	// contains filtered or unexported fields
}

Color represents an RGBA color.

func HSB

func HSB(h, s, b float64) Color

HSB creates a color from HSB values. h, s, b in range [0, 100], just like Scratch

func HSBA

func HSBA(h, s, b, a float64) Color

HSBA creates a color from HSBA values. h, s, b, a in range [0, 100], just like Scratch

type Config

type Config struct {
	Title              string `json:"title,omitempty"`
	Width              int    `json:"width,omitempty"`
	Height             int    `json:"height,omitempty"`
	KeyDuration        int    `json:"keyDuration,omitempty"`
	ScreenshotKey      string `json:"screenshotKey,omitempty"` // screenshot image capture key
	EventQueuePolicy   string `json:"eventQueuePolicy,omitempty"`
	Index              any    `json:"-"` // where is index.json, can be file (string) or io.Reader
	DontParseFlags     bool   `json:"-"`
	FullScreen         bool   `json:"fullScreen,omitempty"`
	DontRunOnUnfocused bool   `json:"pauseOnUnfocused,omitempty"`
}

type DecoratorJSON

type DecoratorJSON struct {
	Version    int                `json:"version"`
	Decorators []tm.DecoratorNode `json:"decorators"`
}

DecoratorJSON represents the structure of decorator.json file (new format).

type Direction

type Direction = float64

Direction represents the heading direction in degrees.

const (
	Right Direction = 90
	Left  Direction = -90
	Up    Direction = 0
	Down  Direction = 180
)

type EffectKind

type EffectKind int
const (
	ColorEffect EffectKind = iota
	FishEyeEffect
	WhirlEffect
	PixelateEffect
	MosaicEffect
	BrightnessEffect
	GhostEffect
)

func (EffectKind) String

func (kind EffectKind) String() string

type Game

type Game struct {
	Camera Camera
	// contains filtered or unexported fields
}

Game represents the main game instance with all core systems

func (*Game) Answer

func (p *Game) Answer() string

func (*Game) Ask

func (p *Game) Ask(msg any)

func (*Game) BackdropIndex

func (p *Game) BackdropIndex() int

func (*Game) BackdropName

func (p *Game) BackdropName() string

func (*Game) BroadcastAndWait__0

func (p *Game) BroadcastAndWait__0(msg string)

func (*Game) BroadcastAndWait__1

func (p *Game) BroadcastAndWait__1(msg string, data any)

func (*Game) Broadcast__0

func (p *Game) Broadcast__0(msg string)

func (*Game) Broadcast__1

func (p *Game) Broadcast__1(msg string, data any)

func (*Game) ChangeGraphicEffect

func (p *Game) ChangeGraphicEffect(kind EffectKind, delta float64)

func (*Game) ChangeSoundEffect

func (p *Game) ChangeSoundEffect(kind SoundEffectKind, delta float64)

func (*Game) ChangeVolume

func (p *Game) ChangeVolume(delta float64)

func (*Game) ClearGraphicEffects

func (p *Game) ClearGraphicEffects()

func (*Game) ClearSoundEffects

func (p *Game) ClearSoundEffects()

func (*Game) DebugDrawCircle

func (p *Game) DebugDrawCircle(posX, posY, radius float64, color Color)

DebugDrawCircle draws a debug circle

func (*Game) DebugDrawLine

func (p *Game) DebugDrawLine(fromX, fromY, toX, toY float64, color Color)

DebugDrawLine draws a debug line

func (*Game) DebugDrawLines

func (p *Game) DebugDrawLines(points []float64, color Color)

DebugDrawLines draws multiple debug lines

func (*Game) DebugDrawRect

func (p *Game) DebugDrawRect(posX, posY, width, height float64, color Color)

DebugDrawRect draws a debug rectangle

func (*Game) EraseAll

func (p *Game) EraseAll()

EraseAll erases all pen drawings.

func (*Game) EraseTile__0

func (p *Game) EraseTile__0(x, y float64)

EraseTile__0 erases a tile at the specified position using default layer.

func (*Game) EraseTile__1

func (p *Game) EraseTile__1(x, y float64, layerIndex int64)

EraseTile__1 erases a tile at the specified position on a specific layer.

func (*Game) FindPath__0

func (p *Game) FindPath__0(x_from, y_from, x_to, y_to float64) []float64

func (*Game) FindPath__1

func (p *Game) FindPath__1(x_from, y_from, x_to, y_to float64, with_debug bool) []float64

func (*Game) FindPath__2

func (p *Game) FindPath__2(x_from, y_from, x_to, y_to float64, with_debug, with_jump bool) []float64

func (*Game) GetSoundEffect

func (p *Game) GetSoundEffect(kind SoundEffectKind) float64

func (*Game) GetTile__0

func (p *Game) GetTile__0(x, y float64) string

GetTile__0 gets the tile texture path at the specified position using default layer.

func (*Game) GetTile__1

func (p *Game) GetTile__1(x, y float64, layerIndex int64) string

GetTile__1 gets the tile texture path at the specified position on a specific layer.

func (*Game) HideVar

func (p *Game) HideVar(name string)

func (*Game) IntersectCircle

func (p *Game) IntersectCircle(posX, posY, radius float64) []Sprite

IntersectCircle detects sprites intersecting with a circular area

func (*Game) IntersectRect

func (p *Game) IntersectRect(posX, posY, width, height float64) []Sprite

IntersectRect detects sprites intersecting with a rectangular area

func (*Game) KeyPressed

func (p *Game) KeyPressed(key Key) bool

func (*Game) LoadTilemap

func (p *Game) LoadTilemap(mapDir string)

LoadTilemap dynamically loads a tilemap from the specified path mapDir can be either:

  • A directory path (new format): "tilemaps/map1" -> uses C++ TileMapParser
  • A file path (old format): "tilemaps/map1.json" -> uses Go loader

This will unload any currently loaded tilemap before loading the new one.

func (*Game) Loudness

func (p *Game) Loudness() float64

func (*Game) MousePressed

func (p *Game) MousePressed() bool

func (*Game) MouseX

func (p *Game) MouseX() float64

func (*Game) MouseY

func (p *Game) MouseY() float64

func (*Game) OnAnyKey

func (p *Game) OnAnyKey(onKey func(key Key))

func (*Game) OnBackdrop__0

func (p *Game) OnBackdrop__0(onBackdrop func(name BackdropName))

func (*Game) OnBackdrop__1

func (p *Game) OnBackdrop__1(name BackdropName, onBackdrop func())

func (*Game) OnClick

func (p *Game) OnClick(onClick func())

func (*Game) OnEngineDestroy

func (p *Game) OnEngineDestroy()

func (*Game) OnEnginePause

func (p *Game) OnEnginePause(isPaused bool)

func (*Game) OnEngineRender

func (p *Game) OnEngineRender(delta float64)

func (*Game) OnEngineReset

func (p *Game) OnEngineReset()

func (*Game) OnEngineStart

func (p *Game) OnEngineStart()

func (*Game) OnEngineUpdate

func (p *Game) OnEngineUpdate(delta float64)

func (*Game) OnKey__0

func (p *Game) OnKey__0(key Key, onKey func())

func (*Game) OnKey__1

func (p *Game) OnKey__1(keys []Key, onKey func(Key))

func (*Game) OnKey__2

func (p *Game) OnKey__2(keys []Key, onKey func())

func (*Game) OnMsg__0

func (p *Game) OnMsg__0(onMsg func(msg string, data any))

func (*Game) OnMsg__1

func (p *Game) OnMsg__1(msg string, onMsg func())

func (*Game) OnStart

func (p *Game) OnStart(onStart func())

func (*Game) OnSwipe__0

func (p *Game) OnSwipe__0(direction Direction, onSwipe func())

func (*Game) OnTimer

func (p *Game) OnTimer(time float64, call func())

func (*Game) PausePlaying

func (p *Game) PausePlaying(name SoundName)

func (*Game) PlaceTile

func (p *Game) PlaceTile(x, y float64, texturePath string)

PlaceTile places a single tile at the specified position.

func (*Game) PlaceTiles__0

func (p *Game) PlaceTiles__0(positions []float64, texturePath string)

PlaceTiles__0 places multiple tiles at specified positions using default layer.

func (*Game) PlaceTiles__1

func (p *Game) PlaceTiles__1(positions []float64, texturePath string, layerIndex int64)

PlaceTiles__1 places multiple tiles at specified positions on a specific layer.

func (*Game) PlayAndWait

func (p *Game) PlayAndWait(name SoundName)

func (*Game) Play__0

func (p *Game) Play__0(name SoundName, loop bool)

func (*Game) Play__1

func (p *Game) Play__1(name SoundName)

func (*Game) Raycast__0

func (p *Game) Raycast__0(fromX, fromY, toX, toY float64, ignoreSprites []Sprite) (hit bool, sprite Sprite, hitX, hitY float64)

Raycast__0 performs a raycast, ignoring specified sprites

func (*Game) Raycast__1

func (p *Game) Raycast__1(fromX, fromY, toX, toY float64, ignoreSprite Sprite) (hit bool, sprite Sprite, hitX, hitY float64)

Raycast__1 performs a raycast, ignoring a single sprite

func (*Game) Raycast__2

func (p *Game) Raycast__2(fromX, fromY, toX, toY float64) (hit bool, sprite Sprite, hitX, hitY float64)

Raycast__2 performs a raycast without ignoring any sprites

func (*Game) ResetTimer

func (p *Game) ResetTimer()

func (*Game) ResumePlaying

func (p *Game) ResumePlaying(name SoundName)

func (*Game) SetBackdropAndWait__0

func (p *Game) SetBackdropAndWait__0(backdrop BackdropName)

func (*Game) SetBackdropAndWait__1

func (p *Game) SetBackdropAndWait__1(index float64)

func (*Game) SetBackdropAndWait__2

func (p *Game) SetBackdropAndWait__2(index int)

func (*Game) SetBackdropAndWait__3

func (p *Game) SetBackdropAndWait__3(action switchAction)

func (*Game) SetBackdrop__0

func (p *Game) SetBackdrop__0(backdrop BackdropName)

func (*Game) SetBackdrop__1

func (p *Game) SetBackdrop__1(index float64)

func (*Game) SetBackdrop__2

func (p *Game) SetBackdrop__2(index int)

func (*Game) SetBackdrop__3

func (p *Game) SetBackdrop__3(action switchAction)

func (*Game) SetGraphicEffect

func (p *Game) SetGraphicEffect(kind EffectKind, val float64)

func (*Game) SetSoundEffect

func (p *Game) SetSoundEffect(kind SoundEffectKind, value float64)

func (*Game) SetVolume

func (p *Game) SetVolume(volume float64)

func (*Game) SetWindowSize

func (p *Game) SetWindowSize(width int64, height int64)

SetWindowSize sets the window size to the specified width and height.

func (*Game) SetupPathFinder__0

func (p *Game) SetupPathFinder__0()

func (*Game) SetupPathFinder__1

func (p *Game) SetupPathFinder__1(x_grid_size, y_grid_size, x_cell_size, y_cell_size float64, with_jump, with_debug bool)

func (*Game) ShowVar

func (p *Game) ShowVar(name string)

func (*Game) Stop

func (p *Game) Stop(kind StopKind)

func (*Game) StopAllSounds

func (p *Game) StopAllSounds()

func (*Game) StopPlaying

func (p *Game) StopPlaying(name SoundName)

func (*Game) TilemapName

func (p *Game) TilemapName() string

TilemapName returns the name of the currently loaded tilemap. Returns empty string if no tilemap is loaded.

func (*Game) Timer

func (p *Game) Timer() float64

func (*Game) UnloadTilemap

func (p *Game) UnloadTilemap()

UnloadTilemap unloads the currently loaded tilemap and cleans up resources.

func (*Game) Username

func (p *Game) Username() string

func (*Game) Volume

func (p *Game) Volume() float64

func (*Game) Wait

func (p *Game) Wait(secs float64)

func (*Game) WaitNextFrame

func (p *Game) WaitNextFrame() float64

type Gamer

type Gamer interface {
	engine.IGame
	// contains filtered or unexported methods
}

type IEventSinks

type IEventSinks interface {
	OnAnyKey(onKey func(key Key))
	OnBackdrop__0(onBackdrop func(name BackdropName))
	OnBackdrop__1(name BackdropName, onBackdrop func())
	OnClick(onClick func())
	OnKey__0(key Key, onKey func())
	OnKey__1(keys []Key, onKey func(Key))
	OnKey__2(keys []Key, onKey func())
	OnMsg__0(onMsg func(msg string, data any))
	OnMsg__1(msg string, onMsg func())
	OnStart(onStart func())
	OnSwipe__0(direction Direction, onSwipe func())
	OnTimer(time float64, onTimer func())
	Stop(kind StopKind)
}

type Key

type Key = gdx.KeyCode
const (
	Key0            Key = gdx.Key0
	Key1            Key = gdx.Key1
	Key2            Key = gdx.Key2
	Key3            Key = gdx.Key3
	Key4            Key = gdx.Key4
	Key5            Key = gdx.Key5
	Key6            Key = gdx.Key6
	Key7            Key = gdx.Key7
	Key8            Key = gdx.Key8
	Key9            Key = gdx.Key9
	KeyA            Key = gdx.KeyA
	KeyB            Key = gdx.KeyB
	KeyC            Key = gdx.KeyC
	KeyD            Key = gdx.KeyD
	KeyE            Key = gdx.KeyE
	KeyF            Key = gdx.KeyF
	KeyG            Key = gdx.KeyG
	KeyH            Key = gdx.KeyH
	KeyI            Key = gdx.KeyI
	KeyJ            Key = gdx.KeyJ
	KeyK            Key = gdx.KeyK
	KeyL            Key = gdx.KeyL
	KeyM            Key = gdx.KeyM
	KeyN            Key = gdx.KeyN
	KeyO            Key = gdx.KeyO
	KeyP            Key = gdx.KeyP
	KeyQ            Key = gdx.KeyQ
	KeyR            Key = gdx.KeyR
	KeyS            Key = gdx.KeyS
	KeyT            Key = gdx.KeyT
	KeyU            Key = gdx.KeyU
	KeyV            Key = gdx.KeyV
	KeyW            Key = gdx.KeyW
	KeyX            Key = gdx.KeyX
	KeyY            Key = gdx.KeyY
	KeyZ            Key = gdx.KeyZ
	KeyApostrophe   Key = gdx.KeyApostrophe
	KeyBackslash    Key = gdx.KeyBackslash
	KeyBackspace    Key = gdx.KeyBackspace
	KeyCapsLock     Key = gdx.KeyCapsLock
	KeyComma        Key = gdx.KeyComma
	KeyDelete       Key = gdx.KeyDelete
	KeyDown         Key = gdx.KeyDown
	KeyEnd          Key = gdx.KeyEnd
	KeyEnter        Key = gdx.KeyEnter
	KeyEqual        Key = gdx.KeyEqual
	KeyEscape       Key = gdx.KeyEscape
	KeyF1           Key = gdx.KeyF1
	KeyF2           Key = gdx.KeyF2
	KeyF3           Key = gdx.KeyF3
	KeyF4           Key = gdx.KeyF4
	KeyF5           Key = gdx.KeyF5
	KeyF6           Key = gdx.KeyF6
	KeyF7           Key = gdx.KeyF7
	KeyF8           Key = gdx.KeyF8
	KeyF9           Key = gdx.KeyF9
	KeyF10          Key = gdx.KeyF10
	KeyF11          Key = gdx.KeyF11
	KeyF12          Key = gdx.KeyF12
	KeyGraveAccent  Key = gdx.KeyQuoteLeft
	KeyHome         Key = gdx.KeyHome
	KeyInsert       Key = gdx.KeyInsert
	KeyKP0          Key = gdx.KeyKP0
	KeyKP1          Key = gdx.KeyKP1
	KeyKP2          Key = gdx.KeyKP2
	KeyKP3          Key = gdx.KeyKP3
	KeyKP4          Key = gdx.KeyKP4
	KeyKP5          Key = gdx.KeyKP5
	KeyKP6          Key = gdx.KeyKP6
	KeyKP7          Key = gdx.KeyKP7
	KeyKP8          Key = gdx.KeyKP8
	KeyKP9          Key = gdx.KeyKP9
	KeyKPDecimal    Key = gdx.KeyKPPeriod
	KeyKPDivide     Key = gdx.KeyKPDivide
	KeyKPEnter      Key = gdx.KeyKPEnter
	KeyKPEqual      Key = gdx.KeyEqual
	KeyKPMultiply   Key = gdx.KeyKPMultiply
	KeyKPSubtract   Key = gdx.KeyKPSubtract
	KeyLeft         Key = gdx.KeyLeft
	KeyLeftBracket  Key = gdx.KeyBracketLeft
	KeyMenu         Key = gdx.KeyMenu
	KeyMinus        Key = gdx.KeyMinus
	KeyNumLock      Key = gdx.KeyNumLock
	KeyPageDown     Key = gdx.KeyPageDown
	KeyPageUp       Key = gdx.KeyPageUp
	KeyPause        Key = gdx.KeyPause
	KeyPeriod       Key = gdx.KeyPeriod
	KeyPrintScreen  Key = gdx.KeyPrint
	KeyRight        Key = gdx.KeyRight
	KeyRightBracket Key = gdx.KeyBracketRight
	KeyScrollLock   Key = gdx.KeyScrollLock
	KeySemicolon    Key = gdx.KeySemicolon
	KeySlash        Key = gdx.KeySlash
	KeySpace        Key = gdx.KeySpace
	KeyTab          Key = gdx.KeyTab
	KeyUp           Key = gdx.KeyUp
	KeyAlt          Key = gdx.KeyAlt
	KeyControl      Key = gdx.KeyCmdOrCtrl
	KeyShift        Key = gdx.KeyShift
	KeyMax          Key = -2
	KeyAny          Key = -1
)

func KeyFromString

func KeyFromString(key string) Key

KeyFromString converts a string to its corresponding KeyCode. It supports key names like "A", "Space", "Enter", "Left", etc. Returns KeyMax if the key name is not recognized.

type List

type List struct {
	// contains filtered or unexported fields
}

func NewList

func NewList(l ...obj) List

NewList creates a new List initialized with the given elements.

func (*List) Append

func (p *List) Append(v obj)

Append adds the element v to the end of the list.

func (*List) At

func (p *List) At(i Pos) Value

At returns the Value at the specified index.

func (*List) Clear

func (p *List) Clear()

Clear removes all elements from the list.

func (*List) Contains

func (p *List) Contains(v obj) bool

Contains returns true if the list contains the element v.

func (*List) Delete

func (p *List) Delete(i Pos)

Delete removes the element at the specified index.

func (*List) IndexOf

func (p *List) IndexOf(v obj) Pos

IndexOf returns the zero-based position of the first occurrence of v in the list. Returns Invalid (-1) if v is not found.

func (*List) Init

func (p *List) Init(data ...obj)

func (*List) InitFrom

func (p *List) InitFrom(src *List)

func (*List) Insert

func (p *List) Insert(i Pos, v obj)

Insert inserts the element v at the specified index i.

func (*List) Len

func (p *List) Len() int

func (*List) Set

func (p *List) Set(i Pos, v obj)

Set sets the element at the specified index i to v.

func (*List) String

func (p *List) String() string

type Monitor

type Monitor struct {
	// contains filtered or unexported fields
}

Monitor class.

func (*Monitor) ChangeSize

func (pself *Monitor) ChangeSize(delta float64)

func (*Monitor) ChangeXYpos

func (pself *Monitor) ChangeXYpos(dx float64, dy float64)

func (*Monitor) ChangeXpos

func (pself *Monitor) ChangeXpos(dx float64)

func (*Monitor) ChangeYpos

func (pself *Monitor) ChangeYpos(dy float64)

func (*Monitor) GetName

func (pself *Monitor) GetName() WidgetName

------------------------------------------------------------------------------------- IWidget

func (*Monitor) Hide

func (pself *Monitor) Hide()

func (*Monitor) SetSize

func (pself *Monitor) SetSize(size float64)

func (*Monitor) SetXYpos

func (pself *Monitor) SetXYpos(x float64, y float64)

func (*Monitor) SetXpos

func (pself *Monitor) SetXpos(x float64)

func (*Monitor) SetYpos

func (pself *Monitor) SetYpos(y float64)

func (*Monitor) Show

func (pself *Monitor) Show()

func (*Monitor) Size

func (pself *Monitor) Size() float64

func (*Monitor) Visible

func (pself *Monitor) Visible() bool

func (*Monitor) Xpos

func (pself *Monitor) Xpos() float64

func (*Monitor) Ypos

func (pself *Monitor) Ypos() float64

type PenColorParam

type PenColorParam int
const (
	PenHue PenColorParam = iota
	PenSaturation
	PenBrightness
	PenTransparency
)

type PhysicsMode

type PhysicsMode = int64
const (
	NoPhysics        PhysicsMode = 0 // Pure visual, no collision, best performance (current default) eg: decorators
	KinematicPhysics PhysicsMode = 1 // Code-controlled movement with collision detection eg: player
	DynamicPhysics   PhysicsMode = 2 // Affected by physics, automatic gravity and collision eg: items
	StaticPhysics    PhysicsMode = 3 // Static immovable, but has collision, affects other objects : eg: walls
)

type Pos

type Pos = int
const (
	Invalid Pos = -1
	Last    Pos = -2
	All         = -3 // Pos or StopKind
	Random  Pos = -4
)

type RotationStyle

type RotationStyle int

RotationStyle defines how a sprite rotates.

const (
	None RotationStyle = iota
	Normal
	LeftRight
)

type Shape

type Shape any

type ShapeGetter

type ShapeGetter interface {
	// contains filtered or unexported methods
}

type SoundEffectKind

type SoundEffectKind int
const (
	SoundPanEffect SoundEffectKind = iota
	SoundPitchEffect
)

type SoundName

type SoundName = string

type SpatialHash

type SpatialHash struct {
	// contains filtered or unexported fields
}

SpatialHash implements a simple spatial hash grid for broad-phase collision detection.

type Sprite

type Sprite interface {
	IEventSinks
	Shape

	// Core Methods
	Main()
	Name() string
	IsCloned() bool
	DeleteThisClone()
	Destroy()
	Die()
	DeltaTime() float64
	TimeSinceLevelLoad() float64

	// Visibility Methods
	Hide()
	Show()
	Visible() bool
	HideVar(name string)
	ShowVar(name string)

	// Position Methods
	Xpos() float64
	Ypos() float64
	SetXpos(x float64)
	SetYpos(y float64)
	SetXYpos(x, y float64)
	ChangeXpos(dx float64)
	ChangeYpos(dy float64)
	ChangeXYpos(dx, dy float64)

	// Movement Methods
	Step__0(step float64)
	Step__1(step float64, speed float64)
	Step__2(step float64, speed float64, animation SpriteAnimationName)
	StepTo__0(sprite Sprite)
	StepTo__1(sprite SpriteName)
	StepTo__2(x, y float64)
	StepTo__3(obj specialObj)
	StepTo__4(sprite Sprite, speed float64)
	StepTo__5(sprite SpriteName, speed float64)
	StepTo__6(x, y, speed float64)
	StepTo__7(obj specialObj, speed float64)
	StepTo__8(sprite Sprite, speed float64, animation SpriteAnimationName)
	StepTo__9(sprite SpriteName, speed float64, animation SpriteAnimationName)
	StepTo__a(x, y, speed float64, animation SpriteAnimationName)
	StepTo__b(obj specialObj, speed float64, animation SpriteAnimationName)
	Glide__0(x, y float64, secs float64)
	Glide__1(sprite Sprite, secs float64)
	Glide__2(sprite SpriteName, secs float64)
	Glide__3(obj specialObj, secs float64)
	Glide__4(pos Pos, secs float64)

	// Heading and Rotation Methods
	Heading() Direction
	SetHeading(dir Direction)
	ChangeHeading(dir Direction)
	SetRotationStyle(style RotationStyle)
	Turn__0(dir Direction)
	Turn__1(dir Direction, speed float64)
	Turn__2(dir Direction, speed float64, animation SpriteAnimationName)
	TurnTo__0(target Sprite)
	TurnTo__1(target SpriteName)
	TurnTo__2(dir Direction)
	TurnTo__3(target specialObj)
	TurnTo__4(target Sprite, speed float64)
	TurnTo__5(target SpriteName, speed float64)
	TurnTo__6(dir Direction, speed float64)
	TurnTo__7(target specialObj, speed float64)
	TurnTo__8(target Sprite, speed float64, animation SpriteAnimationName)
	TurnTo__9(target SpriteName, speed float64, animation SpriteAnimationName)
	TurnTo__a(dir Direction, speed float64, animation SpriteAnimationName)
	TurnTo__b(target specialObj, speed float64, animation SpriteAnimationName)
	BounceOffEdge()

	// Size Methods
	Size() float64
	SetSize(size float64)
	ChangeSize(delta float64)

	// Layer Methods
	SetLayer__0(layer layerAction)
	SetLayer__1(dir dirAction, delta int)

	// Costume Methods
	CostumeName() SpriteCostumeName
	CostumeIndex() int
	SetCostume__0(costume SpriteCostumeName)
	SetCostume__1(index float64)
	SetCostume__2(index int)
	SetCostume__3(action switchAction)

	// Animation Methods
	Animate__0(name SpriteAnimationName)
	Animate__1(name SpriteAnimationName, loop bool)
	AnimateAndWait(name SpriteAnimationName)
	StopAnimation(name SpriteAnimationName)

	// Graphic Effects Methods
	SetGraphicEffect(kind EffectKind, val float64)
	ChangeGraphicEffect(kind EffectKind, delta float64)
	ClearGraphicEffects()

	// Pen Methods
	PenDown()
	PenUp()
	SetPenColor__0(color Color)
	SetPenColor__1(kind PenColorParam, value float64)
	ChangePenColor(kind PenColorParam, delta float64)
	SetPenSize(size float64)
	ChangePenSize(delta float64)
	Stamp()

	// Distance and Detection Methods
	DistanceTo__0(sprite Sprite) float64
	DistanceTo__1(sprite SpriteName) float64
	DistanceTo__2(obj specialObj) float64
	DistanceTo__3(pos Pos) float64
	Touching__0(sprite SpriteName) bool
	Touching__1(sprite Sprite) bool
	Touching__2(obj specialObj) bool
	TouchingColor(color Color) bool

	// Communication Methods
	Say__0(msg any)
	Say__1(msg any, secs float64)
	Think__0(msg any)
	Think__1(msg any, secs float64)
	Ask(msg any)
	Quote__0(message string)
	Quote__1(message string, secs float64)
	Quote__2(message, description string)
	Quote__3(message, description string, secs float64)

	// Event Methods
	OnCloned__0(onCloned func(data any))
	OnCloned__1(onCloned func())
	OnTouchStart__0(sprite SpriteName, onTouchStart func(Sprite))
	OnTouchStart__1(sprite SpriteName, onTouchStart func())
	OnTouchStart__2(sprites []SpriteName, onTouchStart func(Sprite))
	OnTouchStart__3(sprites []SpriteName, onTouchStart func())

	// Sound Methods
	Volume() float64
	SetVolume(volume float64)
	ChangeVolume(delta float64)
	GetSoundEffect(kind SoundEffectKind) float64
	SetSoundEffect(kind SoundEffectKind, value float64)
	ChangeSoundEffect(kind SoundEffectKind, delta float64)
	Play__0(name SoundName, loop bool)
	Play__1(name SoundName)
	PlayAndWait(name SoundName)
	PausePlaying(name SoundName)
	ResumePlaying(name SoundName)
	StopPlaying(name SoundName)

	// Physics Methods
	SetPhysicsMode(mode PhysicsMode)
	PhysicsMode() PhysicsMode
	SetVelocity(velocityX, velocityY float64)
	Velocity() (velocityX, velocityY float64)
	SetGravity(gravity float64)
	Gravity() float64
	AddImpulse(impulseX, impulseY float64)
	IsOnFloor() bool

	// Collider Methods
	SetColliderShape(isTrigger bool, ctype ColliderShapeType, params []float64) error
	ColliderShape(isTrigger bool) (ColliderShapeType, []float64)
	SetColliderPivot(isTrigger bool, offsetX, offsetY float64)
	ColliderPivot(isTrigger bool) (offsetX, offsetY float64)

	// Collision Methods
	SetCollisionLayer(layer int64)
	SetCollisionMask(mask int64)
	SetCollisionEnabled(enabled bool)
	CollisionLayer() int64
	CollisionMask() int64
	CollisionEnabled() bool

	// Trigger Methods
	SetTriggerEnabled(trigger bool)
	SetTriggerLayer(layer int64)
	SetTriggerMask(mask int64)
	TriggerLayer() int64
	TriggerMask() int64
	TriggerEnabled() bool
}

Sprite defines the interface for all sprite objects in the game

type SpriteAABB

type SpriteAABB struct {
	// contains filtered or unexported fields
}

SpriteAABB represents an axis-aligned bounding box for a sprite.

type SpriteAnimationName

type SpriteAnimationName = string

Type aliases for sprite-related identifiers.

type SpriteCostumeName

type SpriteCostumeName = string

Type aliases for sprite-related identifiers.

type SpriteImpl

type SpriteImpl struct {
	// contains filtered or unexported fields
}

SpriteImpl is the concrete implementation of the Sprite interface

func (*SpriteImpl) AddImpulse

func (p *SpriteImpl) AddImpulse(impulseX, impulseY float64)

func (*SpriteImpl) AnimateAndWait

func (p *SpriteImpl) AnimateAndWait(name SpriteAnimationName)

func (*SpriteImpl) Animate__0

func (p *SpriteImpl) Animate__0(name SpriteAnimationName)

func (*SpriteImpl) Animate__1

func (p *SpriteImpl) Animate__1(name SpriteAnimationName, loop bool)

func (*SpriteImpl) Ask

func (p *SpriteImpl) Ask(msg any)

func (*SpriteImpl) BounceOffEdge

func (p *SpriteImpl) BounceOffEdge()

func (*SpriteImpl) ChangeGraphicEffect

func (p *SpriteImpl) ChangeGraphicEffect(kind EffectKind, delta float64)

func (*SpriteImpl) ChangeHeading

func (p *SpriteImpl) ChangeHeading(dir Direction)

func (*SpriteImpl) ChangePenColor

func (p *SpriteImpl) ChangePenColor(kind PenColorParam, delta float64)

func (*SpriteImpl) ChangePenSize

func (p *SpriteImpl) ChangePenSize(delta float64)

func (*SpriteImpl) ChangeSize

func (p *SpriteImpl) ChangeSize(delta float64)

func (*SpriteImpl) ChangeSoundEffect

func (p *SpriteImpl) ChangeSoundEffect(kind SoundEffectKind, delta float64)

func (*SpriteImpl) ChangeVolume

func (p *SpriteImpl) ChangeVolume(delta float64)

func (*SpriteImpl) ChangeXYpos

func (p *SpriteImpl) ChangeXYpos(dx, dy float64)

func (*SpriteImpl) ChangeXpos

func (p *SpriteImpl) ChangeXpos(dx float64)

func (*SpriteImpl) ChangeYpos

func (p *SpriteImpl) ChangeYpos(dy float64)

func (*SpriteImpl) ClearGraphicEffects

func (p *SpriteImpl) ClearGraphicEffects()

func (*SpriteImpl) ColliderPivot

func (p *SpriteImpl) ColliderPivot(isTrigger bool) (offsetX, offsetY float64)

func (*SpriteImpl) ColliderShape

func (p *SpriteImpl) ColliderShape(isTrigger bool) (ColliderShapeType, []float64)

func (*SpriteImpl) CollisionEnabled

func (p *SpriteImpl) CollisionEnabled() bool

func (*SpriteImpl) CollisionLayer

func (p *SpriteImpl) CollisionLayer() int64

func (*SpriteImpl) CollisionMask

func (p *SpriteImpl) CollisionMask() int64

func (*SpriteImpl) CostumeIndex

func (p *SpriteImpl) CostumeIndex() int

func (*SpriteImpl) CostumeName

func (p *SpriteImpl) CostumeName() SpriteCostumeName

func (*SpriteImpl) DeleteThisClone

func (p *SpriteImpl) DeleteThisClone()

DeleteThisClone deletes only cloned sprite, no effect on prototype sprite. Add this interface to match Scratch.

func (*SpriteImpl) DeltaTime

func (pself *SpriteImpl) DeltaTime() float64

func (*SpriteImpl) Destroy

func (p *SpriteImpl) Destroy()

func (*SpriteImpl) Die

func (p *SpriteImpl) Die()

func (*SpriteImpl) DistanceTo__0

func (p *SpriteImpl) DistanceTo__0(sprite Sprite) float64

DistanceTo func:

DistanceTo(sprite)
DistanceTo(spx.Mouse)
DistanceTo(spx.Random)

func (*SpriteImpl) DistanceTo__1

func (p *SpriteImpl) DistanceTo__1(sprite SpriteName) float64

func (*SpriteImpl) DistanceTo__2

func (p *SpriteImpl) DistanceTo__2(obj specialObj) float64

func (*SpriteImpl) DistanceTo__3

func (p *SpriteImpl) DistanceTo__3(pos Pos) float64

func (*SpriteImpl) GetSoundEffect

func (p *SpriteImpl) GetSoundEffect(kind SoundEffectKind) float64

func (*SpriteImpl) Glide__0

func (p *SpriteImpl) Glide__0(x, y float64, secs float64)

func (*SpriteImpl) Glide__1

func (p *SpriteImpl) Glide__1(sprite Sprite, secs float64)

func (*SpriteImpl) Glide__2

func (p *SpriteImpl) Glide__2(sprite SpriteName, secs float64)

func (*SpriteImpl) Glide__3

func (p *SpriteImpl) Glide__3(obj specialObj, secs float64)

func (*SpriteImpl) Glide__4

func (p *SpriteImpl) Glide__4(pos Pos, secs float64)

func (*SpriteImpl) Gravity

func (p *SpriteImpl) Gravity() float64

func (*SpriteImpl) Heading

func (p *SpriteImpl) Heading() Direction

func (*SpriteImpl) Hide

func (p *SpriteImpl) Hide()

func (*SpriteImpl) HideVar

func (p *SpriteImpl) HideVar(name string)

func (*SpriteImpl) InitFrom

func (p *SpriteImpl) InitFrom(src *SpriteImpl)

func (*SpriteImpl) IsCloned

func (p *SpriteImpl) IsCloned() bool

func (*SpriteImpl) IsOnFloor

func (p *SpriteImpl) IsOnFloor() bool

func (*SpriteImpl) Move__0

func (p *SpriteImpl) Move__0(step float64)

func (*SpriteImpl) Move__1

func (p *SpriteImpl) Move__1(step int)

func (*SpriteImpl) Name

func (p *SpriteImpl) Name() string

func (*SpriteImpl) OnAnyKey

func (p *SpriteImpl) OnAnyKey(onKey func(key Key))

func (*SpriteImpl) OnBackdrop__0

func (p *SpriteImpl) OnBackdrop__0(onBackdrop func(name BackdropName))

func (*SpriteImpl) OnBackdrop__1

func (p *SpriteImpl) OnBackdrop__1(name BackdropName, onBackdrop func())

func (*SpriteImpl) OnClick

func (p *SpriteImpl) OnClick(onClick func())

func (*SpriteImpl) OnCloned__0

func (p *SpriteImpl) OnCloned__0(onCloned func(data any))

func (*SpriteImpl) OnCloned__1

func (p *SpriteImpl) OnCloned__1(onCloned func())

func (*SpriteImpl) OnKey__0

func (p *SpriteImpl) OnKey__0(key Key, onKey func())

func (*SpriteImpl) OnKey__1

func (p *SpriteImpl) OnKey__1(keys []Key, onKey func(Key))

func (*SpriteImpl) OnKey__2

func (p *SpriteImpl) OnKey__2(keys []Key, onKey func())

func (*SpriteImpl) OnMsg__0

func (p *SpriteImpl) OnMsg__0(onMsg func(msg string, data any))

func (*SpriteImpl) OnMsg__1

func (p *SpriteImpl) OnMsg__1(msg string, onMsg func())

func (*SpriteImpl) OnStart

func (p *SpriteImpl) OnStart(onStart func())

func (*SpriteImpl) OnSwipe__0

func (p *SpriteImpl) OnSwipe__0(direction Direction, onSwipe func())

func (*SpriteImpl) OnTimer

func (p *SpriteImpl) OnTimer(time float64, call func())

func (*SpriteImpl) OnTouchStart__0

func (p *SpriteImpl) OnTouchStart__0(sprite SpriteName, onTouchStart func(Sprite))

func (*SpriteImpl) OnTouchStart__1

func (p *SpriteImpl) OnTouchStart__1(sprite SpriteName, onTouchStart func())

func (*SpriteImpl) OnTouchStart__2

func (p *SpriteImpl) OnTouchStart__2(sprites []SpriteName, onTouchStart func(Sprite))

func (*SpriteImpl) OnTouchStart__3

func (p *SpriteImpl) OnTouchStart__3(sprites []SpriteName, onTouchStart func())

func (*SpriteImpl) PausePlaying

func (p *SpriteImpl) PausePlaying(name SoundName)

func (*SpriteImpl) PenDown

func (p *SpriteImpl) PenDown()

func (*SpriteImpl) PenUp

func (p *SpriteImpl) PenUp()

func (*SpriteImpl) PhysicsMode

func (p *SpriteImpl) PhysicsMode() PhysicsMode

func (*SpriteImpl) PlayAndWait

func (p *SpriteImpl) PlayAndWait(name SoundName)

func (*SpriteImpl) Play__0

func (p *SpriteImpl) Play__0(name SoundName, loop bool)

func (*SpriteImpl) Play__1

func (p *SpriteImpl) Play__1(name SoundName)

func (*SpriteImpl) Quote__0

func (p *SpriteImpl) Quote__0(message string)

func (*SpriteImpl) Quote__1

func (p *SpriteImpl) Quote__1(message string, secs float64)

func (*SpriteImpl) Quote__2

func (p *SpriteImpl) Quote__2(message, description string)

func (*SpriteImpl) Quote__3

func (p *SpriteImpl) Quote__3(message, description string, secs float64)

func (*SpriteImpl) ResumePlaying

func (p *SpriteImpl) ResumePlaying(name SoundName)

func (*SpriteImpl) Say__0

func (p *SpriteImpl) Say__0(msg any)

func (*SpriteImpl) Say__1

func (p *SpriteImpl) Say__1(msg any, secs float64)

func (*SpriteImpl) SetColliderPivot

func (p *SpriteImpl) SetColliderPivot(isTrigger bool, offsetX, offsetY float64)

func (*SpriteImpl) SetColliderShape

func (p *SpriteImpl) SetColliderShape(isTrigger bool, ctype ColliderShapeType, params []float64) error

func (*SpriteImpl) SetCollisionEnabled

func (p *SpriteImpl) SetCollisionEnabled(enabled bool)

func (*SpriteImpl) SetCollisionLayer

func (p *SpriteImpl) SetCollisionLayer(layer int64)

func (*SpriteImpl) SetCollisionMask

func (p *SpriteImpl) SetCollisionMask(mask int64)

func (*SpriteImpl) SetCostume__0

func (p *SpriteImpl) SetCostume__0(costume SpriteCostumeName)

func (*SpriteImpl) SetCostume__1

func (p *SpriteImpl) SetCostume__1(index float64)

func (*SpriteImpl) SetCostume__2

func (p *SpriteImpl) SetCostume__2(index int)

func (*SpriteImpl) SetCostume__3

func (p *SpriteImpl) SetCostume__3(action switchAction)

func (*SpriteImpl) SetGraphicEffect

func (p *SpriteImpl) SetGraphicEffect(kind EffectKind, val float64)

func (*SpriteImpl) SetGravity

func (p *SpriteImpl) SetGravity(gravity float64)

func (*SpriteImpl) SetHeading

func (p *SpriteImpl) SetHeading(dir Direction)

func (*SpriteImpl) SetLayer__0

func (p *SpriteImpl) SetLayer__0(layer layerAction)

func (*SpriteImpl) SetLayer__1

func (p *SpriteImpl) SetLayer__1(dir dirAction, delta int)

func (*SpriteImpl) SetPenColor__0

func (p *SpriteImpl) SetPenColor__0(color Color)

func (*SpriteImpl) SetPenColor__1

func (p *SpriteImpl) SetPenColor__1(kind PenColorParam, value float64)

func (*SpriteImpl) SetPenSize

func (p *SpriteImpl) SetPenSize(size float64)

func (*SpriteImpl) SetPhysicsMode

func (p *SpriteImpl) SetPhysicsMode(mode PhysicsMode)

func (*SpriteImpl) SetRotationStyle

func (p *SpriteImpl) SetRotationStyle(style RotationStyle)

func (*SpriteImpl) SetSize

func (p *SpriteImpl) SetSize(size float64)

func (*SpriteImpl) SetSoundEffect

func (p *SpriteImpl) SetSoundEffect(kind SoundEffectKind, value float64)

func (*SpriteImpl) SetTriggerEnabled

func (p *SpriteImpl) SetTriggerEnabled(trigger bool)

func (*SpriteImpl) SetTriggerLayer

func (p *SpriteImpl) SetTriggerLayer(layer int64)

func (*SpriteImpl) SetTriggerMask

func (p *SpriteImpl) SetTriggerMask(mask int64)

func (*SpriteImpl) SetVelocity

func (p *SpriteImpl) SetVelocity(velocityX, velocityY float64)

func (*SpriteImpl) SetVolume

func (p *SpriteImpl) SetVolume(volume float64)

func (*SpriteImpl) SetXYpos

func (p *SpriteImpl) SetXYpos(x, y float64)

func (*SpriteImpl) SetXpos

func (p *SpriteImpl) SetXpos(x float64)

func (*SpriteImpl) SetYpos

func (p *SpriteImpl) SetYpos(y float64)

func (*SpriteImpl) Show

func (p *SpriteImpl) Show()

func (*SpriteImpl) ShowVar

func (p *SpriteImpl) ShowVar(name string)

func (*SpriteImpl) Size

func (p *SpriteImpl) Size() float64

func (*SpriteImpl) Stamp

func (p *SpriteImpl) Stamp()

func (*SpriteImpl) StepTo__0

func (p *SpriteImpl) StepTo__0(sprite Sprite)

func (*SpriteImpl) StepTo__1

func (p *SpriteImpl) StepTo__1(sprite SpriteName)

func (*SpriteImpl) StepTo__2

func (p *SpriteImpl) StepTo__2(x, y float64)

func (*SpriteImpl) StepTo__3

func (p *SpriteImpl) StepTo__3(obj specialObj)

func (*SpriteImpl) StepTo__4

func (p *SpriteImpl) StepTo__4(sprite Sprite, speed float64)

func (*SpriteImpl) StepTo__5

func (p *SpriteImpl) StepTo__5(sprite SpriteName, speed float64)

func (*SpriteImpl) StepTo__6

func (p *SpriteImpl) StepTo__6(x, y, speed float64)

func (*SpriteImpl) StepTo__7

func (p *SpriteImpl) StepTo__7(obj specialObj, speed float64)

func (*SpriteImpl) StepTo__8

func (p *SpriteImpl) StepTo__8(sprite Sprite, speed float64, animation SpriteAnimationName)

func (*SpriteImpl) StepTo__9

func (p *SpriteImpl) StepTo__9(sprite SpriteName, speed float64, animation SpriteAnimationName)

func (*SpriteImpl) StepTo__a

func (p *SpriteImpl) StepTo__a(x, y, speed float64, animation SpriteAnimationName)

func (*SpriteImpl) StepTo__b

func (p *SpriteImpl) StepTo__b(obj specialObj, speed float64, animation SpriteAnimationName)

func (*SpriteImpl) Step__0

func (p *SpriteImpl) Step__0(step float64)

func (*SpriteImpl) Step__1

func (p *SpriteImpl) Step__1(step float64, speed float64)

func (*SpriteImpl) Step__2

func (p *SpriteImpl) Step__2(step float64, speed float64, animation SpriteAnimationName)

func (*SpriteImpl) Stop

func (p *SpriteImpl) Stop(kind StopKind)

func (*SpriteImpl) StopAnimation

func (p *SpriteImpl) StopAnimation(name SpriteAnimationName)

func (*SpriteImpl) StopPlaying

func (p *SpriteImpl) StopPlaying(name SoundName)

func (*SpriteImpl) Think__0

func (p *SpriteImpl) Think__0(msg any)

func (*SpriteImpl) Think__1

func (p *SpriteImpl) Think__1(msg any, secs float64)

func (*SpriteImpl) TimeSinceLevelLoad

func (pself *SpriteImpl) TimeSinceLevelLoad() float64

func (*SpriteImpl) TouchingColor

func (p *SpriteImpl) TouchingColor(color Color) bool

func (*SpriteImpl) Touching__0

func (p *SpriteImpl) Touching__0(sprite SpriteName) bool

func (*SpriteImpl) Touching__1

func (p *SpriteImpl) Touching__1(sprite Sprite) bool

func (*SpriteImpl) Touching__2

func (p *SpriteImpl) Touching__2(obj specialObj) bool

func (*SpriteImpl) TriggerEnabled

func (p *SpriteImpl) TriggerEnabled() bool

func (*SpriteImpl) TriggerLayer

func (p *SpriteImpl) TriggerLayer() int64

func (*SpriteImpl) TriggerMask

func (p *SpriteImpl) TriggerMask() int64

func (*SpriteImpl) TurnTo__0

func (p *SpriteImpl) TurnTo__0(target Sprite)

func (*SpriteImpl) TurnTo__1

func (p *SpriteImpl) TurnTo__1(target SpriteName)

func (*SpriteImpl) TurnTo__2

func (p *SpriteImpl) TurnTo__2(dir Direction)

func (*SpriteImpl) TurnTo__3

func (p *SpriteImpl) TurnTo__3(target specialObj)

func (*SpriteImpl) TurnTo__4

func (p *SpriteImpl) TurnTo__4(target Sprite, speed float64)

func (*SpriteImpl) TurnTo__5

func (p *SpriteImpl) TurnTo__5(target SpriteName, speed float64)

func (*SpriteImpl) TurnTo__6

func (p *SpriteImpl) TurnTo__6(dir Direction, speed float64)

func (*SpriteImpl) TurnTo__7

func (p *SpriteImpl) TurnTo__7(target specialObj, speed float64)

func (*SpriteImpl) TurnTo__8

func (p *SpriteImpl) TurnTo__8(target Sprite, speed float64, animation SpriteAnimationName)

func (*SpriteImpl) TurnTo__9

func (p *SpriteImpl) TurnTo__9(target SpriteName, speed float64, animation SpriteAnimationName)

func (*SpriteImpl) TurnTo__a

func (p *SpriteImpl) TurnTo__a(dir Direction, speed float64, animation SpriteAnimationName)

func (*SpriteImpl) TurnTo__b

func (p *SpriteImpl) TurnTo__b(target specialObj, speed float64, animation SpriteAnimationName)

func (*SpriteImpl) Turn__0

func (p *SpriteImpl) Turn__0(dir Direction)

func (*SpriteImpl) Turn__1

func (p *SpriteImpl) Turn__1(dir Direction, speed float64)

func (*SpriteImpl) Turn__2

func (p *SpriteImpl) Turn__2(dir Direction, speed float64, animation SpriteAnimationName)

func (*SpriteImpl) Velocity

func (p *SpriteImpl) Velocity() (velocityX, velocityY float64)

func (*SpriteImpl) Visible

func (p *SpriteImpl) Visible() bool

func (*SpriteImpl) Volume

func (p *SpriteImpl) Volume() float64

func (*SpriteImpl) Xpos

func (p *SpriteImpl) Xpos() float64

func (*SpriteImpl) Ypos

func (p *SpriteImpl) Ypos() float64

type SpriteName

type SpriteName = string

Type aliases for sprite-related identifiers.

type StopKind

type StopKind int
const (
	AllStop              StopKind = All  // -3: stop all scripts of stage/sprites and abort this script
	AllOtherScripts      StopKind = -100 // stop all other scripts
	AllSprites           StopKind = -101 // stop all scripts of sprites
	ThisSprite           StopKind = -102 // stop all scripts of this sprite
	ThisScript           StopKind = -103 // abort this script
	OtherScriptsInSprite StopKind = -104 // stop other scripts of this sprite
)

type Value

type Value struct {
	// contains filtered or unexported fields
}

func NewValue

func NewValue(o obj) Value

NewValue creates a new Value initialized with the given object.

func (Value) Equal

func (p Value) Equal(v obj) bool

func (Value) Float

func (p Value) Float() float64

func (Value) Int

func (p Value) Int() int

func (*Value) Set

func (p *Value) Set(v obj)

func (Value) String

func (p Value) String() string

type Widget

type Widget interface {
	GetName() WidgetName
	Visible() bool
	Show()
	Hide()

	Xpos() float64
	Ypos() float64
	SetXpos(x float64)
	SetYpos(y float64)
	SetXYpos(x float64, y float64)
	ChangeXpos(dx float64)
	ChangeYpos(dy float64)
	ChangeXYpos(dx float64, dy float64)

	Size() float64
	SetSize(size float64)
	ChangeSize(delta float64)
}

func GetWidget_

func GetWidget_(sg ShapeGetter, name WidgetName) Widget

GetWidget_ returns the widget instance with given name. It panics if not found. Instead of being used directly, it is meant to be called by `XGot_Game_XGox_GetWidget` only. We extract `GetWidget_` to keep `XGot_Game_XGox_GetWidget` simple, which simplifies work in ispx, see details in https://github.com/goplus/builder/issues/765#issuecomment-2313915805.

type WidgetName

type WidgetName = string

Directories

Path Synopsis
cmd
ispx command
ispxnative command
spxrun command
Package main implements the spxrun command for running SPX 2.0 projects.
Package main implements the spxrun command for running SPX 2.0 projects.
spxrun/runner
Package runner implements the SPX 2.0 project runner.
Package runner implements the SPX 2.0 project runner.
fs
zip
internal
debug
Package debug provides debugging utilities for stack traces and logging.
Package debug provides debugging utilities for stack traces and logging.
log
Package log provides a unified logging system for SPX engine.
Package log provides a unified logging system for SPX engine.
ui
pkg
gdspx/internal/ffi
------------------------------------------------------------------------------ // This code was generated by template ffi_gdextension_interface.go.tmpl.
------------------------------------------------------------------------------ // This code was generated by template ffi_gdextension_interface.go.tmpl.
gdspx/internal/webffi
------------------------------------------------------------------------------ // This code was generated by template ffi_wrapper.go.tmpl.
------------------------------------------------------------------------------ // This code was generated by template ffi_wrapper.go.tmpl.
gdspx/internal/wrap
------------------------------------------------------------------------------ // This code was generated by template ffi_gdextension_interface.go.tmpl.
------------------------------------------------------------------------------ // This code was generated by template ffi_gdextension_interface.go.tmpl.
gdspx/pkg/engine
------------------------------------------------------------------------------ // This code was generated by template ffi_gdextension_interface.go.tmpl.
------------------------------------------------------------------------------ // This code was generated by template ffi_gdextension_interface.go.tmpl.
spx

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL