Documentation ¶
Index ¶
- Constants
- func Bound(point, size image.Point) image.Rectangle
- func DPIScale(res int) int
- func Keypress(keys []ebiten.Key) bool
- func NewImageBound(bound image.Rectangle) *ebiten.Image
- func Pad(bound image.Rectangle, pad image.Point) image.Rectangle
- func Radian(degree float64) float64
- func SecondToTick(seconds float64) int
- func TickToSecond(ticks int) float64
- func Unpad(bound image.Rectangle, pad image.Point) image.Rectangle
- type Align
- type Animation
- type Clock
- type Component
- type Debug
- type Delta
- type DeltaAlgorithm
- type Entity
- type Font
- func (f *Font) Draw(str string, clr color.Color, img *ebiten.Image, point image.Point)
- func (f *Font) Load(src []byte, opts *opentype.FaceOptions) error
- func (f *Font) Write(str string, clr color.Color, img *ebiten.Image, point image.Point, align Align) image.Rectangle
- func (f *Font) WriteCenter(str string, clr color.Color, img *ebiten.Image) image.Rectangle
- type InitError
- type RenderState
- type Scene
- type Scroll
- type Sprite
- type Stage
- type Stream
- type Tileset
- type Transition
- type Vec
- func (vec *Vec) Arc(center image.Point, radius int, from, to float32)
- func (vec *Vec) Circle(center image.Point, radius int)
- func (vec *Vec) Draw(clr color.Color, img *ebiten.Image, o *ebiten.DrawTrianglesOptions)
- func (vec *Vec) DrawShader(clr color.Color, img *ebiten.Image, shader *ebiten.Shader, ...)
- func (vec *Vec) Line(to image.Point)
- func (vec *Vec) Move(to image.Point)
- func (vec *Vec) Rect(bounds image.Rectangle)
Constants ¶
const ( // Right moves an image to the right of a point. Right Align = 1 << iota // HCenter moves an image to the horizontal center of a point. HCenter // Left moves an image to the left of a point. Left // Top moves an image above a point. Top // VCenter moves an image to the vertical center of a point. VCenter // Bottom moves an image below a point. Bottom // Default is the default alignment of an image (to the right and below). Default = BottomRight TopLeft = Top | Left TopCenter = Top | HCenter TopRight = Top | Right CenterLeft = VCenter | Left Center = VCenter | HCenter CenterRight = VCenter | Right BottomLeft = Bottom | Left BottomCenter = Bottom | Center BottomRight = Bottom | Right )
Variables ¶
This section is empty.
Functions ¶
func DPIScale ¶
DPIScale scales the given resolution by the device's scale factor. This allows high-DPI rendering.
func Keypress ¶
func Keypress(keys []ebiten.Key) bool
Keypress checks if the key is pressed in the current frame.
func NewImageBound ¶
NewImageBound creates an image from a bound.
Types ¶
type Align ¶
type Align int
Align specifies the alignment to render an image at a point (x, y). Align must have at most one horizontal (AlignRight, AlignHCenter, AlignLeft) and vertical (AlignTop, AlignVCenter, AlignBottom) flag.
type Animation ¶
type Animation interface { Component // Draw renders the animation to the image. Draw(img *ebiten.Image) // Done checks if the animation has finished. Done() bool }
Animation is a effect rendered on a scene/sprite.
type Clock ¶
type Clock struct {
// contains filtered or unexported fields
}
Clock acts as a basic scheduler for operations. One tick is equivalent to a single frame, where 1 second is 60 frames.
func NewClockOnce ¶
NewClockOnce creates a new clock that triggers once after n seconds.
func (*Clock) Done ¶
Done checks if the clock's timer has triggered on the current tick. If the timer was set with ScheduleOnce, this will only return true one time.
func (*Clock) Schedule ¶
Schedule sets the clock's timer to trigger every n seconds. This will panic if n is too small to calculate ticks for.
func (*Clock) ScheduleOnce ¶
ScheduleOnce sets the clock's timer to trigger once, after n seconds. This will panic if n is too small to calculate ticks for.
type Component ¶ added in v0.2.0
type Component interface {
Update() error
}
Component is a state that updates every tick. Update must be called before using the component's state, i.e
type myComponent struct { sub Component }
func (mc *myComponent) Update() error { if err := mc.sub.Update(); err != nil { return err } // use mc.sub here }
or else accessing the component's state may result in undefined behaviour/panics.
type Debug ¶
type Debug struct {
Font *Font
}
Debug is a struct of options for debug mode. A font is required to render certain elements.
type Delta ¶
type Delta struct {
// contains filtered or unexported fields
}
Delta is a delta that changes over time.
func NewDelta ¶
func NewDelta( dalgo DeltaAlgorithm, delta image.Point, period float64, ) *Delta
NewDelta creates an delta with the total delta, and the period over which to increase the current delta.
func (*Delta) Delta ¶
Delta returns the current delta. This will panic if delta has not been updated yet.
type DeltaAlgorithm ¶
type DeltaAlgorithm int
DeltaAlgorithm specifies the algorithm to use when generating deltas.
const ( // Linear specifies a delta is constant. Linear DeltaAlgorithm = iota // Exponential specifies a delta in exponential (e^x) space. Exponential )
type Entity ¶
type Entity struct { Sprite *Transition Op *ebiten.DrawImageOptions }
Entity is a sprite with rendering state. While a sprite renders to an image, an entity handles drawing the rendered image to the screen. Op is the options used to draw the entity to the screen.
func NewEntities ¶
NewEntities constructs a slice of entities from several sprites.
type Font ¶
Font is a wrapper around a fontface, used to render text to images.
func (*Font) Draw ¶
Draw renders the text on an image at the point as-is (i.e without any alignment). NOTE: point is the bottom-left point of the text.
func (*Font) Load ¶
func (f *Font) Load(src []byte, opts *opentype.FaceOptions) error
Load loads an OpenType fontface from a source.
type InitError ¶ added in v0.2.0
type InitError struct {
// contains filtered or unexported fields
}
InitError indicates that the component has not been updated yet with .Update.
type RenderState ¶
type RenderState int
RenderState represents the rendering state of an entity on the stage.
The render lifecycle has several states: Hidden (default): The entity is not rendering to the screen. Entering: An enter transition is being rendered on the entity. Visible: The entity is rendering normally. Exiting: An exit transition is being rendered on the entity.
After an entity has exited the stage, the render state will change back to Hidden.
const ( Hidden RenderState = iota Entering Visible Exiting )
func (RenderState) String ¶
func (i RenderState) String() string
type Scene ¶
type Scene interface { // Update updates the state of the scene, if any. Update(stage *Stage) error // Draw renders the scene on screen. Draw(screen *ebiten.Image) // Enter returns the enter transition of the scene, if any. Enter() Animation // Exit returns the enter transition of the scene, if any. Exit() Animation // Entities returns a slice of entities to render on the scene. Entities() []*Entity }
Scene is a special kind of entity that draws directly to a screen instead of rendering to a image.
type Scroll ¶
type Scroll struct { Font *Font // contains filtered or unexported fields }
Scroll allows several pieces of text to be scrolled across an image.
func (*Scroll) Draw ¶
Draw renders the scroll on a new image. point is the bottom-left point of the scroll.
func (*Scroll) Skip ¶
func (s *Scroll) Skip()
Skip causes the next render to render the whole text instead of waiting for scrolling.
type Sprite ¶
type Sprite interface { Component // Render renders the sprite to an image, given the screen's size. Render(entity *Entity, size image.Point) *ebiten.Image }
Sprite is an image with state.
type Stage ¶
type Stage struct {
// contains filtered or unexported fields
}
Stage is a scene manager which implements the ebiten.Game interface. The current scene must never be nil. If debug is not nil, debug mode is enabled.
func NewStage ¶
NewStage creates a stage with an inital scene. NOTE: The initial scene's enter animation is rendered!
func (*Stage) Draw ¶
func (s *Stage) Draw(screen *ebiten.Image)
Draw renders the current scene to the screen.
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream is a stream of text over a channel.
type Tileset ¶
type Tileset struct {
// contains filtered or unexported fields
}
Tileset is a image with tiles that can be tiled into a single sprite.
func NewTileset ¶
NewTileset creates a new tileset with a image and tile size. If cache is true, calls to the Tile method will lazily cache tile images for faster loading.
func (*Tileset) Render ¶
Render renders the tileset to an image, given a tilemap. The tilemap must have at least one row, and all rows must have equal length.
type Transition ¶
type Transition struct {
// contains filtered or unexported fields
}
func (*Transition) Draw ¶
func (t *Transition) Draw(image *ebiten.Image)
Draw draws the transition onto the image.
func (*Transition) Hide ¶
func (t *Transition) Hide(exit Animation)
Hide sets the render state to Hidden after rendering an exit transition. If exit is nil, the state is immediately changed.
func (*Transition) RenderState ¶
func (t *Transition) RenderState() RenderState
RenderState returns the rendering state of the transition.
func (*Transition) Show ¶
func (t *Transition) Show(enter Animation)
Show sets the render state to Visible after rendering an enter animation. If enter is nil, the state is immediately changed.
func (*Transition) Update ¶
func (t *Transition) Update() error
Update updates the transition's state.
type Vec ¶
Vec is a wrapper around ebiten's vector path for drawing operations.
func (*Vec) Arc ¶
Arc draws a circular arc with a center and radius. from and to are angles in radians.
func (*Vec) DrawShader ¶
func (vec *Vec) DrawShader( clr color.Color, img *ebiten.Image, shader *ebiten.Shader, o *ebiten.DrawTrianglesShaderOptions, )
DrawShader renders this vector path with a shader to an image.