Documentation
¶
Index ¶
- Constants
- Variables
- func C565toRGBA(c uint16) color.RGBA
- func IsKeyJustPressed(key Key) bool
- func IsKeyJustReleased(key Key) bool
- func IsKeyPressed(key Key) bool
- func KeyPressDuration(key Key) int
- func RGBATo565(c color.RGBA) uint16
- type DrawImageOptions
- type Game
- type GeoM
- func (g *GeoM) Apply(x, y float32) (float32, float32)
- func (g *GeoM) Concat(other GeoM)
- func (g *GeoM) Element(i, j int) float32
- func (g *GeoM) Invert()
- func (g *GeoM) IsInvertible() bool
- func (g *GeoM) Reset()
- func (g *GeoM) Rotate(theta float32)
- func (g *GeoM) Scale(x, y float32)
- func (g *GeoM) SetElement(i, j int, element float32)
- func (g *GeoM) Skew(skewX, skewY float32)
- func (g *GeoM) String() string
- func (g *GeoM) Translate(tx, ty float32)
- type Hardware
- type Image
- type Key
- type RotatedDisplay
Constants ¶
const ( KeyArrowLeft = KeyLeft KeyArrowRight = KeyRight KeyArrowUp = KeyUp KeyArrowDown = KeyDown )
const ( Rotation0 = iota Rotation90 Rotation180 Rotation270 )
Clockwise rotation of the screen.
const GeoMDim = 3
GeoMDim is a dimension of a GeoM.
const (
KeyMax = 20
)
Variables ¶
var Termination = errors.New("Regular termination")
Functions ¶
func C565toRGBA ¶
C565toRGBA converts a uint16 color to color.RGBA
func IsKeyJustPressed ¶
IsKeyJustPressed returns a boolean value indicating whether the given key is pressed just in the current tick.
IsKeyJustPressed must be called in a game's Update, not Draw.
IsKeyJustPressed is concurrent safe.
func IsKeyJustReleased ¶
IsKeyJustReleased returns a boolean value indicating whether the given key is released just in the current tick.
IsKeyJustReleased must be called in a game's Update, not Draw.
IsKeyJustReleased is concurrent safe.
func IsKeyPressed ¶ added in v0.2.0
func KeyPressDuration ¶
KeyPressDuration returns how long the key is pressed in ticks (Update).
KeyPressDuration must be called in a game's Update, not Draw.
KeyPressDuration is concurrent safe.
Types ¶
type DrawImageOptions ¶ added in v0.3.0
type DrawImageOptions struct {
GeoM GeoM
}
type Game ¶
type Game interface {
// Update updates a game by one tick. The given argument represents a screen image.
//
// Update updates only the game logic and Draw draws the screen.
//
// You can assume that Update is always called TPS-times per second (60 by default), and you can assume
// that the time delta between two Updates is always 1 / TPS [s] (1/60[s] by default). As Ebitengine already
// adjusts the number of Update calls, you don't have to measure time deltas in Update by e.g. OS timers.
//
// An actual TPS is available by ActualTPS(), and the result might slightly differ from your expected TPS,
// but still, your game logic should stick to the fixed time delta and should not rely on ActualTPS() value.
// This API is for just measurement and/or debugging. In the long run, the number of Update calls should be
// adjusted based on the set TPS on average.
//
// An actual time delta between two Updates might be bigger than expected. In this case, your game's
// Update or Draw takes longer than they should. In this case, there is nothing other than optimizing
// your game implementation.
//
// In the first frame, it is ensured that Update is called at least once before Draw. You can use Update
// to initialize the game state.
//
// After the first frame, Update might not be called or might be called once
// or more for one frame. The frequency is determined by the current TPS (tick-per-second).
//
// If the error returned is nil, game execution proceeds normally.
// If the error returned is Termination, game execution halts, but does not return an error from RunGame.
// If the error returned is any other non-nil value, game execution halts and the error is returned from RunGame.
Update() error
// Draw draws the game screen by one frame.
//
// The give argument represents a screen image. The updated content is adopted as the game screen.
//
// The frequency of Draw calls depends on the user's environment, especially the monitors refresh rate.
// For portability, you should not put your game logic in Draw in general.
Draw(screen *Image)
// Layout accepts a native outside size in device-independent pixels and returns the game's logical screen
// size.
//
// On desktops, the outside is a window or a monitor (fullscreen mode). On browsers, the outside is a body
// element. On mobiles, the outside is the view's size.
//
// Even though the outside size and the screen size differ, the rendering scale is automatically adjusted to
// fit with the outside.
//
// Layout is called almost every frame.
//
// It is ensured that Layout is invoked before Update is called in the first frame.
//
// If Layout returns non-positive numbers, the caller can panic.
//
// You can return a fixed screen size if you don't care, or you can also return a calculated screen size
// adjusted with the given outside size.
//
// If the game implements the interface LayoutFer, Layout is never called and LayoutF is called instead.
Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int)
}
Game defines necessary functions for a game.
type GeoM ¶ added in v0.3.0
type GeoM struct {
// contains filtered or unexported fields
}
A GeoM represents a matrix to transform geometry when rendering an image.
The initial value is identity.
func (*GeoM) Apply ¶ added in v0.3.0
Apply pre-multiplies a vector (x, y, 1) by the matrix. In other words, Apply calculates GeoM * (x, y, 1)^T. The return value is x and y values of the result vector.
func (*GeoM) Concat ¶ added in v0.3.0
Concat multiplies a geometry matrix with the other geometry matrix. This is same as multiplying the matrix other and the matrix g in this order.
func (*GeoM) Invert ¶ added in v0.3.0
func (g *GeoM) Invert()
Invert inverts the matrix. If g is not invertible, Invert panics.
func (*GeoM) IsInvertible ¶ added in v0.3.0
IsInvertible returns a boolean value indicating whether the matrix g is invertible or not.
func (*GeoM) Rotate ¶ added in v0.3.0
Rotate rotates the matrix clockwise by theta. The unit is radian.
func (*GeoM) SetElement ¶ added in v0.3.0
SetElement sets an element at (i, j).
type Image ¶ added in v0.3.0
type Image struct {
// contains filtered or unexported fields
}
Image is a Wrapper for the pixel.Image type.
Image implements the Displayer interface.
func NewImage ¶ added in v0.3.0
NewImage creates a new Image with the given width and height.
It returns a pointer to the new Image.
func NewImageFromFS ¶ added in v0.3.0
NewImageFromFS creates a new Image from the filesystem.
func (*Image) ClearBuffer ¶ added in v0.3.0
func (i *Image) ClearBuffer()
ClearBuffer clears the buffer.
It implements the Displayer interface.
func (*Image) ClearDisplay ¶ added in v0.3.0
func (i *Image) ClearDisplay()
ClearDisplay clears the display.
It implements the Displayer interface.
func (*Image) Display ¶ added in v0.3.0
Display does nothing.
It implements the Displayer interface.
func (*Image) DrawImage ¶ added in v0.3.0
func (i *Image) DrawImage(dst Displayer, options DrawImageOptions)
DrawImage draws an image onto the display.
type Key ¶
type Key int
func AppendJustPressedKeys ¶
AppendJustPressedKeys append just pressed keyboard keys to keys and returns the extended buffer. Giving a slice that already has enough capacity works efficiently.
AppendJustPressedKeys must be called in a game's Update, not Draw.
AppendJustPressedKeys is concurrent safe.
func AppendJustReleasedKeys ¶
AppendJustReleasedKeys append just released keyboard keys to keys and returns the extended buffer. Giving a slice that already has enough capacity works efficiently.
AppendJustReleasedKeys must be called in a game's Update, not Draw.
AppendJustReleasedKeys is concurrent safe.
func AppendPressedKeys ¶
AppendPressedKeys append currently pressed keyboard keys to keys and returns the extended buffer. Giving a slice that already has enough capacity works efficiently.
AppendPressedKeys must be called in a game's Update, not Draw.
AppendPressedKeys is concurrent safe.
func PressedKeys
deprecated
func PressedKeys() []Key
PressedKeys returns a set of currently pressed keyboard keys.
PressedKeys must be called in a game's Update, not Draw.
Deprecated: as of v2.2. Use AppendPressedKeys instead.
type RotatedDisplay ¶
type RotatedDisplay struct {
Displayer
// contains filtered or unexported fields
}
func (*RotatedDisplay) Size ¶
func (d *RotatedDisplay) Size() (x, y int16)
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
GeoM
command
|
|
|
drawing
command
|
|
|
games
|
|
|
all
command
|
|
|
blocks
command
|
|
|
flappygopher
command
|
|
|
goradius
command
|
|
|
jumpingopher
command
|
|
|
snakegame
command
|
|

