day13

package
v0.0.0-...-a30599c Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoPlayer

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

AutoPlayer will automatically move the joystick perfectly.

func NewAutoPlayer

func NewAutoPlayer(g *Game) *AutoPlayer

NewAutoPlayer creates a new autoplayer.

func (*AutoPlayer) HandleInput

func (ap *AutoPlayer) HandleInput() int

HandleInput gives the correct way to move the joystick based on the current game state. Use this with SetInputFunc on the game's VM.

type Canvas

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

Canvas is an infinitely paintable 2D surface.

func NewCanvas

func NewCanvas() *Canvas

NewCanvas creates an empty canvas.

func (*Canvas) At

func (c *Canvas) At(p point.Point2D) int

At gets the color painted at a point.

func (*Canvas) Count

func (c *Canvas) Count() int

Count returns the number of points that have been painted at all.

func (*Canvas) CountColor

func (c *Canvas) CountColor(color int) int

CountColor returns the number of points painted with the given color.

func (*Canvas) Draw

func (c *Canvas) Draw(drawFn func(int, int, int))

Draw calls the provided drawFn for every square on the canvas, regardless of whether it has been painted to.

func (*Canvas) Height

func (c *Canvas) Height() int

Height returns the height of the canvas

func (*Canvas) Paint

func (c *Canvas) Paint(p point.Point2D, color int)

Paint paints a point with a color, extending the bounds of the canvas if needed.

func (*Canvas) PrintTo

func (c *Canvas) PrintTo(w io.Writer)

PrintTo prints the image on the canvas to the given writer.

func (*Canvas) Width

func (c *Canvas) Width() int

Width returns the width of the canvas

type Game

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

Game plays a game controlled by an Intcode program

func NewGame

func NewGame(c *Canvas) *Game

NewGame creates a new game that draws on the given canvas.

func (*Game) Connect

func (g *Game) Connect(screen tcell.Screen)

Connect connects the game to a terminal screen.

func (*Game) Run

func (g *Game) Run(output chan int)

Run runs the game according to the instructions from output.

func (*Game) Score

func (g *Game) Score() int

Score returns the current score of the game, or the final score if the game is over.

Jump to

Keyboard shortcuts

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