Documentation ¶
Index ¶
- Constants
- Variables
- type App
- type Button
- type Counter
- type MinesweeperGrid
- func (g *MinesweeperGrid) Col() int
- func (g *MinesweeperGrid) GetCanvasObject() fyne.CanvasObject
- 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) TappedTile(pos minesweeper.Pos)
- type Tile
- type Timer
- type Version
Constants ¶
const ( GridLabelSize float32 = 40 ResetDefaultText = "🙂" ResetGameOverText = "☠" ResetGameWonText = "😎" ResetTextSize float32 = 40 )
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 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.
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 MinesweeperGrid ¶
type MinesweeperGrid struct { Tiles [][]*Tile Difficulty minesweeper.Difficulty Game minesweeper.Game Timer *Timer MineCount *Counter ResetButton *Button }
Graphical display for a minesweeper game
func NewMinesweeperGrid ¶
func NewMinesweeperGrid(d minesweeper.Difficulty) *MinesweeperGrid
Create a new grid suitable for the give difficulty
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) 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) 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 Pos minesweeper.Pos Field *minesweeper.Field Flagged bool // 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) 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) TappedSecondary ¶
func (t *Tile) TappedSecondary(_ *fyne.PointEvent)
Right mouse click on tile
func (*Tile) UpdateContent ¶
func (t *Tile) UpdateContent()
Update the tile render depending on the current state of it's backing Field