client

package
v0.0.0-...-6aaa5b3 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2025 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultGameWidth  = 640
	DefaultGameHeight = 480
)

Game defaults.

Variables

View Source
var Version = ""

The client version.

Functions

This section is empty.

Types

type Game

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

Game values represent the game state.

func NewGame

func NewGame(log logger.Logger, w, h int, id, name, desc string) *Game

NewGame creates and initializes a new Game object.

func (*Game) APIToken

func (g *Game) APIToken() string

APIToken returns the API token.

func (*Game) APIURL

func (g *Game) APIURL() string

APIURL returns the API URL.

func (*Game) AddImage

func (g *Game) AddImage(img *Image)

AddImage adds an image to the game.

func (*Game) AddObject

func (g *Game) AddObject(obj *Object)

AddObject adds an object to the game.

func (*Game) AddSubject

func (g *Game) AddSubject(sub *Object)

AddSubject adds a subject to the game.

func (*Game) Draw

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

Draw renders the game state and all objects each frame.

func (*Game) H

func (g *Game) H() int

H returns the game height.

func (*Game) ID

func (g *Game) ID() string

ID returns the game ID.

func (*Game) Layout

func (g *Game) Layout(w, h int) (int, int)

Layout returns the game object dimensions.

func (*Game) Load

func (g *Game) Load() (rErr error)

Load retrieves a persisted game state.

func (*Game) MarshalJSON

func (g *Game) MarshalJSON() ([]byte, error)

MarshalJSON serializes the game to JSON.

func (*Game) Name

func (g *Game) Name() string

Name returns the game name.

func (*Game) Run

func (g *Game) Run(ctx context.Context) error

Run starts the game processing.

func (*Game) Save

func (g *Game) Save() (rErr error)

Save persists a game state.

func (*Game) SetAPIToken

func (g *Game) SetAPIToken(apiToken string)

SetAPIToken sets the API token.

func (*Game) SetAPIURL

func (g *Game) SetAPIURL(apiURL string)

SetAPIURL sets the API URL.

func (*Game) SetH

func (g *Game) SetH(h int)

SetH sets the game height.

func (*Game) SetID

func (g *Game) SetID(id string)

SetID sets the game ID.

func (*Game) SetName

func (g *Game) SetName(name string)

SetName sets the game name.

func (*Game) SetScript

func (g *Game) SetScript(src string)

SetScript sets the game script.

func (*Game) SetW

func (g *Game) SetW(w int)

SetW sets the game width.

func (*Game) UnmarshalJSON

func (g *Game) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes the game from JSON.

func (*Game) Update

func (g *Game) Update() error

Update updates the game state each frame.

func (*Game) W

func (g *Game) W() int

W returns the game width.

type Image

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

Image values represent the images in the game.

func NewImage

func NewImage(id, name string, data []byte, w, h int) *Image

NewImage creates and initializes a new image object.

func (*Image) MarshalJSON

func (i *Image) MarshalJSON() ([]byte, error)

MarshalJSON serializes the image to JSON.

func (*Image) UnmarshalJSON

func (i *Image) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes the image from JSON.

type Object

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

Object values represent the objects in the game.

func NewObject

func NewObject(
	game *Game,
	id, name, img string,
	data map[string]any,
) *Object

NewObject creates and initializes a new object.

func NewObjectFromMap

func NewObjectFromMap(m map[string]any) *Object

NewObjectFromMap creates a new object from a map.

func NewSubject

func NewSubject(
	game *Game,
	id, name, img string,
	data map[string]any,
) *Object

NewSubject creates and initializes a new subject object.

func (*Object) Draw

func (o *Object) Draw(screen *ebiten.Image)

Draw renders the object each frame.

func (*Object) Layout

func (o *Object) Layout(w, h int) (int, int)

Layout returns the object dimensions.

func (*Object) Map

func (o *Object) Map() map[string]any

func (*Object) MarshalJSON

func (o *Object) MarshalJSON() ([]byte, error)

MarshalJSON serializes the object to JSON.

func (*Object) SetData

func (o *Object) SetData(data map[string]any)

SetData sets the object data.

func (*Object) SetH

func (o *Object) SetH(h int)

SetH sets the object height.

func (*Object) SetHidden

func (o *Object) SetHidden(hidden bool)

SetHidden sets the object hidden state.

func (*Object) SetImage

func (o *Object) SetImage(img string)

SetImage sets the object image.

func (*Object) SetName

func (o *Object) SetName(name string)

SetName sets the object name.

func (*Object) SetR

func (o *Object) SetR(r int)

SetR sets the object rotation.

func (*Object) SetW

func (o *Object) SetW(w int)

SetW sets the object width.

func (*Object) SetX

func (o *Object) SetX(x int)

SetX sets the object x-coordinate.

func (*Object) SetY

func (o *Object) SetY(y int)

SetY sets the object y-coordinate.

func (*Object) SetZ

func (o *Object) SetZ(z int)

SetZ sets the object z-index.

func (*Object) UnmarshalJSON

func (o *Object) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes the object from JSON.

Jump to

Keyboard shortcuts

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