game

package
v0.0.0-...-5bfd26b Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2016 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SecPerUpdate = 1.0 / updatesPerSec
)

Variables

View Source
var HUDItemText = [...]string{
	HUDItemSpeed: "S P E E D",
	HUDItemTime:  "T I M E",
	HUDItemScore: "S C O R E",
}
View Source
var MenuChoiceText = map[MenuChoiceID]string{
	MenuEasy:   "E A S Y",
	MenuMedium: "M E D I U M",
	MenuHard:   "H A R D",
}
View Source
var MenuItemText = map[MenuItemID]string{
	MenuNewGameItem: "N E W  G A M E",
	MenuStats:       "S T A T S",
	MenuOptions:     "O P T I O N S",
	MenuCredits:     "C R E D I T S",
	MenuExit:        "E X I T",

	MenuSpeed:      "S P E E D",
	MenuDifficulty: "D I F F I C U L T Y",
	MenuOK:         "O K",

	MenuContinueGame: "C O N T I N U E  G A M E",
	MenuQuit:         "Q U I T",
}
View Source
var MenuTitleText = map[MenuID]string{
	MenuMain:     "b l o c k c i l l i n",
	MenuNewGame:  "N E W  G A M E",
	MenuPaused:   "P A U S E D",
	MenuGameOver: "G A M E  O V E R",
}

Functions

This section is empty.

Types

type Block

type Block struct {
	// State is the block's state.
	State BlockState

	// Color is the block's color. Red by default.
	Color BlockColor

	// Dropping is set when a block is dropping and has been for at least one ring.
	Dropping bool
	// contains filtered or unexported fields
}

Block is a block that can be put into a cell.

func (*Block) StateProgress

func (b *Block) StateProgress(fudge float32) float32

type BlockColor

type BlockColor int32
const (
	Red BlockColor = iota
	Purple
	Blue
	Cyan
	Green
	Yellow
)

func (BlockColor) String

func (i BlockColor) String() string

type BlockState

type BlockState int32
const (
	// BlockStatic is a visible and stationary block.
	BlockStatic BlockState = iota

	// BlockSwappingFromLeft is a visible block swapping from the left.
	BlockSwappingFromLeft

	// BlockSwappingFromRight is a visible block swapping from the right.
	BlockSwappingFromRight

	// BlockDroppingFromAbove is a visible block dropping from above.
	BlockDroppingFromAbove

	// BlockFlashing is a block within a chain that is flashing.
	// Automatically goes to the BlockCracking state.
	BlockFlashing

	// BlockCracking is a block within a chain that is cracking.
	// Automatically goes to the BlockCracked state.
	BlockCracking

	// BlockCracked is a block within a chain has finished cracking.
	// Manually change the state to BlockExploding when ready.
	BlockCracked

	// BlockExploding is a block within a chain that is exploding.
	// Automatically goes to the BlockExploded state.
	BlockExploding

	// BlockExploded is a block within a chain that has finished exploding.
	// Manually change the state to BlockClearPausing when ready.
	BlockExploded

	// BlockClearPausing is an invisible block but cannot be dropped into yet.
	// Automatically goes to the BlockCleared state.
	BlockClearPausing

	// BlockCleared is a an invisible block.
	BlockCleared
)

func (BlockState) String

func (i BlockState) String() string

type Board

type Board struct {
	// State is the board's state. Use only within this file.
	State BoardState

	// Rings are the rings with cells with blocks that the player can swap.
	Rings []*Ring

	// SpareRings are additional upcoming rings that the user cannot swap yet.
	SpareRings []*Ring

	// RingCount is how many rings the board has.
	RingCount int

	// CellCount is the fixed number of cells each ring can have.
	CellCount int

	// Selector is the selector the player uses to swap blocks.
	Selector *Selector

	// Y is vertical offset from 0 to 1 as the board rises one ring.
	Y float32
	// contains filtered or unexported fields
}

func (*Board) RiseProgress

func (b *Board) RiseProgress(fudge float32) float32

func (*Board) StateDone

func (b *Board) StateDone() bool

func (*Board) StateProgress

func (b *Board) StateProgress(fudge float32) float32

type BoardState

type BoardState int32
const (
	BoardEntering BoardState = iota
	BoardLive
	BoardGameOver
	BoardExiting
)

func (BoardState) String

func (i BoardState) String() string

type Cell

type Cell struct {
	Block  *Block
	Marker *Marker
}

type Game

type Game struct {
	State GameState
	Menu  *Menu
	Board *Board
	HUD   *HUD

	// GlobalPulse is incremented each update so it can be used for any pulsing animation.
	GlobalPulse float32
	// contains filtered or unexported fields
}

func New

func New() *Game

func (*Game) Done

func (g *Game) Done() bool

func (*Game) KeyCallback

func (g *Game) KeyCallback(key glfw.Key, action glfw.Action)

func (*Game) StateProgress

func (g *Game) StateProgress(fudge float32) float32

func (*Game) Update

func (g *Game) Update()

type GameState

type GameState int32
const (
	GameInitial GameState = iota
	GamePlaying
	GamePaused
	GameExiting
)

func (GameState) String

func (i GameState) String() string

type HUD

type HUD struct {
	Speed   int
	TimeSec int
	Score   int
	// contains filtered or unexported fields
}

type HUDItem

type HUDItem int32
const (
	HUDItemSpeed HUDItem = iota
	HUDItemTime
	HUDItemScore
)

func (HUDItem) String

func (i HUDItem) String() string

type Marker

type Marker struct {
	State      MarkerState
	ComboLevel int
	ChainLevel int
	// contains filtered or unexported fields
}

func (*Marker) StateProgress

func (m *Marker) StateProgress(fudge float32) float32

type MarkerState

type MarkerState int32
const (
	// MarkerNone is an empty marker.
	MarkerNone MarkerState = iota

	// MarkeShowing is a marker being shown.
	MarkerShowing
)

func (MarkerState) String

func (i MarkerState) String() string
type Menu struct {
	ID           MenuID
	Items        []*MenuItem
	FocusedIndex int
	Selected     bool
}
type MenuChoiceID byte
const (
	MenuEasy MenuChoiceID = iota
	MenuMedium
	MenuHard
)
func (i MenuChoiceID) String() string
type MenuID byte
const (
	MenuMain MenuID = iota
	MenuNewGame
	MenuPaused
	MenuGameOver
)
func (i MenuID) String() string
type MenuItem struct {
	ID       MenuItemID
	Selector *MenuSelector
	Slider   *MenuSlider
}
func (i *MenuItem) SingleChoice() bool
type MenuItemID byte
const (
	MenuNewGameItem MenuItemID = iota
	MenuStats
	MenuOptions
	MenuCredits
	MenuExit

	MenuSpeed
	MenuDifficulty
	MenuOK

	MenuContinueGame
	MenuQuit
)
func (i MenuItemID) String() string
type MenuSelector struct {
	Choices []MenuChoiceID
	// contains filtered or unexported fields
}
func (s *MenuSelector) Value() MenuChoiceID
type MenuSlider struct {
	Min   int
	Max   int
	Value int
}

type Ring

type Ring struct {
	Cells []*Cell
}

type Selector

type Selector struct {
	// State is the state of the selector.
	State SelectorState

	// X is the selector's current column.
	// It changes only after the move animation completes.
	X int

	// Y is the selector's current row.
	// It changes only after the move animation completes.
	Y int

	// Pulse is used to pulse the selector only when it is moving.
	Pulse float32
	// contains filtered or unexported fields
}

func (*Selector) StateProgress

func (s *Selector) StateProgress(fudge float32) float32

type SelectorState

type SelectorState int32
const (
	SelectorStatic SelectorState = iota
	SelectorMovingUp
	SelectorMovingDown
	SelectorMovingLeft
	SelectorMovingRight
)

func (SelectorState) String

func (i SelectorState) String() string

Jump to

Keyboard shortcuts

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