game

package
v0.0.0-...-b747725 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs[T number](x T) T

func Contains

func Contains(slices [][2]int, item [2]int) int

func Max

func Max[T constraints.Ordered](a, b T) T

func Min

func Min[T constraints.Ordered](a, b T) T

Types

type Controller

type Controller struct {
	Renderer  *Renderer
	GameBoard *GameBoard
	// contains filtered or unexported fields
}

func NewController

func NewController(width int32, height int32, fontPath string, fontSize int, windowTitle string) *Controller

func (*Controller) Start

func (controller *Controller) Start()

func (*Controller) Update

func (controller *Controller) Update()

type GameBoard

type GameBoard struct {
	Snake  []([2]int)
	Food   [2]int
	Width  int
	Height int

	GameScore    int
	GameWin      bool
	GameOverFlag bool
}

func NewGameBoard

func NewGameBoard(width int, height int) *GameBoard

func (*GameBoard) Update

func (gameBoard *GameBoard) Update(keyState sdl.Keycode)

type Renderer

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

func NewRenderer

func NewRenderer(width int32, height int32, fontPath string, fontSize int, windowTitle string) *Renderer

func (*Renderer) Update

func (renderer *Renderer) Update(gameBoard GameBoard)

Jump to

Keyboard shortcuts

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