game

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ROWS_MAX    = 6
	COLUMNS_MAX = 7
)
View Source
const (
	PlayerOne = 1
	PlayerTwo = 2
)
View Source
const (
	ScreenWidth  = 640
	ScreenHeight = 360
)

Variables

View Source
var (
	ColorRed = color.RGBA{
		R: 0xFF,
		G: 0x00,
		B: 0x00,
		A: 0xFF,
	}
	ColorYellow = color.RGBA{
		R: 0xFF,
		G: 0xFF,
		B: 0x00,
		A: 0xFF,
	}
	ColorBlue = color.RGBA{
		R: 0x00,
		G: 0x00,
		B: 0xFF,
		A: 0xFF,
	}
)
View Source
var (
	SmallFont  font.Face
	MediumFont font.Face
	LargeFont  font.Face
)
View Source
var (
	ErrTerminated = errors.New("terminated")
)

Functions

func GetBoardState

func GetBoardState(board Board) (BoardState, []Piece)

func IsValidMove

func IsValidMove(state Board, player int, column int) bool

Types

type Board

type Board [][]int

func AddPiece

func AddPiece(board Board, player int, column int) Board

func NewBoard

func NewBoard(state Board) Board

type BoardState

type BoardState int
const (
	DrawState         BoardState = -1
	OngoingState      BoardState = 0
	PlayerOneWinState BoardState = 1
	PlayerTwoWinState BoardState = 2
)

type Game

type Game struct {
	Title string
	State *GameState
	// contains filtered or unexported fields
}

func (*Game) Draw

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

func (*Game) Layout

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

func (*Game) Setup

func (g *Game) Setup()

func (*Game) StartGame

func (g *Game) StartGame()

func (*Game) Update

func (g *Game) Update() (err error)

type GameState

type GameState struct {
	Board      *Board
	NextToPlay int
	BoardState BoardState
}

func NewGameState

func NewGameState(board *Board, boardState BoardState, nextToPlay int) *GameState

type Piece

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

type Scene

type Scene int
const (
	PlayingScene Scene = iota
	GameOverScene
)

Jump to

Keyboard shortcuts

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