components

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Are ya winnin' son?
	GameStateWin = iota
	GameStateLose
	GameStateOngoing
)

The different states of a game

View Source
const (
	TileTypeMine = iota
	TileTypeEmpty
	TileType0
	TileType1
	TileType2
	TileType3
	TileType4
	TileType5
	TileType6
	TileType7
	TileType8
)

TileTypes

Variables

This section is empty.

Functions

func NewBoard

func NewBoard(tiles [][]*Tile) *fyne.Container

NewBoard creates a new board of dimensions rows and cols

Types

type GameState

type GameState int

GameState represents the current state of the game

type MineCounter

type MineCounter struct {
	*fyne.Container
	// contains filtered or unexported fields
}

MineCounter counts the possible remaining mines

func NewMineCounter

func NewMineCounter(init int) *MineCounter

NewMineCounter reates a new mine counter

func (*MineCounter) Decrement

func (mc *MineCounter) Decrement()

Decrement updates the counter

func (*MineCounter) Increment

func (mc *MineCounter) Increment()

Increment updates the counter

type SmileyMan

type SmileyMan struct {
	widget.Icon
	// contains filtered or unexported fields
}

SmileyMan controls everything. God, you mean? No.

func NewSmileyMan

func NewSmileyMan(state GameState, resetHandler func()) *SmileyMan

NewSmileyMan creates a new smileyman

func (*SmileyMan) MouseDown

func (sm *SmileyMan) MouseDown(ev *desktop.MouseEvent)

MouseDown impl for desktop clicks

func (*SmileyMan) MouseUp

func (sm *SmileyMan) MouseUp(ev *desktop.MouseEvent)

MouseUp impl for desktop clicks

func (*SmileyMan) SetState

func (sm *SmileyMan) SetState(state GameState)

SetState chagnes smiley amns state based on game state

type Tile

type Tile struct {
	widget.Icon

	Base      TileType
	IsOpen    bool
	IsFlagged bool
	Row       int
	Col       int

	OpenHandler func(int, int)
	MarkHandler func(int, int)
}

Tile stores the data and state of a tile on the game board

func NewTile

func NewTile(tileType TileType, row, col int, openHandler func(int, int), markHandler func(int, int)) *Tile

NewTile creates a new tile of the given type

func (*Tile) Flag

func (t *Tile) Flag()

Flag falgs a tile

func (*Tile) MouseDown

func (t *Tile) MouseDown(ev *desktop.MouseEvent)

MouseDown impl for desktop clicks

func (*Tile) MouseIn

func (t *Tile) MouseIn(ev *desktop.MouseEvent)

MouseIn impl for desktop clicks

func (*Tile) MouseMoved

func (t *Tile) MouseMoved(ev *desktop.MouseEvent)

MouseMoved impl for desktop clicks

func (*Tile) MouseOut

func (t *Tile) MouseOut()

MouseOut impl for desktop clicks

func (*Tile) MouseUp

func (t *Tile) MouseUp(ev *desktop.MouseEvent)

MouseUp impl for desktop clicks

func (*Tile) Open

func (t *Tile) Open(byUser bool)

Open opens a tile

func (*Tile) Unflag

func (t *Tile) Unflag()

Unflag unflags a tile

type TileType

type TileType int

TileType is the type of the tile that modifies it's look

type TimeCounter

type TimeCounter struct {
	*fyne.Container
	// contains filtered or unexported fields
}

TimeCounter counts the time

func NewTimeCounter

func NewTimeCounter(init int) *TimeCounter

NewTimeCounter creates a new time counter

func (*TimeCounter) Increment

func (tc *TimeCounter) Increment()

Increment updates the counter

Jump to

Keyboard shortcuts

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