Version: v0.11.2 Latest Latest

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

Go to latest
Published: Nov 12, 2022 License: MIT Imports: 11 Imported by: 10




View Source
const (
	TransformOriginTopLeft      = "TopLeft"
	TransformOriginTopMiddle    = "TopMiddle"
	TransformOriginTopRight     = "TopRight"
	TransformOriginMiddleLeft   = "MiddleLeft"
	TransformOriginMiddle       = "Middle"
	TransformOriginMiddleRight  = "MiddleRight"
	TransformOriginBottomLeft   = "BottomLeft"
	TransformOriginBottomMiddle = "BottomMiddle"
	TransformOriginBottomRight  = "BottomRight"

Transform origin variants

View Source
const (
	PivotDot          = "Dot"
	PivotTopLeft      = "TopLeft"
	PivotTopMiddle    = "TopMiddle"
	PivotTopRight     = "TopRight"
	PivotMiddleLeft   = "MiddleLeft"
	PivotMiddle       = "Middle"
	PivotMiddleRight  = "MiddleRight"
	PivotBottomLeft   = "BottomLeft"
	PivotBottomMiddle = "BottomMiddle"
	PivotBottomRight  = "BottomRight"

Pivot variants

View Source
const (
	UITransformOriginTopLeft      = "TopLeft"
	UITransformOriginTopMiddle    = "TopMiddle"
	UITransformOriginTopRight     = "TopRight"
	UITransformOriginMiddleLeft   = "MiddleLeft"
	UITransformOriginMiddle       = "Middle"
	UITransformOriginMiddleRight  = "MiddleRight"
	UITransformOriginBottomLeft   = "BottomLeft"
	UITransformOriginBottomMiddle = "BottomMiddle"
	UITransformOriginBottomRight  = "BottomRight"

UI transform origin variants


This section is empty.


func ComputeDotOffset added in v0.6.2

func ComputeDotOffset(text string, fontFace font.Face, pivot string) (x, y int, err error)

ComputeDotOffset computes dot offset from text and pivot


type Animation added in v0.2.0

type Animation struct {
	// List of times (must be in strictly increasing order, with first element equal to 0)
	Time []float64
	// List of sprite numbers (must have one less element than the Time field, and at least one element)
	SpriteNumber []int `toml:"sprite_number"`

Animation structure

func (*Animation) UnmarshalTOML added in v0.2.0

func (a *Animation) UnmarshalTOML(i interface{}) error

UnmarshalTOML fills structure fields from TOML data

type AnimationCommand added in v0.2.0

type AnimationCommand struct {
	// Animation command type
	Type AnimationCommandType
	// Command time, used only with AnimationCommandSetTime
	Time float64

AnimationCommand structure

type AnimationCommandType added in v0.2.0

type AnimationCommandType int

AnimationCommandType is an animation command type

const (
	// AnimationCommandNone does nothing
	AnimationCommandNone AnimationCommandType = iota
	// AnimationCommandRestart restarts the animation
	// AnimationCommandStart starts the animation
	// AnimationCommandStepBackward steps backward
	// AnimationCommandStepForward steps forward
	// AnimationCommandSetTime sets animation time to the specified time value
	// AnimationCommandPause pauses the animation
	// AnimationCommandAbort aborts and removes the animation from entity

type AnimationControl added in v0.2.0

type AnimationControl struct {
	// Reference animation
	Animation *Animation
	// End control
	End EndControl
	// Animation command
	Command AnimationCommand
	// Animation speed multiplier
	RateMultiplier float64
	// contains filtered or unexported fields

AnimationControl component

func (*AnimationControl) GetState added in v0.2.0

func (c *AnimationControl) GetState() ControlState

GetState returns animation control state

func (*AnimationControl) SetCurrentTime added in v0.2.0

func (c *AnimationControl) SetCurrentTime(time float64)

SetCurrentTime sets current animation time

func (*AnimationControl) SetStateType added in v0.2.0

func (c *AnimationControl) SetStateType(stateType ControlStateType)

SetStateType sets animation control state type

type Components

type Components struct {
	Engine *EngineComponents
	Game   interface{}

Components contains engine and game components

func InitComponents

func InitComponents(manager *ecs.Manager, gameComponents interface{}) *Components

InitComponents initializes components

type ControlState added in v0.2.0

type ControlState struct {
	// Control state type
	Type ControlStateType
	// Current animation time
	CurrentTime float64

ControlState structure

type ControlStateType added in v0.2.0

type ControlStateType int

ControlStateType is a control state type

const (
	// ControlStateNotStarted is the default state
	ControlStateNotStarted ControlStateType = iota
	// ControlStateRunning is the running state
	// ControlStatePaused is the paused state
	// ControlStateDone is the done state

type EndControl added in v0.2.0

type EndControl struct {
	// End control type
	Type EndControlType

EndControl structure

type EndControlType added in v0.2.0

type EndControlType int

EndControlType is an end control type

const (
	// EndControlNormal goes back to the start of the animation
	EndControlNormal EndControlType = iota
	// EndControlStay stays at the end of the animation
	// EndControlLoop loops the animation

type EngineComponents

type EngineComponents struct {
	SpriteRender     *ecs.SliceComponent
	Transform        *ecs.SliceComponent
	AnimationControl *ecs.SliceComponent
	Text             *ecs.SliceComponent
	UITransform      *ecs.SliceComponent
	MouseReactive    *ecs.SliceComponent

EngineComponents contains references to all engine components

type MouseReactive

type MouseReactive struct {
	ID          string
	Hovered     bool
	JustClicked bool

MouseReactive component

type Sprite

type Sprite struct {
	// Horizontal position of the sprite in the sprite sheet
	X int
	// Vertical position of the sprite in the sprite sheet
	Y int
	// Width of the sprite
	Width int
	// Height of the sprite
	Height int

Sprite structure

type SpriteRender

type SpriteRender struct {
	// Reference sprite sheet
	SpriteSheet *SpriteSheet
	// Index of the sprite on the sprite sheet
	SpriteNumber int
	// Draw options
	Options ebiten.DrawImageOptions

SpriteRender component

type SpriteSheet

type SpriteSheet struct {
	// Texture image
	Texture Texture `toml:"texture_image"`
	// List of sprites
	Sprites []Sprite
	// List of animations
	Animations map[string]*Animation

SpriteSheet structure

type Text

type Text struct {
	ID       string
	Text     string
	FontFace font.Face
	Color    color.RGBA

Text component

type Texture

type Texture struct {
	// Texture image
	Image *ebiten.Image

Texture structure

func (*Texture) UnmarshalText

func (t *Texture) UnmarshalText(text []byte) error

UnmarshalText fills structure fields from text data

type Transform

type Transform struct {
	// Scale1 vector defines image scaling. Contains scale value minus 1 so that zero value is identity.
	Scale1 math.Vector2 `toml:"scale_minus_1"`
	// Rotation angle is measured counterclockwise.
	Rotation float64
	// Translation defines the position of the image center relative to the origin.
	Translation math.Vector2
	// Origin defines the origin (0, 0) relative to the screen. Default is "BottomLeft".
	Origin string
	// Depth determines the drawing order on the screen. Images with higher depth are drawn above others.
	Depth float64

Transform component. The origin (0, 0) is the lower left part of screen. Image is first rotated, then scaled, and finally translated.

func NewTransform

func NewTransform() *Transform

NewTransform creates a new default transform, corresponding to identity.

func (*Transform) ComputeOriginOffset added in v0.11.2

func (t *Transform) ComputeOriginOffset(screenWidth, screenHeight float64) (offsetX, offsetY float64)

ComputeOriginOffset returns the transform origin offset.

func (*Transform) SetDepth

func (t *Transform) SetDepth(depth float64) *Transform

SetDepth sets transform depth.

func (*Transform) SetOrigin added in v0.11.0

func (t *Transform) SetOrigin(origin string) *Transform

SetOrigin sets transform origin.

func (*Transform) SetRotation

func (t *Transform) SetRotation(angle float64) *Transform

SetRotation sets transform rotation.

func (*Transform) SetScale

func (t *Transform) SetScale(sx, sy float64) *Transform

SetScale sets transform scale.

func (*Transform) SetTranslation

func (t *Transform) SetTranslation(tx, ty float64) *Transform

SetTranslation sets transform translation.

type UITransform

type UITransform struct {
	// Translation defines the position of the pivot relative to the origin.
	Translation math.VectorInt2
	// Origin defines the origin (0, 0) relative to the screen. Default is "BottomLeft".
	Origin string
	// Pivot defines the position of the element relative to its translation (default is Middle).
	Pivot string

UITransform component

func (*UITransform) ComputeOriginOffset added in v0.11.2

func (t *UITransform) ComputeOriginOffset(screenWidth, screenHeight int) (offsetX, offsetY int)

ComputeOriginOffset returns the UI transform origin offset

Jump to

Keyboard shortcuts

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