tic_tac_toe

package
v0.0.0-...-46eff7e Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	XSize   = 80
	ORadius = 40
)
View Source
const (
	XPlayer        = 1
	OPlayer        = 2
	Draw           = 3
	DifficultyEasy = 101
	DifficultyHard = 102
	BoardSize      = 9
)

Variables

View Source
var (
	XColor = color.RGBA{64, 140, 242, 0xff}
	OColor = color.RGBA{242, 140, 64, 0xff}
)
View Source
var (
	Title        = "Tic Tac Toe"
	ScreenWidth  = 300
	ScreenHeight = 300
)

Functions

func GetOponent

func GetOponent(player int) int

Types

type Board

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

Board represents a board state.

func NewBoard

func NewBoard(player, difficulty int) (*Board, error)

NewBoard generates a new Board.

func (*Board) Draw

func (b *Board) Draw(boardImage *ebiten.Image)

Draw draws the board to the given boardImage.

func (*Board) Layout

func (b *Board) Layout(outsideWidth, outsideHeight int) (boardWidth, boardHeight int)

Layout implements ebiten.Game's Layout.

func (*Board) Update

func (b *Board) Update() error

Update updates the board state.

type Game

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

Game represents a game state.

func NewGame

func NewGame(player, difficulty int) (*Game, error)

NewGame generates a new Game object.

func (*Game) Draw

func (g *Game) Draw(screen *ebiten.Image)

func (*Game) Layout

func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int)

Layout implements ebiten.Game's Layout.

func (*Game) Update

func (g *Game) Update() error

Update updates the current game state.

type GameState

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

func (*GameState) HasWinner

func (gs *GameState) HasWinner() bool

func (*GameState) IsDraw

func (gs *GameState) IsDraw() bool

func (*GameState) MakeMove

func (gs *GameState) MakeMove() int

func (*GameState) NextTurn

func (gs *GameState) NextTurn()

func (*GameState) Play

func (gs *GameState) Play(move int) bool

Jump to

Keyboard shortcuts

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