Documentation ¶
Overview ¶
Package ebiten provides a renderer implementation using Ebiten
Index ¶
- type PanicScreen
- type Renderer
- func (r *Renderer) CreateSurface(surface d2interface.Surface) (d2interface.Surface, error)
- func (r *Renderer) CurrentFPS() float64
- func (r *Renderer) Draw(screen *ebiten.Image)
- func (r *Renderer) GetCursorPos() (x, y int)
- func (*Renderer) GetRendererName() string
- func (r *Renderer) GetVSyncEnabled() bool
- func (r *Renderer) IsDrawingSkipped() bool
- func (r *Renderer) IsFullScreen() bool
- func (r *Renderer) Layout(_, _ int) (width, height int)
- func (r *Renderer) NewSurface(width, height int) d2interface.Surface
- func (r *Renderer) Run(f renderCallback, u updateCallback, width, height int, title string) error
- func (r *Renderer) SetFullScreen(fullScreen bool)
- func (r *Renderer) SetVSyncEnabled(vsync bool)
- func (*Renderer) SetWindowIcon(fileName string)
- func (r *Renderer) ShowPanicScreen(message string)
- func (r *Renderer) Update() error
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 ¶
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 ¶
GetCursorPos returns the current cursor position x,y coordinates
func (*Renderer) GetRendererName ¶
GetRendererName returns the name of the renderer
func (*Renderer) GetVSyncEnabled ¶
GetVSyncEnabled returns a boolean for whether or not vsync is enabled
func (*Renderer) IsDrawingSkipped ¶
IsDrawingSkipped returns a bool for whether or not the drawing has been skipped
func (*Renderer) IsFullScreen ¶
IsFullScreen returns a boolean for whether or not the renderer is currently set to fullscreen
func (*Renderer) NewSurface ¶
func (r *Renderer) NewSurface(width, height int) d2interface.Surface
NewSurface creates a new surface
func (*Renderer) SetFullScreen ¶
SetFullScreen sets the renderer to fullscreen, given a boolean
func (*Renderer) SetVSyncEnabled ¶
SetVSyncEnabled enables vsync, given a boolean
func (*Renderer) SetWindowIcon ¶
SetWindowIcon sets the icon for the window, visible in the chrome of the window
func (*Renderer) ShowPanicScreen ¶
ShowPanicScreen shows a panic message in a forever loop