sandbox

package
v0.0.0-...-f930f65 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const MaxChunks = 10

Variables

This section is empty.

Functions

This section is empty.

Types

type Cell

type Cell struct {
	CType CellType
	// contains filtered or unexported fields
}

func NewCell

func NewCell(cType CellType) *Cell

func (*Cell) BaseColor

func (c *Cell) BaseColor() color.RGBA

func (*Cell) IsFlamable

func (c *Cell) IsFlamable() bool

func (*Cell) ThermalConductivity

func (c *Cell) ThermalConductivity() int

type CellType

type CellType int
const (
	SAND CellType = iota
	GLASS
	WATER
	WALL
	STONE
	SMOKE
	STEAM
	WOOD
	FIRE
	IRON
	CLNE
	PLANT
	AIR // special type for empty cells. Always last for easy iteration
)

func (CellType) Color

func (cType CellType) Color() color.RGBA

type Change

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

type Chunk

type Chunk struct {
	Width, Height int
	X, Y          int

	// Dirty rect
	MinX, MinY int
	MaxX, MaxY int
	// contains filtered or unexported fields
}

func NewChunk

func NewChunk(width, height, x, y int) *Chunk

func (*Chunk) ApplyChanges

func (c *Chunk) ApplyChanges()

func (*Chunk) GetCell

func (c *Chunk) GetCell(x, y int) *Cell

func (*Chunk) GetCellAt

func (c *Chunk) GetCellAt(i int) *Cell

func (*Chunk) GetIndex

func (c *Chunk) GetIndex(x, y int) int

GetIndex returns the index of the cell at the given coordinates.

func (*Chunk) InBounds

func (c *Chunk) InBounds(x, y int) bool

func (*Chunk) IsEmpty

func (c *Chunk) IsEmpty(x, y int) bool

func (*Chunk) IsEmptyAt

func (c *Chunk) IsEmptyAt(i int) bool

func (*Chunk) KeepAlive

func (c *Chunk) KeepAlive(x, y int)

func (*Chunk) KeepAliveAt

func (c *Chunk) KeepAliveAt(i int)

func (*Chunk) MoveCell

func (c *Chunk) MoveCell(src *Chunk, x, y, dx, dy int)

func (*Chunk) SetCell

func (c *Chunk) SetCell(x, y int, cell *Cell)

func (*Chunk) SetCellAt

func (c *Chunk) SetCellAt(i int, cell *Cell)

func (*Chunk) UpdateRect

func (c *Chunk) UpdateRect()

type Sandbox

type Sandbox struct {
	Chunks []*Chunk
	// contains filtered or unexported fields
}

func NewSandbox

func NewSandbox(width, height int) *Sandbox

func (*Sandbox) CreateChunk

func (s *Sandbox) CreateChunk(x, y int) *Chunk

func (*Sandbox) Draw

func (s *Sandbox) Draw(pix []byte, screenWidth int, temp bool)

func (*Sandbox) GetCell

func (s *Sandbox) GetCell(x, y int) *Cell

func (*Sandbox) GetChunk

func (s *Sandbox) GetChunk(x, y int) *Chunk

func (*Sandbox) GetChunkLocation

func (s *Sandbox) GetChunkLocation(x, y int) (int, int)

func (*Sandbox) InBounds

func (s *Sandbox) InBounds(x, y int) bool

func (*Sandbox) IsEmpty

func (s *Sandbox) IsEmpty(x, y int) bool

func (*Sandbox) KeepAlive

func (s *Sandbox) KeepAlive(x, y int)

func (*Sandbox) MoveCell

func (s *Sandbox) MoveCell(x, y, xn, yn int)

func (*Sandbox) MoveUpdate

func (s *Sandbox) MoveUpdate()

func (*Sandbox) RemoveEmptyChunks

func (s *Sandbox) RemoveEmptyChunks()

func (*Sandbox) SetCell

func (s *Sandbox) SetCell(x, y int, cell *Cell)

func (*Sandbox) StateUpdate

func (s *Sandbox) StateUpdate()

func (*Sandbox) TempUpdate

func (s *Sandbox) TempUpdate()

func (*Sandbox) Update

func (s *Sandbox) Update(temp bool)

type Worker

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

func NewWorker

func NewWorker(sandbox *Sandbox, chunk *Chunk) *Worker

func (*Worker) GetCell

func (w *Worker) GetCell(x, y int) *Cell

func (*Worker) InBounds

func (w *Worker) InBounds(x, y int) bool

func (*Worker) IsEmpty

func (w *Worker) IsEmpty(x, y int) bool

func (*Worker) MoveCell

func (w *Worker) MoveCell(x, y, dx, dy int)

func (*Worker) MoveFire

func (w *Worker) MoveFire(x, y int, cell *Cell)

func (*Worker) MoveGas

func (w *Worker) MoveGas(x, y int, cell *Cell) (int, int)

TODO: refactor this to return position.

func (*Worker) MoveLiquid

func (w *Worker) MoveLiquid(x, y int, cell *Cell)

func (*Worker) MovePowder

func (w *Worker) MovePowder(x, y int, cell *Cell)

func (*Worker) MoveSolid

func (w *Worker) MoveSolid(x, y int, cell *Cell)

func (*Worker) SetCell

func (w *Worker) SetCell(x, y int, cell *Cell)

func (*Worker) UpdateChunk

func (w *Worker) UpdateChunk()

func (*Worker) UpdateChunkState

func (w *Worker) UpdateChunkState()

func (*Worker) UpdateChunkTemp

func (w *Worker) UpdateChunkTemp()

func (*Worker) UpdateFire

func (w *Worker) UpdateFire(x, y int)

func (*Worker) UpdatePlant

func (w *Worker) UpdatePlant(x, y int)

func (*Worker) UpdateReplicator

func (w *Worker) UpdateReplicator(x, y int)

func (*Worker) UpdateSand

func (w *Worker) UpdateSand(x, y int)

func (*Worker) UpdateSmoke

func (w *Worker) UpdateSmoke(x, y int)

func (*Worker) UpdateSteam

func (w *Worker) UpdateSteam(x, y int)

func (*Worker) UpdateWater

func (w *Worker) UpdateWater(x, y int)

Jump to

Keyboard shortcuts

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