engine

package
v0.0.0-...-65675ae Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandomRange

func RandomRange(min int, max int) int

RandomRange returns a pseudo-random number in [min,max]

Types

type BaseEntity

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

func NewBaseEntity

func NewBaseEntity() *BaseEntity

func (BaseEntity) Equals

func (e BaseEntity) Equals(other Entity) bool

func (BaseEntity) ID

func (e BaseEntity) ID() EntityID

func (*BaseEntity) String

func (e *BaseEntity) String() string

type CountdownTimer

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

func NewCountdownTimer

func NewCountdownTimer(duration time.Duration, action func()) *CountdownTimer

func (CountdownTimer) Done

func (t CountdownTimer) Done() bool

func (CountdownTimer) PercentDone

func (t CountdownTimer) PercentDone() float64

func (*CountdownTimer) Update

func (t *CountdownTimer) Update(dt float64)

type Entity

type Entity interface {
	ID() EntityID
	Equals(Entity) bool
}

type EntityID

type EntityID int64

type Event

type Event interface {
}

type EventBus

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

func NewEventBus

func NewEventBus() *EventBus

func (*EventBus) Flush

func (e *EventBus) Flush()

Flush should be called between game ticks to ensure systems don't conflict with each other.

func (*EventBus) Publish

func (e *EventBus) Publish(event Event)

func (*EventBus) Subscribe

func (e *EventBus) Subscribe(event Event, subscriber Subscriber)

type PivotType

type PivotType int
const (
	PivotTop PivotType = iota
	PivotCenter
	PivotBottom
	PivotTopLeft
	PivotTopRight
	PivotBottomLeft
	PivotBottomRight
)

type Point

type Point struct {
	X int
	Y int
}

func (*Point) Set

func (p *Point) Set(x int, y int)

func (*Point) Translate

func (p *Point) Translate(dx int, dy int)

func (Point) Unpack

func (p Point) Unpack() (x int, y int)

type Rect

type Rect struct {
	Position Vector
	Width    float64
	Height   float64
}

func (Rect) Intersects

func (r Rect) Intersects(other Rect) bool

func (Rect) WithinBounds

func (r Rect) WithinBounds(v Vector) bool

type Sprite

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

func NewBlankSprite

func NewBlankSprite(width int, height int) Sprite

func NewBlankSpriteWithPivot

func NewBlankSpriteWithPivot(width int, height int, pivot Vector) Sprite

func NewFilledSprite

func NewFilledSprite(width int, height int, c color.Color) Sprite

func NewSpriteFromImage

func NewSpriteFromImage(image *ebiten.Image) Sprite

func NewSpriteFromImageWithPivot

func NewSpriteFromImageWithPivot(image *ebiten.Image, pivot Vector) Sprite

func NewSpriteFromImageWithPivotType

func NewSpriteFromImageWithPivotType(image *ebiten.Image, pivotType PivotType) Sprite

func NewSpriteFromSprite

func NewSpriteFromSprite(s Sprite) Sprite

func (Sprite) Draw

func (s Sprite) Draw(source Sprite)

Draw draws source sprite on the sprite.

func (Sprite) DrawAtPoint

func (s Sprite) DrawAtPoint(source Sprite, p Point)

DrawAtVector draws source sprite on the sprite at given point.

func (Sprite) DrawAtPosition

func (s Sprite) DrawAtPosition(source Sprite, x int, y int)

DrawAtPosition draws source sprite on the sprite at given position.

func (Sprite) DrawAtVector

func (s Sprite) DrawAtVector(source Sprite, v Vector)

DrawAtVector draws source sprite on the sprite at given vector.

func (Sprite) DrawInSection

func (s Sprite) DrawInSection(source Sprite, rect Rect)

func (Sprite) Height

func (s Sprite) Height() int

func (Sprite) Image

func (s Sprite) Image() *ebiten.Image

func (Sprite) IsZero

func (s Sprite) IsZero() bool

func (Sprite) Pivot

func (s Sprite) Pivot() Vector

func (*Sprite) Scale

func (s *Sprite) Scale(scale Vector)

func (*Sprite) SetPivot

func (s *Sprite) SetPivot(p Vector)

func (Sprite) Size

func (s Sprite) Size() (width int, height int)

func (Sprite) Width

func (s Sprite) Width() int

type Sprites

type Sprites []Sprite

func (Sprites) Random

func (s Sprites) Random() Sprite

type Subscriber

type Subscriber interface {
	HandleEvent(event Event)
}

type Vector

type Vector struct {
	X float64
	Y float64
}

func NewPivotForImage

func NewPivotForImage(image *ebiten.Image, pivotType PivotType) Vector

func NewPivotForSprite

func NewPivotForSprite(sprite Sprite, pivotType PivotType) Vector

func (Vector) Add

func (v Vector) Add(other Vector) Vector

func (Vector) Distance

func (v Vector) Distance(other Vector) float64

func (Vector) IsZero

func (v Vector) IsZero() bool

func (Vector) Length

func (v Vector) Length() float64

func (Vector) Mul

func (v Vector) Mul(factor float64) Vector

func (Vector) Normalized

func (v Vector) Normalized() Vector

func (*Vector) Set

func (v *Vector) Set(x float64, y float64)

func (Vector) Sub

func (v Vector) Sub(other Vector) Vector

func (*Vector) Translate

func (v *Vector) Translate(dx float64, dy float64)

func (Vector) Unpack

func (v Vector) Unpack() (x float64, y float64)

Jump to

Keyboard shortcuts

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