components

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2020 License: MIT Imports: 8 Imported by: 17

Documentation

Index

Constants

View Source
const (
	TopLeft      = "TopLeft"
	TopMiddle    = "TopMiddle"
	TopRight     = "TopRight"
	MiddleLeft   = "MiddleLeft"
	Middle       = "Middle"
	MiddleRight  = "MiddleRight"
	BottomLeft   = "BottomLeft"
	BottomMiddle = "BottomMiddle"
	BottomRight  = "BottomRight"
)

Pivot variants

Variables

This section is empty.

Functions

This section is empty.

Types

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 EngineComponents

type EngineComponents struct {
	SpriteRender  *ecs.Component
	Transform     *ecs.Component
	Text          *ecs.Component
	UITransform   *ecs.Component
	MouseReactive *ecs.Component
}

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 `toml:"sprite_number"`
	// Draw options
	Options ebiten.DrawImageOptions
}

SpriteRender component

type SpriteSheet

type SpriteSheet struct {
	// Texture image
	Texture Texture `toml:"texture_image"`
	// List of sprites
	Sprites []Sprite
}

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
	// 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) SetDepth

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

SetDepth sets transform depth.

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
	// Pivot defines the position of the element relative to its translation (default is Middle).
	Pivot string
}

UITransform component

Jump to

Keyboard shortcuts

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