visual

package
v0.3.26 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2021 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

Package visual implements the graphical interface for Spy Cards Online.

Index

Constants

This section is empty.

Variables

View Source
var (
	// AsNPC causes an NPC to play the game instead of the user.
	AsNPC string
	// VersusNPC forces the game into singleplayer mode.
	VersusNPC string
)

Functions

func Loop

func Loop(ctx context.Context, looper Looper) (*router.PageInfo, error)

Loop handles the graphical loop, running Update every 1/60th of a second, and Render every graphical frame. If the loop gets too backlogged, it will drop frames rather than building up pending frames infinitely.

Resize is called once at the start, then once every time the screen resolution changes.

Types

type Card

type Card struct {
	*match.Card
	Active *match.ActiveCard
	ModTP  card.Number
	// contains filtered or unexported fields
}

func (*Card) Flip

func (c *Card) Flip()

Flip flips the card from face-up to face-down or vice versa.

func (*Card) IsFlip

func (c *Card) IsFlip() bool

IsFlip returns true if the card is face-down.

func (*Card) Render

func (c *Card) Render(ctx context.Context, batch *sprites.Batch, highlightEffect *card.EffectDef)

Render draws a card to the screen.

func (*Card) SetFlip

func (c *Card) SetFlip(down bool)

SetFlip flips the card to a specified side.

type CheapCardSheet

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

func NewCheapCardSheet

func NewCheapCardSheet() *CheapCardSheet

func (*CheapCardSheet) Ready

func (s *CheapCardSheet) Ready(ctx context.Context) bool

func (*CheapCardSheet) Release

func (s *CheapCardSheet) Release()

func (*CheapCardSheet) SetCard

func (s *CheapCardSheet) SetCard(i int, c *Card)

func (*CheapCardSheet) Sprite

func (s *CheapCardSheet) Sprite(i int) *sprites.Sprite

type DeckBuilder

type DeckBuilder struct {
	IsEditor  *Visual
	Confirmed bool
	// contains filtered or unexported fields
}

DeckBuilder constructs or edits a deck.

func NewDeckBuilder

func NewDeckBuilder(ctx context.Context, set *card.Set) *DeckBuilder

NewDeckBuilder creates a deck builder.

func (*DeckBuilder) Render

func (d *DeckBuilder) Render(ctx context.Context)

Render draws the deck builder to the screen.

func (*DeckBuilder) Update

func (d *DeckBuilder) Update(ctx context.Context)

Update processes one frame of input.

type DeckPicker

type DeckPicker struct {
	AllowCreate bool
	IsEditor    *Visual
	Selected    card.Deck
	// contains filtered or unexported fields
}

func NewDeckPicker

func NewDeckPicker(ctx context.Context, set *card.Set) *DeckPicker

func (*DeckPicker) Populate

func (d *DeckPicker) Populate()

func (*DeckPicker) Render

func (d *DeckPicker) Render(ctx context.Context)

func (*DeckPicker) Update

func (d *DeckPicker) Update(ctx context.Context)

type InlineLayout

type InlineLayout struct {
	*Layout
	Context context.Context
	Scroll  *gui.Scroll
	Dy      float32
	// contains filtered or unexported fields
}

func (*InlineLayout) Height

func (l *InlineLayout) Height() float32

func (*InlineLayout) Render

func (l *InlineLayout) Render(sb *sprites.Batch)

func (*InlineLayout) SetY

func (l *InlineLayout) SetY(y float32)

func (*InlineLayout) Update

func (l *InlineLayout) Update(cam *gfx.Camera, ictx *input.Context)

func (*InlineLayout) Width

func (l *InlineLayout) Width() float32

type Layout

type Layout struct {
	Cards []*Card

	MinPerRow int
	MaxPerRow int
	OnSelect  func(*Card)
	gui.FocusHandler
	MinScale       float32
	BaseScale      float32
	MaxScale       float32
	HoverScale     float32
	MarginTop      float32
	MarginLeft     float32
	MarginBottom   float32
	MarginRight    float32
	PaddingX       float32
	PaddingY       float32
	ScrollPadding  float32
	GrowDx, GrowDy float32

	CenterLastRow bool
	AllowScroll   bool
	Reverse       bool
	PinCorner     uint8
	Slide         bool
	SquishY       bool
	ShowRelated   bool
	DefaultFocus  bool
	// contains filtered or unexported fields
}

Layout handles arranging a grid of cards on the screen.

func NewLayout

func NewLayout(ctx context.Context) *Layout

NewLayout creates a new card layout.

func (*Layout) Focus

func (l *Layout) Focus()

Focus attaches the input focus to this Layout.

func (*Layout) Render

func (l *Layout) Render(ctx context.Context, pass int)

Render draws the card layout to the screen.

func (*Layout) Update

func (l *Layout) Update(modTP map[card.ID]card.Number)

Update processes one frame of input.

type Looper added in v0.3.19

type Looper interface {
	Resize(context.Context) error
	Update(context.Context, bool) (*router.PageInfo, error)
	Render(context.Context) error
	MakeScreenReaderUI() *screenreader.UI
}

type State

type State uint64
const (
	StateHome State = iota
	StateConnecting
	StateWait
	StateMatchmakingWait
	StateCharacterSelect
	StateDeckSelect
	StateReadyToStart
	StateNextRound
	StateNextRoundWait
	StateTurnSelect
	StateTurnProcess
	StateTurnEnd
	StateMatchCompleteWait
	StateMatchComplete
	StatePlaybackFetch
	StatePlaybackInit
	StatePlaybackIdle
	StatePlaybackNext
	StatePlaybackTurnWait
	StateSelectMode
	StateDeckEditor
)

Constants for State.

func (State) String

func (i State) String() string

type Visual

type Visual struct {
	State State

	Match *match.Match
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, init *match.Init) (*Visual, error)

func (*Visual) InitCardEditor

func (v *Visual) InitCardEditor(ctx context.Context, codes string) error

func (*Visual) JoinMatch

func (v *Visual) JoinMatch(ctx context.Context, code string) error

func (*Visual) MakeScreenReaderUI added in v0.3.19

func (v *Visual) MakeScreenReaderUI() *screenreader.UI

func (*Visual) Render

func (v *Visual) Render(ctx context.Context) error

func (*Visual) Resize

func (v *Visual) Resize(ctx context.Context) error

func (*Visual) SetDeck

func (v *Visual) SetDeck(ctx context.Context, code string) error

func (*Visual) SetRecording

func (v *Visual) SetRecording(ctx context.Context, code string)

func (*Visual) Update

func (v *Visual) Update(ctx context.Context, frameAdvance bool) (*router.PageInfo, error)

Jump to

Keyboard shortcuts

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