entities

package
v4.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: Apache-2.0 Imports: 10 Imported by: 8

Documentation

Overview

Package entities provides common entity constructor functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Arrows

func Arrows(mvr *Entity)

Arrows moves the given mover based on its speed as the arrow keys are pressed

func CenterScreenOn

func CenterScreenOn(mvr *Entity)

CenterScreenOn will cause the screen to center on the given mover, obeying viewport limits if they have been set previously

func Limit

func Limit(mvr *Entity, rect floatgeom.Rect2)

Limit restricts the movement of the mover to stay within a given rectangle

func TopDown

func TopDown(mvr *Entity, up, down, left, right key.Code)

TopDown moves the given mover based on its speed as the given keys are pressed

func WASD

func WASD(mvr *Entity)

WASD moves the given mover based on its speed as W,A,S, and D are pressed

Types

type Entity

type Entity struct {
	event.CallerID

	Rect  floatgeom.Rect2
	Speed floatgeom.Point2
	Delta floatgeom.Point2

	Renderable render.Renderable

	collision.Phase

	Space *collision.Space
	Tree  *collision.Tree

	Children []*Entity
	// contains filtered or unexported fields
}

func New

func New(ctx *scene.Context, opts ...Option) *Entity

func (Entity) Bottom

func (e Entity) Bottom() float64

func (Entity) CID

func (e Entity) CID() event.CallerID

func (*Entity) Destroy

func (e *Entity) Destroy()

func (Entity) H

func (e Entity) H() float64

func (*Entity) HitLabel

func (e *Entity) HitLabel(label collision.Label) *collision.Space

func (Entity) Left

func (e Entity) Left() float64

func (*Entity) Metadata

func (e *Entity) Metadata(k string) (v string, ok bool)

Metadata accesses the value, and whether it existed, for a given metadata key

func (Entity) Right

func (e Entity) Right() float64

func (*Entity) SetMetadata

func (e *Entity) SetMetadata(k, v string)

SetMetadata sets the metadata for some key to some value. Empty value strings will not be stored.

func (*Entity) SetPos

func (e *Entity) SetPos(p floatgeom.Point2)

func (*Entity) SetX

func (e *Entity) SetX(x float64)

func (*Entity) SetY

func (e *Entity) SetY(y float64)

func (*Entity) Shift

func (e *Entity) Shift(delta floatgeom.Point2)

func (*Entity) ShiftDelta

func (e *Entity) ShiftDelta()

func (*Entity) ShiftPos

func (e *Entity) ShiftPos(x, y float64)

func (*Entity) ShiftX

func (e *Entity) ShiftX(x float64)

func (*Entity) ShiftY

func (e *Entity) ShiftY(y float64)

func (Entity) Top

func (e Entity) Top() float64

func (Entity) W

func (e Entity) W() float64

func (Entity) X

func (e Entity) X() float64

func (Entity) Y

func (e Entity) Y() float64

type Generator

type Generator struct {
	Position   floatgeom.Point2
	Dimensions floatgeom.Point2
	Speed      floatgeom.Point2

	Parent event.Caller

	Color      color.Color
	Renderable render.Renderable

	Mod mod.Mod

	Label collision.Label

	DrawLayers []int

	UseMouseTree     bool
	WithoutCollision bool

	Children         [][]Option
	ExplicitChildren []*Entity
}

type Option

type Option func(Generator) Generator

func And

func And(opts ...Option) Option

func WithChild

func WithChild(opts ...Option) Option

func WithChildren

func WithChildren(v [][]Option) Option

func WithColor

func WithColor(v color.Color) Option

func WithDimensions

func WithDimensions(v floatgeom.Point2) Option

func WithDrawLayers

func WithDrawLayers(v []int) Option

func WithExplicitChild added in v4.1.0

func WithExplicitChild(e *Entity) Option

func WithLabel

func WithLabel(v collision.Label) Option

func WithMod

func WithMod(v mod.Mod) Option

func WithOffset

func WithOffset(p floatgeom.Point2) Option

func WithParent

func WithParent(v event.Caller) Option

func WithPosition

func WithPosition(v floatgeom.Point2) Option

func WithRect

func WithRect(v floatgeom.Rect2) Option

func WithRenderable

func WithRenderable(v render.Renderable) Option

func WithSpeed

func WithSpeed(v floatgeom.Point2) Option

func WithUseMouseTree

func WithUseMouseTree(v bool) Option

func WithWithoutCollision

func WithWithoutCollision(v bool) Option

Directories

Path Synopsis
x
Package x provides experimental utilities
Package x provides experimental utilities
btn
btn/grid
Package grid provides structures for aligning grids of buttons
Package grid provides structures for aligning grids of buttons

Jump to

Keyboard shortcuts

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