Documentation ¶
Index ¶
- Constants
- Variables
- type App
- type Button
- type Counter
- type HelpMarking
- type MinesweeperGrid
- func (g *MinesweeperGrid) Autosolve(delay time.Duration) bool
- func (g *MinesweeperGrid) Col() int
- func (g *MinesweeperGrid) GetCanvasObject() fyne.CanvasObject
- func (g *MinesweeperGrid) Hint() bool
- func (g *MinesweeperGrid) NewGame()
- func (g *MinesweeperGrid) OutOfBounds(p minesweeper.Pos) bool
- func (g *MinesweeperGrid) Replay()
- func (g *MinesweeperGrid) Reset()
- func (g *MinesweeperGrid) Row() int
- func (g *MinesweeperGrid) TapNeighbours(pos minesweeper.Pos)
- func (g *MinesweeperGrid) TappedTile(pos minesweeper.Pos)
- type Tile
- func (t *Tile) Checked() bool
- func (t *Tile) Content() minesweeper.FieldContent
- func (t *Tile) CreateRenderer() fyne.WidgetRenderer
- func (t *Tile) DoubleTapped(_ *fyne.PointEvent)
- func (t *Tile) Flag(v bool)
- func (t *Tile) Flagged() bool
- func (t *Tile) Mark(m HelpMarking)
- func (t *Tile) Marking() HelpMarking
- func (t *Tile) Reset()
- func (t *Tile) SetField(f minesweeper.Field)
- func (t *Tile) Tapped(_ *fyne.PointEvent)
- func (t *Tile) TappedSecondary(_ *fyne.PointEvent)
- type Timer
- type Version
Constants ¶
const ( GridLabelSize float32 = 40 ResetDefaultText = "🙂" ResetGameOverText = "☠" ResetGameWonText = "😎" ResetTextSize float32 = 40 )
const ( GameAlgorithmSafePos = iota GameAlgorithmSafeArea GameAlgorithmSolvable )
const (
ChunkSize = 10
)
const DEFAULT_AUTOSOLVE_DELAY = 500 * time.Millisecond
const DEFAULT_GAME_ALGORITHM = GameAlgorithmSolvable
Variables ¶
var ( TileDefaultColor = color.Gray16{32767} TileBackgroundColor = color.Gray16{^uint16(0)} TileExplodedColor = color.RGBA{240, 10, 20, alpha} TileSize = fyne.NewSize(32, 32) TileTextSize float32 = 23 // Biggest we can go with TileSize of 32^2 )
var ( HelperMarkerSymbols = []string{"", "!", "?"} HelperMarkerColors = []color.Color{ color.White, color.RGBA{180, 15, 15, alpha}, color.RGBA{15, 180, 15, alpha}, } )
var DEFAULT_DIFFICULTY = minesweeper.Difficulties()[minesweeper.DifficultyIntermediate]
var (
GridLabelColor = color.RGBA{240, 10, 20, alpha}
)
var TEXT_COLOR = color.White
var TileTextColor = []color.Color{ color.White, color.RGBA{20, 15, 220, alpha}, color.RGBA{5, 110, 20, alpha}, color.RGBA{240, 10, 20, alpha}, color.RGBA{5, 5, 100, alpha}, color.RGBA{90, 38, 42, alpha}, color.RGBA{25, 230, 230, alpha}, color.RGBA{10, 10, 10, alpha}, color.RGBA{64, 64, 64, alpha}, }
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct { Version Version // contains filtered or unexported fields }
Struct representing the current app. There should only ever be a single instance during runtime.
func (*App) NewGrid ¶ added in v0.3.0
func (a *App) NewGrid(d minesweeper.Difficulty)
type Button ¶
type Button struct { widget.BaseWidget Label *canvas.Text Action func() }
Custom implementation for a button that is only portraied by text. The text is fully configurable by exposing the backing label.
func (*Button) CreateRenderer ¶
func (b *Button) CreateRenderer() fyne.WidgetRenderer
Function to create renderer needed to implement widget
func (*Button) TappedSecondary ¶
func (b *Button) TappedSecondary(_ *fyne.PointEvent)
Right click action, currently not implemented or exposed
type HelpMarking ¶ added in v0.3.0
type HelpMarking int
const ( HelpMarkingNone HelpMarking = iota HelpMarkingMine HelpMarkingSafe )
type MinesweeperGrid ¶
type MinesweeperGrid struct { Tiles [][]*Tile Difficulty minesweeper.Difficulty Game minesweeper.Game AssistedMode bool GameAlgorithm int Timer *Timer MineCount *Counter ResetButton *Button // contains filtered or unexported fields }
Graphical display for a minesweeper game
func NewMinesweeperGrid ¶
func NewMinesweeperGrid(d minesweeper.Difficulty, assistedMode bool) *MinesweeperGrid
Create a new grid suitable for the give difficulty
func (*MinesweeperGrid) Autosolve ¶ added in v0.4.0
func (g *MinesweeperGrid) Autosolve(delay time.Duration) bool
Autosolve the current running game, delay is the time between steps Returns false if it can't run autosolve, otherwise true. If there are no steps to be taken, still
func (*MinesweeperGrid) Col ¶
func (g *MinesweeperGrid) Col() int
Return the number of columns in the grid
func (*MinesweeperGrid) GetCanvasObject ¶
func (g *MinesweeperGrid) GetCanvasObject() fyne.CanvasObject
Get the graphical representation of the grid
func (*MinesweeperGrid) Hint ¶ added in v0.3.0
func (g *MinesweeperGrid) Hint() bool
Display a single hint on the grid. Returns false if no hint could be displayed.
func (*MinesweeperGrid) OutOfBounds ¶ added in v0.2.0
func (g *MinesweeperGrid) OutOfBounds(p minesweeper.Pos) bool
Check if the given position is out of bounds. Calls Game.OutOfBounds(Pos)
func (*MinesweeperGrid) Replay ¶ added in v0.2.0
func (g *MinesweeperGrid) Replay()
Replay the current game
func (*MinesweeperGrid) Row ¶
func (g *MinesweeperGrid) Row() int
Return the number of rows in the grid
func (*MinesweeperGrid) TapNeighbours ¶ added in v0.4.1
func (g *MinesweeperGrid) TapNeighbours(pos minesweeper.Pos)
Called by the child tiles to reveal all neighbours when they have been double tapped
func (*MinesweeperGrid) TappedTile ¶
func (g *MinesweeperGrid) TappedTile(pos minesweeper.Pos)
Called by the child tiles to signal they have been tapped. Checks the given tile and then updates the display according to the new state. Starts a new game when no game is currently running.
type Tile ¶
type Tile struct { widget.BaseWidget // contains filtered or unexported fields }
A tile extends the base widget and displays the current state of the backing games field
func NewTile ¶
func NewTile(x, y int, grid *MinesweeperGrid) *Tile
Create a new Tile with a reference to it's parent grid, as well as knowledge of it's own position in the Grid
func (*Tile) Content ¶ added in v0.4.1
func (t *Tile) Content() minesweeper.FieldContent
Returns the field content
func (*Tile) CreateRenderer ¶
func (t *Tile) CreateRenderer() fyne.WidgetRenderer
Function to create renderer needed to implement widget
func (*Tile) DoubleTapped ¶ added in v0.2.0
func (t *Tile) DoubleTapped(_ *fyne.PointEvent)
Double click on tile
func (*Tile) Marking ¶ added in v0.4.1
func (t *Tile) Marking() HelpMarking
Returns the marking of the tile
func (*Tile) SetField ¶ added in v0.4.1
func (t *Tile) SetField(f minesweeper.Field)
Set the content of the field
func (*Tile) TappedSecondary ¶
func (t *Tile) TappedSecondary(_ *fyne.PointEvent)
Right mouse click on tile