glossary

package
v0.0.0-...-93f9cd5 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2021 License: MIT, MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnchorTxt

func AnchorTxt(txt *text.Text, pos pixel.Vec, anchorX AnchorX, anchorY AnchorY, desc string)

AnchorTxt positions a text.Text label with an anchor alignment.

func AtlasASCII

func AtlasASCII() *text.Atlas

AtlasASCII returns an atlas which allows you to draw only ASCII characters. Atlas is a set of generated textures for glyphs in a specific font.

func Direction

func Direction(from, to pixel.Vec) (dirVecNormalized pixel.Vec)

Direction returns a direction as a normalized vector. This vector always has a length of 1.

func ItfsToStrs

func ItfsToStrs(itfs []interface{}) (strs []string)

ItfsToStrs converts []interface{} to []string.

func LoadPicture

func LoadPicture(_bytes []byte) (pixel.Picture, error)

LoadPicture decodes an image that has been encoded in a registered format. (png, jpg, etc.) Format registration is typically done by an init function in the codec-specific package. (with underscore import)

func LoadPictureFromFile

func LoadPictureFromFile(path string) (pixel.Picture, error)

LoadPictureFromFile decodes an image that has been encoded in a registered format. (png, jpg, etc.) Format registration is typically done by an init function in the codec-specific package. (with underscore import)

func LoadTrueTypeFont

func LoadTrueTypeFont(bytes []byte, size float64) (font.Face, error)

LoadTrueTypeFont creates and returns a font face.

func LoadTrueTypeFontFromFile

func LoadTrueTypeFontFromFile(path string, size float64) (font.Face, error)

LoadTrueTypeFontFromFile creates and returns a font face.

func NewAtlas

func NewAtlas(nameAssetTTF string, size float64, runeSet []rune) *text.Atlas

NewAtlas newly loads and prepares a set of images of characters or symbols to be drawn. Arg runeSet would be set to nil if non-ASCII characters are not in use.

func NewSprite

func NewSprite(nameAsset string) *pixel.Sprite

NewSprite converts an asset (resource) into a sprite. Returns nil if there is an error. AssetNames() or AssetDir() might be helpful when utilizing this function.

func RandomNiceColor

func RandomNiceColor() pixel.RGBA

RandomNiceColor from Platformer. Is not completely random without rand.Seed().

func VerticesOfRect

func VerticesOfRect(r pixel.Rect) []pixel.Vec

VerticesOfRect returns 4 vertices of a rectangle in a form of a slice of vectors.

Types

type Aim

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

Aim for experiments.

func (Aim) Draw

func (aim Aim) Draw(t pixel.Target)

Draw aim as a dot.

type AnchorX

type AnchorX int

AnchorX - Left, Center, Right

const (
	Left AnchorX = 1 + iota
	Center
	Right
)

enum AnchorX

type AnchorY

type AnchorY int

AnchorY - Top, Middle, Bottom

const (
	Top AnchorY = 1 + iota
	Middle
	Bottom
)

enum AnchorY

type Camera

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

Camera is a tool to get the screen center to be able to follow a certain point on a plane.

func NewCamera

func NewCamera(_pos pixel.Vec, _screenBound pixel.Rect) *Camera

NewCamera is a constructor.

func (Camera) Angle

func (camera Camera) Angle() float64

Angle returns the angle of a camera in radians.

func (*Camera) Move

func (camera *Camera) Move(distance pixel.Vec)

Move camera a specified distance.

func (*Camera) MoveTo

func (camera *Camera) MoveTo(posAim pixel.Vec)

MoveTo () moves a camera to a point on a plane.

func (*Camera) Rotate

func (camera *Camera) Rotate(degree float64)

Rotate a camera by certain degrees. + ) Counterclockwise - ) Clockwise

func (*Camera) SetScreenBound

func (camera *Camera) SetScreenBound(screenBound pixel.Rect)

SetScreenBound of a camera.

func (Camera) Transform

func (camera Camera) Transform() pixel.Matrix

Transform returns a transformation matrix of a camera. Use Transform().Project() to convert a game position to a screen position. To do the inverse operation, it is recommended to use Camera#Unproject() rather than Transform().Unproject()

func (Camera) Unproject

func (camera Camera) Unproject(screenPosition pixel.Vec) (gamePosition pixel.Vec)

Unproject converts a screen position to a game position. This method is a replacement of Transform().Unproject() which might return a bit off position.

func (*Camera) Update

func (camera *Camera) Update(dt float64)

Update a camera's current physical state (physics) by calculating coordinates X, Y, Z and its angle after delta time in seconds.

func (Camera) XY

func (camera Camera) XY() pixel.Vec

XY returns the X and Y of a camera as a vector.

func (Camera) XYZ

func (camera Camera) XYZ() (float64, float64, float64)

XYZ returns a camera's coordinates value X, Y, and Z in a current physical state.

func (Camera) Z

func (camera Camera) Z() float64

Z returns the zoom depth of a camera.

func (*Camera) Zoom

func (camera *Camera) Zoom(byLevel float64)

Zoom in and out with a camera by certain levels. + ) Zoom in - ) Zoom out

type DtWatch

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

DtWatch is a delta time checker.

func (*DtWatch) Dt

func (watch *DtWatch) Dt() (deltaTimeInSeconds float64)

Dt since last Dt() or DtNano(). .Start() must be called prior to calling this method.

func (*DtWatch) DtNano

func (watch *DtWatch) DtNano() (deltaTimeInNanosec time.Duration)

DtNano since last Dt() or DtNano(). It returns a time instance with nanosecond precision. .Start() must be called prior to calling this method.

func (DtWatch) DtSinceStart

func (watch DtWatch) DtSinceStart() (deltaTimeInSeconds float64)

DtSinceStart is dt since last Start(). .Start() must be called prior to calling this method.

func (DtWatch) GetTimeStarted

func (watch DtWatch) GetTimeStarted() time.Time

GetTimeStarted gets the time it started. .Start() must be called prior to calling this method.

func (DtWatch) IsStarted

func (watch DtWatch) IsStarted() bool

IsStarted () determines whether it has started or not. .Start() is <not> required in order to call this method.

func (*DtWatch) SetTimeStarted

func (watch *DtWatch) SetTimeStarted(t time.Time)

SetTimeStarted sets the time it started. .Start() must be called prior to calling this method.

func (*DtWatch) Start

func (watch *DtWatch) Start()

Start () is required in order to call other methods of a DtWatch.

type Explosions

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

Explosions is an imdraw and a manager of all particles.

func NewExplosions

func NewExplosions(width, height float64, colors []color.Color, precision int) *Explosions

NewExplosions is a constructor. The 3rd argument colors can be nil. Then it will use its default value of a color set.

func (*Explosions) Draw

func (e *Explosions) Draw(t pixel.Target)

Draw guarantees the thread safety, though it's not a necessary condition. It is quite dangerous to access this struct's member (imdraw) directly from outside these methods.

func (*Explosions) ExplodeAt

func (e *Explosions) ExplodeAt(pos, vel pixel.Vec)

ExplodeAt generates an explosion at given point.

func (Explosions) IsExploding

func (e Explosions) IsExploding() bool

IsExploding determines whether this Explosions is about to be updated or not. Pass lock by value warning from (e Explosions) should be ignored, because an Explosions here is just passed as a read only argument.

func (*Explosions) SetBound

func (e *Explosions) SetBound(width, height float64)

SetBound of particles. All particles bounce when they meet this bound.

func (*Explosions) Update

func (e *Explosions) Update(dt float64)

Update animates an Explosions. An Explosions is drawn on an imdraw.

type FPSWatch

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

FPSWatch measures the real-time frame rates and displays it on a target canvas.

func NewFPSWatch

func NewFPSWatch(
	additionalCaption string, _pos pixel.Vec,
	_anchorY AnchorY, _anchorX AnchorX,
	_colorBg, _colorTxt color.Color,
) (watch *FPSWatch)

NewFPSWatch is a constructor.

func NewFPSWatchSimple

func NewFPSWatchSimple(_pos pixel.Vec, _anchorY AnchorY, _anchorX AnchorX) *FPSWatch

NewFPSWatchSimple is a constructor.

func (*FPSWatch) Draw

func (watch *FPSWatch) Draw(t pixel.Target)

Draw FPSWatch.

func (FPSWatch) GetFPS

func (watch FPSWatch) GetFPS() int

GetFPS returns the most recent FPS recorded. A non-ptr FPSWatch as a read only argument passes lock by value within itself but that seems totally fine.

func (*FPSWatch) Poll

func (watch *FPSWatch) Poll()

Poll () should be called only once and in every single frame. (Obligatory) This is an extended behavior of Update() like funcs.

func (*FPSWatch) SetPos

func (watch *FPSWatch) SetPos(pos pixel.Vec, anchorY AnchorY, anchorX AnchorX)

SetPos to a position in screen coords.

func (*FPSWatch) Start

func (watch *FPSWatch) Start()

Start ticking every second.

type Galaxy

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

Galaxy is an imd of stars.

func NewGalaxy

func NewGalaxy(_width, _height, _speed float64) *Galaxy

NewGalaxy is a constructor.

func (*Galaxy) Draw

func (galaxy *Galaxy) Draw(t pixel.Target)

Draw guarantees the thread safety, though it's not a necessary condition. It is quite dangerous to access this struct's member (imdraw) directly from outside these methods.

func (*Galaxy) SetSpeed

func (galaxy *Galaxy) SetSpeed(_speed float64)

SetSpeed is a setter.

func (Galaxy) Speed

func (galaxy Galaxy) Speed() float64

Speed is a getter. Pass lock by value warning from (galaxy Galaxy) should be ignored, because a galaxy here is just passed as a read only argument.

func (*Galaxy) Update

func (galaxy *Galaxy) Update(dt float64)

Update animates a galaxy.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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