gui

package
v0.0.0-...-d65a093 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package gui provides the graphical interface of the game world.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunEditor

func RunEditor(file string, world *core.World)

RunEditor initializes and runs the map editor with the specified file and world data. It loads the world data from the provided file, checks its validity, and configures the editor's settings.

This function is blocking!

func RunGame

func RunGame(title string, world *core.World, remote *remote.Client, mute bool) error

RunGame initializes the game window and starts the GUI loop. The Update function from core.World is called with 30 Ticks per second (see core.GameSpeed).

This function is blocking!

Types

type Editor

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

Editor implements the ebiten.Game interface and manages the Map-Editor.

func (*Editor) Draw

func (e *Editor) Draw(screen *ebiten.Image)

Draw draws the img screen by one frame.

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

func (*Editor) Layout

func (e *Editor) Layout(_, _ int) (int, int)

Layout accepts a native outside size in device-independent pixels and returns the img 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.

func (*Editor) Update

func (e *Editor) Update() error

Update updates an img by one tick. The given argument represents a screen image.

Update updates only the img 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 img 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 Game

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

Game implements the ebiten.Game interface and manages the GUI.

func (*Game) Draw

func (g *Game) Draw(screen *ebiten.Image)

Draw draws the img screen by one frame.

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

func (*Game) Layout

func (g *Game) Layout(_, _ int) (int, int)

Layout accepts a native outside size in device-independent pixels and returns the img 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.

func (*Game) Update

func (g *Game) Update() error

Update updates an img by one tick. The given argument represents a screen image.

Update updates only the img 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 img 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).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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