spx

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 46 Imported by: 10

README

spx - A Go+ 2D Game Engine for STEM education

Build Status Go Report Card GitHub release Language Scratch diff

How to build

How to run games powered by Go+ spx engine?

  • Download Go+ and build it. See https://github.com/goplus/gop#how-to-build.
  • Download spx and build it.
    • git clone https://github.com/goplus/spx.git
    • cd spx
    • go install -v ./...
  • Build a game and run.
    • cd game-root-dir
    • gop 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": "stageMonitor",
      "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 Go+)"}

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 => {
	broadcast "undo", true
	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
	DbgFlagAll = DbgFlagLoad | DbgFlagInstr | DbgFlagEvent
)
View Source
const (
	Prev switchAction = -1
	Next switchAction = 1
)
View Source
const (
	Right specialDir = 90
	Left  specialDir = -90
	Up    specialDir = 0
	Down  specialDir = 180
)
View Source
const (
	Mouse      specialObj = -5
	Edge       specialObj = touchingAllEdges
	EdgeLeft   specialObj = touchingScreenLeft
	EdgeTop    specialObj = touchingScreenTop
	EdgeRight  specialObj = touchingScreenRight
	EdgeBottom specialObj = touchingScreenBottom
)

Variables

This section is empty.

Functions

func Exit__0 added in v1.0.0

func Exit__0(code int)

func Exit__1 added in v1.0.0

func Exit__1()

func Gopt_Game_Main added in v0.8.6

func Gopt_Game_Main(game Gamer, sprites ...Spriter)

Gopt_Game_Main is required by Go+ compiler as the entry of a .gmx project.

func Gopt_Game_Reload added in v1.0.0

func Gopt_Game_Reload(game Gamer, index interface{}) (err error)

func Gopt_Game_Run added in v0.4.0

func Gopt_Game_Run(game Gamer, resource interface{}, gameConf ...*Config)

Gopt_Game_Run runs the game. resource can be a string or fs.Dir object.

func Gopt_Sprite_Clone__0 added in v0.4.0

func Gopt_Sprite_Clone__0(sprite Spriter)

func Gopt_Sprite_Clone__1 added in v0.4.0

func Gopt_Sprite_Clone__1(sprite Spriter, data interface{})

func Iround added in v0.6.0

func Iround(v float64) int

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

func Rand__0 added in v0.4.0

func Rand__0(from, to int) float64

func Rand__1 added in v0.4.0

func Rand__1(from, to float64) float64

func Sched added in v0.2.1

func Sched() int

func SchedNow added in v0.2.1

func SchedNow() int

func SetDebug added in v0.3.0

func SetDebug(flags dbgFlags)

Types

type Camera added in v1.0.0

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

func (*Camera) ChangeXYpos added in v1.0.0

func (c *Camera) ChangeXYpos(x float64, y float64)

func (*Camera) On added in v1.0.0

func (c *Camera) On(obj interface{})

func (*Camera) SetXYpos added in v1.0.0

func (c *Camera) SetXYpos(x float64, y float64)

type Color

type Color = color.RGBA

func RGB added in v0.6.0

func RGB(r, g, b uint8) Color

-----------------------------------------------------------------------------

func RGBA added in v0.6.0

func RGBA(r, g, b, a uint8) Color

type Config added in v0.2.0

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
	Index              interface{} `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 EffectKind

type EffectKind int
const (
	ColorEffect EffectKind = iota
	BrightnessEffect
	GhostEffect
)

func (EffectKind) String added in v1.0.0

func (kind EffectKind) String() string

type Game

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

func (*Game) Answer

func (p *Game) Answer() Value

func (*Game) Ask

func (p *Game) Ask(msg interface{})

func (*Game) Broadcast__0 added in v0.3.0

func (p *Game) Broadcast__0(msg string)

func (*Game) Broadcast__1 added in v0.3.0

func (p *Game) Broadcast__1(msg string, wait bool)

func (*Game) Broadcast__2 added in v0.3.0

func (p *Game) Broadcast__2(msg string, data interface{}, wait bool)

func (*Game) ChangeEffect

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

func (*Game) ChangeVolume

func (p *Game) ChangeVolume(delta float64)

func (*Game) ClearSoundEffects added in v1.0.0

func (p *Game) ClearSoundEffects()

func (*Game) Draw added in v0.8.0

func (p *Game) Draw(screen *ebiten.Image)

func (*Game) EraseAll added in v1.0.0

func (p *Game) EraseAll()

func (*Game) HideVar added in v0.7.0

func (p *Game) HideVar(name string)

func (*Game) KeyPressed

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

func (*Game) Layout added in v0.8.0

func (p *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int)

func (*Game) Loudness added in v1.0.0

func (p *Game) Loudness() float64

func (*Game) MouseHitItem added in v1.0.0

func (p *Game) MouseHitItem() (target *Sprite, ok bool)

MouseHitItem returns the topmost item which is hit by mouse.

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) NextScene

func (p *Game) NextScene(wait ...bool)

func (*Game) OnAnyKey added in v0.8.0

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

func (*Game) OnClick added in v0.4.0

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

func (*Game) OnKey__0 added in v0.4.0

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

func (*Game) OnKey__1 added in v0.5.0

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

func (*Game) OnKey__2 added in v0.8.0

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

func (*Game) OnMsg__0 added in v0.4.0

func (p *Game) OnMsg__0(onMsg func(msg string, data interface{}))

func (*Game) OnMsg__1 added in v0.4.0

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

func (*Game) OnScene__0 added in v0.4.0

func (p *Game) OnScene__0(onScene func(name string))

func (*Game) OnScene__1 added in v0.5.0

func (p *Game) OnScene__1(name string, onScene func())

func (*Game) OnStart added in v0.4.0

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

func (*Game) Play__0 added in v0.3.0

func (p *Game) Play__0(media Sound)

Play func:

Play(sound)
Play(video) -- maybe
Play(media, wait) -- sync
Play(media, opts)

func (*Game) Play__1 added in v1.0.0

func (p *Game) Play__1(media Sound, wait bool)

func (*Game) Play__2 added in v1.0.0

func (p *Game) Play__2(media Sound, action *PlayOptions)

func (*Game) PrevScene added in v1.0.0

func (p *Game) PrevScene(wait ...bool)

func (*Game) ResetTimer

func (p *Game) ResetTimer()

func (*Game) SceneIndex

func (p *Game) SceneIndex() int

func (*Game) SceneName

func (p *Game) SceneName() string

func (*Game) SetEffect

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

func (*Game) SetVolume

func (p *Game) SetVolume(volume float64)

func (*Game) ShowVar added in v0.7.0

func (p *Game) ShowVar(name string)

func (*Game) StartScene

func (p *Game) StartScene(scene interface{}, wait ...bool)

StartScene func:

StartScene(sceneName) or
StartScene(sceneIndex) or
StartScene(spx.Next)
StartScene(spx.Prev)

func (*Game) Stop added in v0.4.0

func (p *Game) Stop(kind StopKind)

func (*Game) StopAllSounds

func (p *Game) StopAllSounds()

func (*Game) Timer

func (p *Game) Timer() float64

func (*Game) Update added in v0.8.0

func (p *Game) Update() error

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)

type Gamer added in v0.2.0

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

type Key

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

type List added in v0.5.0

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

func (*List) Append added in v0.5.0

func (p *List) Append(v obj)

func (*List) At added in v0.5.0

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

func (*List) Contains added in v0.5.0

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

func (*List) Delete added in v0.5.0

func (p *List) Delete(i Pos)

func (*List) Init added in v0.5.0

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

func (*List) InitFrom added in v0.5.0

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

func (*List) Insert added in v0.5.0

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

func (*List) Len added in v0.5.0

func (p *List) Len() int

func (*List) Set added in v0.5.0

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

func (*List) String added in v0.5.0

func (p *List) String() string

type MovingInfo added in v0.8.1

type MovingInfo struct {
	OldX, OldY float64
	NewX, NewY float64

	Obj *Sprite
	// contains filtered or unexported fields
}

func (*MovingInfo) Dx added in v0.8.6

func (p *MovingInfo) Dx() float64

func (*MovingInfo) Dy added in v0.8.6

func (p *MovingInfo) Dy() float64

func (*MovingInfo) StopMoving added in v1.0.0

func (p *MovingInfo) StopMoving()

type PlayAction added in v1.0.0

type PlayAction int
const (
	PlayRewind PlayAction = iota
	PlayContinue
	PlayPause
	PlayResume
	PlayStop
)

type PlayOptions added in v1.0.0

type PlayOptions struct {
	Action PlayAction
	Wait   bool
	Loop   bool
}

type Pos added in v1.0.0

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

type RotationStyle

type RotationStyle int
const (
	None RotationStyle = iota
	Normal
	LeftRight
)

type Shape added in v0.2.0

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

type Sound added in v0.3.0

type Sound *soundConfig

type Sprite

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

func (*Sprite) Animate added in v1.0.0

func (p *Sprite) Animate(name string)

func (*Sprite) Ask added in v1.0.0

func (p *Sprite) Ask(msg interface{})

func (*Sprite) BounceOffEdge

func (p *Sprite) BounceOffEdge()

func (*Sprite) Bounds added in v1.0.0

func (p *Sprite) Bounds() *math32.RotatedRect

func (*Sprite) ChangeEffect added in v1.0.0

func (p *Sprite) ChangeEffect(kind EffectKind, delta float64)

func (*Sprite) ChangeHeading added in v1.0.0

func (p *Sprite) ChangeHeading(dir float64)

func (*Sprite) ChangePenColor

func (p *Sprite) ChangePenColor(delta float64)

func (*Sprite) ChangePenHue

func (p *Sprite) ChangePenHue(delta float64)

func (*Sprite) ChangePenShade

func (p *Sprite) ChangePenShade(delta float64)

func (*Sprite) ChangePenSize

func (p *Sprite) ChangePenSize(delta float64)

func (*Sprite) ChangeSize

func (p *Sprite) ChangeSize(delta float64)

func (*Sprite) ChangeXYpos added in v0.8.2

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

func (*Sprite) ChangeXpos

func (p *Sprite) ChangeXpos(dx float64)

func (*Sprite) ChangeYpos

func (p *Sprite) ChangeYpos(dy float64)

func (*Sprite) ClearGraphEffects added in v1.0.0

func (p *Sprite) ClearGraphEffects()

func (*Sprite) CostumeHeight added in v1.0.0

func (p *Sprite) CostumeHeight() float64

CostumeHeight returns height of sprite current costume.

func (*Sprite) CostumeIndex

func (p *Sprite) CostumeIndex() int

func (*Sprite) CostumeName

func (p *Sprite) CostumeName() string

func (*Sprite) CostumeWidth added in v1.0.0

func (p *Sprite) CostumeWidth() float64

CostumeWidth returns width of sprite current costume.

func (*Sprite) Destroy

func (p *Sprite) Destroy()

func (*Sprite) Die added in v0.8.5

func (p *Sprite) Die()

func (*Sprite) DistanceTo

func (p *Sprite) DistanceTo(obj interface{}) float64

DistanceTo func:

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

func (*Sprite) Glide__0 added in v1.0.0

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

func (*Sprite) Glide__1 added in v1.0.0

func (p *Sprite) Glide__1(obj interface{}, secs float64)

func (*Sprite) GoBackLayers

func (p *Sprite) GoBackLayers(n int)

func (*Sprite) Goto

func (p *Sprite) Goto(obj interface{})

Goto func:

Goto(sprite)
Goto(spriteName)
Goto(spx.Mouse)
Goto(spx.Random)

func (*Sprite) GotoBack added in v1.0.0

func (p *Sprite) GotoBack()

func (*Sprite) GotoFront

func (p *Sprite) GotoFront()

func (*Sprite) Heading

func (p *Sprite) Heading() float64

func (*Sprite) Hide

func (p *Sprite) Hide()

func (*Sprite) HideVar added in v0.7.0

func (p *Sprite) HideVar(name string)

func (*Sprite) InitFrom added in v0.5.0

func (p *Sprite) InitFrom(src *Sprite)

func (*Sprite) IsCloned added in v1.0.0

func (p *Sprite) IsCloned() bool

func (*Sprite) Move__0 added in v1.0.0

func (p *Sprite) Move__0(step float64)

func (*Sprite) Move__1 added in v1.0.0

func (p *Sprite) Move__1(step int)

func (*Sprite) NextCostume

func (p *Sprite) NextCostume()

func (*Sprite) OnAnyKey added in v0.8.0

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

func (*Sprite) OnClick added in v0.4.0

func (p *Sprite) OnClick(onClick func())

func (*Sprite) OnCloned__0 added in v0.4.0

func (p *Sprite) OnCloned__0(onCloned func(data interface{}))

func (*Sprite) OnCloned__1 added in v0.5.0

func (p *Sprite) OnCloned__1(onCloned func())

func (*Sprite) OnKey__0 added in v0.4.0

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

func (*Sprite) OnKey__1 added in v0.5.0

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

func (*Sprite) OnKey__2 added in v0.8.0

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

func (*Sprite) OnMoving__0 added in v0.8.5

func (p *Sprite) OnMoving__0(onMoving func(mi *MovingInfo))

func (*Sprite) OnMoving__1 added in v0.8.5

func (p *Sprite) OnMoving__1(onMoving func())

func (*Sprite) OnMsg__0 added in v0.4.0

func (p *Sprite) OnMsg__0(onMsg func(msg string, data interface{}))

func (*Sprite) OnMsg__1 added in v0.4.0

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

func (*Sprite) OnScene__0 added in v0.4.0

func (p *Sprite) OnScene__0(onScene func(name string))

func (*Sprite) OnScene__1 added in v0.5.0

func (p *Sprite) OnScene__1(name string, onScene func())

func (*Sprite) OnStart added in v0.4.0

func (p *Sprite) OnStart(onStart func())

func (*Sprite) OnTouched__0 added in v1.0.0

func (p *Sprite) OnTouched__0(onTouched func(obj *Sprite))

func (*Sprite) OnTouched__1 added in v1.0.0

func (p *Sprite) OnTouched__1(onTouched func())

func (*Sprite) OnTouched__2 added in v1.0.0

func (p *Sprite) OnTouched__2(name string, onTouched func(obj *Sprite))

func (*Sprite) OnTouched__3 added in v1.0.0

func (p *Sprite) OnTouched__3(name string, onTouched func())

func (*Sprite) OnTouched__4 added in v1.0.0

func (p *Sprite) OnTouched__4(names []string, onTouched func(obj *Sprite))

func (*Sprite) OnTouched__5 added in v1.0.0

func (p *Sprite) OnTouched__5(names []string, onTouched func())

func (*Sprite) OnTurning__0 added in v1.0.0

func (p *Sprite) OnTurning__0(onTurning func(ti *TurningInfo))

func (*Sprite) OnTurning__1 added in v1.0.0

func (p *Sprite) OnTurning__1(onTurning func())

func (*Sprite) Parent added in v0.8.3

func (p *Sprite) Parent() *Game

func (*Sprite) PenDown

func (p *Sprite) PenDown()

func (*Sprite) PenUp

func (p *Sprite) PenUp()

func (*Sprite) PrevCostume added in v0.7.0

func (p *Sprite) PrevCostume()

func (*Sprite) Quote__0 added in v1.0.0

func (p *Sprite) Quote__0(message string)

func (*Sprite) Quote__1 added in v1.0.0

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

func (*Sprite) Quote__2 added in v1.0.0

func (p *Sprite) Quote__2(message, description string, secs ...float64)

func (*Sprite) Say

func (p *Sprite) Say(msg interface{}, secs ...float64)

func (*Sprite) SetCostume

func (p *Sprite) SetCostume(costume interface{})

func (*Sprite) SetDying added in v0.8.5

func (p *Sprite) SetDying()

func (*Sprite) SetEffect added in v1.0.0

func (p *Sprite) SetEffect(kind EffectKind, val float64)

func (*Sprite) SetHeading added in v1.0.0

func (p *Sprite) SetHeading(dir float64)

func (*Sprite) SetPenColor

func (p *Sprite) SetPenColor(color Color)

func (*Sprite) SetPenHue

func (p *Sprite) SetPenHue(hue float64)

func (*Sprite) SetPenShade

func (p *Sprite) SetPenShade(shade float64)

func (*Sprite) SetPenSize

func (p *Sprite) SetPenSize(size float64)

func (*Sprite) SetRotationStyle

func (p *Sprite) SetRotationStyle(style RotationStyle)

func (*Sprite) SetSize

func (p *Sprite) SetSize(size float64)

func (*Sprite) SetXYpos added in v0.2.1

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

func (*Sprite) SetXpos

func (p *Sprite) SetXpos(x float64)

func (*Sprite) SetYpos

func (p *Sprite) SetYpos(y float64)

func (*Sprite) Show

func (p *Sprite) Show()

func (*Sprite) ShowVar added in v0.7.0

func (p *Sprite) ShowVar(name string)

func (*Sprite) Size

func (p *Sprite) Size() float64

func (*Sprite) Stamp

func (p *Sprite) Stamp()

func (*Sprite) Step__0 added in v1.0.0

func (p *Sprite) Step__0(step float64)

func (*Sprite) Step__1 added in v1.0.0

func (p *Sprite) Step__1(step int)

func (*Sprite) Step__2 added in v1.0.0

func (p *Sprite) Step__2(step float64, animname string)

func (*Sprite) Stop added in v1.0.0

func (p *Sprite) Stop(kind StopKind)

func (*Sprite) Think

func (p *Sprite) Think(msg interface{}, secs ...float64)

func (*Sprite) Touching

func (p *Sprite) Touching(obj interface{}) bool

Touching func:

Touching(spriteName)
Touching(sprite)
Touching(spx.Mouse)
Touching(spx.Edge)
Touching(spx.EdgeLeft)
Touching(spx.EdgeTop)
Touching(spx.EdgeRight)
Touching(spx.EdgeBottom)

func (*Sprite) TouchingColor

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

func (*Sprite) Turn

func (p *Sprite) Turn(val interface{})

Turn func:

Turn(degree)
Turn(spx.Left)
Turn(spx.Right)
Turn(ti *spx.TurningInfo)

func (*Sprite) TurnTo

func (p *Sprite) TurnTo(obj interface{})

TurnTo func:

TurnTo(sprite)
TurnTo(spriteName)
TurnTo(spx.Mouse)
TurnTo(degree)
TurnTo(spx.Left)
TurnTo(spx.Right)
TurnTo(spx.Up)
TurnTo(spx.Down)

func (*Sprite) Visible added in v0.8.5

func (p *Sprite) Visible() bool

func (*Sprite) Xpos

func (p *Sprite) Xpos() float64

func (*Sprite) Ypos

func (p *Sprite) Ypos() float64

type Spriter added in v0.6.0

type Spriter interface {
	Shape
	Main()
}

type StopKind added in v1.0.0

type StopKind int
const (
	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 TurningInfo added in v1.0.0

type TurningInfo struct {
	OldDir float64
	NewDir float64
	Obj    *Sprite
}

func (*TurningInfo) Dir added in v1.0.0

func (p *TurningInfo) Dir() float64

type Value

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

func (Value) Equal added in v0.5.0

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) String

func (p Value) String() string

Jump to

Keyboard shortcuts

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