ebiten

package
v0.0.0-...-7f92c57 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package ebiten provides a renderer implementation using Ebiten

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PanicScreen

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

PanicScreen represents the system to draw a panic message on the screen.

func CreatePanicScreen

func CreatePanicScreen(errorMessage string) *PanicScreen

CreatePanicScreen creates a new panic screen.

func (*PanicScreen) Draw

func (s *PanicScreen) Draw(screen *ebiten.Image)

Draw draws the game screen by one frame.

The give argument represents a screen image. The updated content is adopted as the game screen.

func (*PanicScreen) Layout

func (s *PanicScreen) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int)

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.

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.

func (*PanicScreen) Update

func (s *PanicScreen) Update() error

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.

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).

type Renderer

type Renderer struct {
	*d2util.GlyphPrinter
	// contains filtered or unexported fields
}

Renderer is an implementation of a renderer

func CreateRenderer

func CreateRenderer(cfg *d2config.Configuration) (*Renderer, error)

CreateRenderer creates an ebiten renderer instance

func (*Renderer) CreateSurface

func (r *Renderer) CreateSurface(surface d2interface.Surface) (d2interface.Surface, error)

CreateSurface creates a renderer surface from an existing surface

func (*Renderer) CurrentFPS

func (r *Renderer) CurrentFPS() float64

CurrentFPS returns the current frames per second of the renderer

func (*Renderer) Draw

func (r *Renderer) Draw(screen *ebiten.Image)

Draw updates the screen with the given *ebiten.Image

func (*Renderer) GetCursorPos

func (r *Renderer) GetCursorPos() (x, y int)

GetCursorPos returns the current cursor position x,y coordinates

func (*Renderer) GetRendererName

func (*Renderer) GetRendererName() string

GetRendererName returns the name of the renderer

func (*Renderer) GetVSyncEnabled

func (r *Renderer) GetVSyncEnabled() bool

GetVSyncEnabled returns a boolean for whether or not vsync is enabled

func (*Renderer) IsDrawingSkipped

func (r *Renderer) IsDrawingSkipped() bool

IsDrawingSkipped returns a bool for whether or not the drawing has been skipped

func (*Renderer) IsFullScreen

func (r *Renderer) IsFullScreen() bool

IsFullScreen returns a boolean for whether or not the renderer is currently set to fullscreen

func (*Renderer) Layout

func (r *Renderer) Layout(_, _ int) (width, height int)

Layout returns the renderer screen width and height

func (*Renderer) NewSurface

func (r *Renderer) NewSurface(width, height int) d2interface.Surface

NewSurface creates a new surface

func (*Renderer) Run

func (r *Renderer) Run(f renderCallback, u updateCallback, width, height int, title string) error

Run initializes the renderer

func (*Renderer) SetFullScreen

func (r *Renderer) SetFullScreen(fullScreen bool)

SetFullScreen sets the renderer to fullscreen, given a boolean

func (*Renderer) SetVSyncEnabled

func (r *Renderer) SetVSyncEnabled(vsync bool)

SetVSyncEnabled enables vsync, given a boolean

func (*Renderer) SetWindowIcon

func (*Renderer) SetWindowIcon(fileName string)

SetWindowIcon sets the icon for the window, visible in the chrome of the window

func (*Renderer) ShowPanicScreen

func (r *Renderer) ShowPanicScreen(message string)

ShowPanicScreen shows a panic message in a forever loop

func (*Renderer) Update

func (r *Renderer) Update() error

Update calls the game's logical update function (the `Advance` method)

Jump to

Keyboard shortcuts

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