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: 0

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

func Exit(code int)

func Exit

func Exit()

func Gopt_Game_Main

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

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

func Gopt_Game_Run

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

func Gopt_Sprite_Clone(sprite Spriter)

func Gopt_Sprite_Clone

func Gopt_Sprite_Clone(sprite Spriter, data interface{})

func Iround

func Iround(v float64) int

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

func Rand

func Rand(from, to int) float64

func Rand

func Rand(from, to float64) float64

func Sched

func Sched() int

func SchedNow

func SchedNow() int

func SetDebug

func SetDebug(flags dbgFlags)

Types

type Camera

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

func (*Camera) ChangeXYpos

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

func (*Camera) On

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

func (*Camera) SetXYpos

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

type Color

type Color = color.RGBA

func RGB

func RGB(r, g, b uint8) Color

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

func RGBA

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

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

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

func (p *Game) Broadcast(msg string)

func (*Game) Broadcast

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

func (*Game) Broadcast

func (p *Game) Broadcast(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

func (p *Game) ClearSoundEffects()

func (*Game) Draw

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

func (*Game) EraseAll

func (p *Game) EraseAll()

func (*Game) HideVar

func (p *Game) HideVar(name string)

func (*Game) KeyPressed

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

func (*Game) Layout

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

func (*Game) Loudness

func (p *Game) Loudness() float64

func (*Game) MouseHitItem

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

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

func (*Game) OnClick

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

func (*Game) OnKey

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

func (*Game) OnKey

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

func (*Game) OnKey

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

func (*Game) OnMsg

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

func (*Game) OnMsg

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

func (*Game) OnScene

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

func (*Game) OnScene

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

func (*Game) OnStart

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

func (*Game) Play

func (p *Game) Play(media Sound)

Play func:

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

func (*Game) Play

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

func (*Game) Play

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

func (*Game) PrevScene

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

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

func (p *Game) Stop(kind StopKind)

func (*Game) StopAllSounds

func (p *Game) StopAllSounds()

func (*Game) Timer

func (p *Game) Timer() float64

func (*Game) Update

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

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

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

func (*List) Append

func (p *List) Append(v obj)

func (*List) At

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

func (*List) Contains

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

func (*List) Delete

func (p *List) Delete(i Pos)

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)

func (*List) Len

func (p *List) Len() int

func (*List) Set

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

func (*List) String

func (p *List) String() string

type MovingInfo

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

	Obj *Sprite
	// contains filtered or unexported fields
}

func (*MovingInfo) Dx

func (p *MovingInfo) Dx() float64

func (*MovingInfo) Dy

func (p *MovingInfo) Dy() float64

func (*MovingInfo) StopMoving

func (p *MovingInfo) StopMoving()

type PlayAction

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

type PlayOptions

type PlayOptions struct {
	Action PlayAction
	Wait   bool
	Loop   bool
}

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
const (
	None RotationStyle = iota
	Normal
	LeftRight
)

type Shape

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

type Sound

type Sound *soundConfig

type Sprite

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

func (*Sprite) Animate

func (p *Sprite) Animate(name string)

func (*Sprite) Ask

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

func (*Sprite) BounceOffEdge

func (p *Sprite) BounceOffEdge()

func (*Sprite) Bounds

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

func (*Sprite) ChangeEffect

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

func (*Sprite) ChangeHeading

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

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

func (p *Sprite) ClearGraphEffects()

func (*Sprite) CostumeHeight

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

func (p *Sprite) CostumeWidth() float64

CostumeWidth returns width of sprite current costume.

func (*Sprite) Destroy

func (p *Sprite) Destroy()

func (*Sprite) Die

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

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

func (*Sprite) Glide

func (p *Sprite) Glide(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

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

func (p *Sprite) HideVar(name string)

func (*Sprite) InitFrom

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

func (*Sprite) IsCloned

func (p *Sprite) IsCloned() bool

func (*Sprite) Move

func (p *Sprite) Move(step float64)

func (*Sprite) Move

func (p *Sprite) Move(step int)

func (*Sprite) NextCostume

func (p *Sprite) NextCostume()

func (*Sprite) OnAnyKey

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

func (*Sprite) OnClick

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

func (*Sprite) OnCloned

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

func (*Sprite) OnCloned

func (p *Sprite) OnCloned(onCloned func())

func (*Sprite) OnKey

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

func (*Sprite) OnKey

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

func (*Sprite) OnKey

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

func (*Sprite) OnMoving

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

func (*Sprite) OnMoving

func (p *Sprite) OnMoving(onMoving func())

func (*Sprite) OnMsg

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

func (*Sprite) OnMsg

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

func (*Sprite) OnScene

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

func (*Sprite) OnScene

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

func (*Sprite) OnStart

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

func (*Sprite) OnTouched

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

func (*Sprite) OnTouched

func (p *Sprite) OnTouched(onTouched func())

func (*Sprite) OnTouched

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

func (*Sprite) OnTouched

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

func (*Sprite) OnTouched

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

func (*Sprite) OnTouched

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

func (*Sprite) OnTurning

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

func (*Sprite) OnTurning

func (p *Sprite) OnTurning(onTurning func())

func (*Sprite) Parent

func (p *Sprite) Parent() *Game

func (*Sprite) PenDown

func (p *Sprite) PenDown()

func (*Sprite) PenUp

func (p *Sprite) PenUp()

func (*Sprite) PrevCostume

func (p *Sprite) PrevCostume()

func (*Sprite) Quote

func (p *Sprite) Quote(message string)

func (*Sprite) Quote

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

func (*Sprite) Quote

func (p *Sprite) Quote(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

func (p *Sprite) SetDying()

func (*Sprite) SetEffect

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

func (*Sprite) SetHeading

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

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

func (p *Sprite) ShowVar(name string)

func (*Sprite) Size

func (p *Sprite) Size() float64

func (*Sprite) Stamp

func (p *Sprite) Stamp()

func (*Sprite) Step

func (p *Sprite) Step(step float64)

func (*Sprite) Step

func (p *Sprite) Step(step int)

func (*Sprite) Step

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

func (*Sprite) Stop

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

func (p *Sprite) Visible() bool

func (*Sprite) Xpos

func (p *Sprite) Xpos() float64

func (*Sprite) Ypos

func (p *Sprite) Ypos() float64

type Spriter

type Spriter interface {
	Shape
	Main()
}

type StopKind

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

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

func (*TurningInfo) Dir

func (p *TurningInfo) Dir() float64

type Value

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

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

func (p Value) String() string

Jump to

Keyboard shortcuts

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