game

package
v0.0.0-...-d5d5497 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string

Action represents a given action, such as "move-left".

type Actioner

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

Actioner converts bind actions into move directions.

func (*Actioner) Init

func (actioner *Actioner) Init()

Init does nothing at the moment.

func (*Actioner) Update

func (actioner *Actioner) Update(binds Binds) game.Desire

Update returns the current move direction from the current actions.

type Below

type Below struct {
	Data Data

	ApplyItem  func(wid id.WID)
	PickupItem func(wid id.WID)
	DropItem   func(wid id.WID)
	// contains filtered or unexported fields
}

func (*Below) Init

func (below *Below) Init(container *widget.Container, ctx ifs.RunContext, binds *Binds)

func (*Below) Refresh

func (below *Below) Refresh(ctx ifs.RunContext, objects game.Objects)

func (*Below) Update

func (below *Below) Update(ctx ifs.RunContext) game.Desire

type Binds

type Binds struct {
	Keys    map[ebiten.Key]Action
	Actions map[Action][]ebiten.Key
	// contains filtered or unexported fields
}

Binds provides a way to map input to game actions. Keys can be bound to actions that then allow the game state to determine if a particular action is active or not. Additionally, "multi actions" can be triggered when one or more actions are fulfilled.

func (*Binds) ActiveActions

func (b *Binds) ActiveActions() []Action

ActiveActions returns the current active actions.

func (*Binds) Init

func (b *Binds) Init()

Init initializes the binds structures and sets up some default binds.

func (*Binds) IsActionActive

func (b *Binds) IsActionActive(a Action) bool

IsActionActive returns if the given action is active.

func (*Binds) IsActionHeld

func (b *Binds) IsActionHeld(a Action) int

IsActionHeld returns how many ticks an action has been held. It returns -1 if the action is not held. It may return 0 on the first tick of being held.

func (*Binds) SetActionKeys

func (b *Binds) SetActionKeys(a Action, k []ebiten.Key)

SetActionKey sets an action associated with a key.

func (*Binds) SetMultiAction

func (b *Binds) SetMultiAction(action Action, actions []Action)

SetMultiAction sets an action associated with multiple actions.

func (*Binds) Update

func (b *Binds) Update(ctx ifs.RunContext)

Update is called per tick and synchronizes inputs to actions.

type Data

type Data interface {
	Archetype(id.UUID) game.Archetype
	ArchetypeImage(id.UUID) *ebiten.Image
	EnsureImage(archetype game.Archetype, zoom float64) (*ebiten.Image, error)
	LoadImage(path string, zoom float64) (*ebiten.Image, error)
}

type Grid

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

Grid renders a grid over an area.

func (*Grid) CellSize

func (grid *Grid) CellSize() (int, int)

CellSize returns the current cell size.

func (*Grid) Color

func (grid *Grid) Color() color.Color

Color returns the grid's line color.

func (*Grid) Draw

func (grid *Grid) Draw(ctx ifs.DrawContext)

Draw draws the grid to the screen.

func (*Grid) Offset

func (grid *Grid) Offset() (x, y int)

Offset returns the grid's placement offset.

func (*Grid) SetCellSize

func (grid *Grid) SetCellSize(w, h int)

SetCellSize sets the cell size.

func (*Grid) SetClickHandler

func (grid *Grid) SetClickHandler(cb func(x, y int))

SetClickHandler sets the grid's click handler.

func (*Grid) SetColor

func (grid *Grid) SetColor(c color.Color)

SetColor sets the grid's line color.

func (*Grid) SetHeldHandler

func (grid *Grid) SetHeldHandler(cb func(x, y int))

SetHeldHandler sets the grid's held handler.

func (*Grid) SetOffset

func (grid *Grid) SetOffset(x, y int)

SetOffset sets the grid's placemeent offset.

func (*Grid) SetSize

func (grid *Grid) SetSize(w, h int)

SetSize sets the grid's size.

func (*Grid) Size

func (grid *Grid) Size() (int, int)

Size returns the grid's size.

func (*Grid) Update

func (grid *Grid) Update(ctx ifs.RunContext)

type Hotbar

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

func (*Hotbar) Init

func (hb *Hotbar) Init(container *widget.Container, ctx ifs.RunContext, binds *Binds)

func (*Hotbar) Refresh

func (hb *Hotbar) Refresh()

func (*Hotbar) Update

func (hb *Hotbar) Update(ctx ifs.RunContext)

type Inventory

type Inventory struct {
	Data Data

	ApplyItem  func(wid id.WID, apply bool)
	DropItem   func(wid id.WID)
	PickupItem func(wid id.WID)
	// contains filtered or unexported fields
}

func (*Inventory) Init

func (inv *Inventory) Init(container *widget.Container, ctx ifs.RunContext)

func (*Inventory) Refresh

func (inv *Inventory) Refresh(ctx ifs.RunContext, objects game.Objects)

type MultiAction

type MultiAction struct {
	Actions []Action
	Action  Action
}

MultiAction maps one or more actions to represent another action. For example, if the two actions "move-left" and "move-up" are active, a multi action could convert that into a "move-up-left" action.

func (*MultiAction) HasActions

func (ma *MultiAction) HasActions(actions []Action) bool

HasActions returns if the passed in actions fulfill the multi action's actions.

type Pather

type Pather struct {
	Steps     []pathing.Step
	Location  *game.Location
	MoveTimer int
	// contains filtered or unexported fields
}

func (*Pather) Draw

func (p *Pather) Draw(ctx ifs.DrawContext, character *game.Character)

func (*Pather) Init

func (pather *Pather) Init()

func (*Pather) SetOffset

func (path *Pather) SetOffset(x, y int)

func (*Pather) Update

func (pather *Pather) Update(character *game.Character) game.Desire

Update returns the current move direction from the current paths.

type Scroller

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

Scroller allows an area within the limits of the window screen. It will allow areas smaller than the screen to be moved within the screen's bounds and will allow areas beyond the screen to be scrolled into view, up to the screen's bounds.

func (*Scroller) CenterTo

func (scroller *Scroller) CenterTo(x, y int)

CenterTo centers the scroller to the given coordinates.

func (*Scroller) GetConstrainedMousePosition

func (scroller *Scroller) GetConstrainedMousePosition() (int, int)

GetConstrainedMousePosition gets the mouse position fully constrained to the current window's dimensions.

func (*Scroller) Init

func (scroller *Scroller) Init()

Init sets some initial state.

func (*Scroller) Limit

func (scroller *Scroller) Limit() (int, int)

Limit returns the scroller's bounds.

func (*Scroller) Scroll

func (scroller *Scroller) Scroll() (int, int)

Scroll returns the current scroll positions.

func (*Scroller) SetHandler

func (scoller *Scroller) SetHandler(cb func(x, y int))

SetHandler sets the scroller's handler.

func (*Scroller) SetLimit

func (scroller *Scroller) SetLimit(x, y int)

SetLimit sets the scroller's bounds.

func (*Scroller) SetScroll

func (scroller *Scroller) SetScroll(x, y int)

SetScroll sets the current scroll position. This will call the handler if one is set.

func (*Scroller) Update

func (scroller *Scroller) Update(ctx ifs.RunContext) error

Update does the bulk of things.

type Sounds

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

Sounds provides a visual rendering of sounds in the game world. It manages their timeout, etc.

func (*Sounds) Add

func (sounds *Sounds) Add(message string, to game.Position, from game.Position)

Add creates and adds a sound to the world.

func (*Sounds) Draw

func (sounds *Sounds) Draw(ctx ifs.DrawContext)

Draw draws the sounds to the provided context's screen.

func (*Sounds) Offset

func (sounds *Sounds) Offset() (x, y int)

Offset returns the current visual offset of the sounds.

func (*Sounds) SetOffset

func (sounds *Sounds) SetOffset(x, y int)

SetOffset sets the current visual offset of the sounds.

func (*Sounds) Update

func (sounds *Sounds) Update()

Update manages the lifetime of sounds.

type Statbar

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

func (*Statbar) Init

func (hb *Statbar) Init(container *widget.Container, ctx ifs.RunContext)

func (*Statbar) Refresh

func (hb *Statbar) Refresh(ctx ifs.RunContext, c *game.Character, a game.CharacterArchetype)

Jump to

Keyboard shortcuts

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