models

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClickOnBody

type ClickOnBody interface {
	AddCircleBody(x, y, radius float64)
	AddRectangleBody(x1, x2, y1, y2 float64)

	IsMouseClickInBody(x, y float64) bool
	GetMousePosRelativeToOriginalSprite(x, y float64) (float64, float64)

	Clone() ClickOnBody

	// Should only be used by the sim.
	Pos(x, y float64)
	Angle(RadAngle float64)
}

type CmdAddCostume

type CmdAddCostume struct {
	CostumeName string
	Img         image.Image
}

type CmdAddNewSprite

type CmdAddNewSprite struct {
	SpriteID int
}

type CmdAddSound

type CmdAddSound struct {
	Path      string
	SoundName string
}

type CmdPlaySound

type CmdPlaySound struct {
	SoundName string
	Volume    float64 // between 0 and 1.
}

type CmdSpriteDelete

type CmdSpriteDelete struct {
	SpriteID int
}

type CmdSpriteUpdateFull

type CmdSpriteUpdateFull struct {
	SpriteID    int
	CostumeName string
	X           float64
	Y           float64
	Z           int
	Angle       float64
	Visible     bool
	XScale      float64
	YScale      float64
	Opacity     float64
}

type CmdSpriteUpdateMin

type CmdSpriteUpdateMin struct {
	SpriteID int
	X        float64
	Y        float64
	AngleRad float64
}

type CmdSpritesDeleteAll

type CmdSpritesDeleteAll struct {
	SpriteID int
}

type KeysStruct

type KeysStruct struct {
	LeftArrow  bool
	RightArrow bool
	UpArrow    bool
	DownArrow  bool

	A bool
	B bool
	C bool
	D bool
	E bool
	F bool
	G bool
	H bool
	I bool
	J bool
	K bool
	L bool
	M bool
	N bool
	O bool
	P bool
	Q bool
	R bool
	S bool
	T bool
	U bool
	V bool
	W bool
	X bool
	Y bool
	Z bool

	Number0 bool
	Number1 bool
	Number2 bool
	Number3 bool
	Number4 bool
	Number5 bool
	Number6 bool
	Number7 bool
	Number8 bool
	Number9 bool

	F1  bool
	F2  bool
	F3  bool
	F4  bool
	F5  bool
	F6  bool
	F7  bool
	F8  bool
	F9  bool
	F10 bool
	F11 bool
	F12 bool

	Space      bool
	Backspace  bool
	Tab        bool
	LeftShift  bool
	RightShift bool
	LeftCtrl   bool
	RightCtrl  bool
	LeftAlt    bool
	RightAlt   bool
	Enter      bool
	Delete     bool
	Escape     bool

	Backquote          bool
	Minus              bool
	Equal              bool
	Comma              bool
	Period             bool
	SemiColon          bool
	Apostrophe         bool
	ForwardSlash       bool
	BackSlash          bool
	OpenSquareBracket  bool
	CloseSquareBracket bool
}

type MouseStruct

type MouseStruct struct {
	Left   bool
	Right  bool
	Center bool

	MouseX      int
	MouseY      int
	MouseScroll float64
}

type NearMeInfo

type NearMeInfo struct {
	SpriteID   int
	SpriteType int
	X, Y       float64
}

type Scratch

type Scratch interface {
	GetWidth() int
	GetHeight() int

	AddCostume(img image.Image, name string)
	AddSprite(UniqueName string) Sprite // If no name is given, a random name is generated.
	DeleteSprite(Sprite)
	DeleteAllSprites()

	SpriteUpdatePosAngle(in Sprite)
	SpriteUpdateFull(in Sprite)

	AddSound(path, name string)
	PlaySound(name string, volume float64) // volume must be between 0 and 1.

	PressedUserInput() *UserInput
	SubscribeToJustPressedUserInput() chan *UserInput
	UnSubscribeToJustPressedUserInput(in chan *UserInput)

	GetSpriteID(UniqueName string) int
	GetSpriteInfo(UniqueName string) SpriteState
	GetSpriteInfoByID(id int) SpriteState

	WhoIsNearMe(x, y, distance float64) []NearMeInfo
	SendMsg(toSpriteID int, msg any)

	Exit()
}

type Sprite

type Sprite interface {
	GetSpriteID() int
	GetUniqueName() string
	Clone(UniqueName string) Sprite

	// Updates
	Costume(name string)
	SetType(newType int)
	Angle(angleDegrees float64)
	Pos(cartX, cartY float64) // Cartesian (x,y). Center in the middle of the window
	Z(int)                    //
	Visible(visible bool)
	Scale(scale float64) // Sets xScale and yScale together
	XYScale(xScale, yScale float64)
	Opacity(opacityPercent float64) // 0 is completely transparent and 100 is completely opaque
	All(in SpriteState)

	// Info
	GetState() SpriteState

	// Click Body
	GetClickBody() ClickOnBody
	ReplaceClickBody(in ClickOnBody)

	// User Input
	PressedUserInput() *UserInput
	JustPressedUserInput() *UserInput

	// Interact With other sprites
	WhoIsNearMe(distance float64) []NearMeInfo
	SendMsg(toSpriteID int, msg any)
	GetMsgs() []any
	AddMsg(msg any)

	// exit
	DeleteSprite()
}

type SpriteState

type SpriteState struct {
	SpriteID       int
	SpriteType     int
	UniqueName     string
	CostumeName    string
	X, Y           float64
	Z              int // Effectively the layer index. 0 through 9 with 9 being the top.
	AngleDegrees   float64
	Visible        bool
	ScaleX, ScaleY float64
	Opacity        float64
	Deleted        bool
}

type UserInput

type UserInput struct {
	AnyPressed bool

	Keys  KeysStruct
	Mouse MouseStruct
}

Jump to

Keyboard shortcuts

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