world

package
v0.0.0-...-c33ef55 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chunk

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

func (Chunk) Draw

func (c Chunk) Draw(screen *ebiten.Image, offsetX int, offsetY int)

Draw (chunk) is used to draw the box for an entire chunk.

func (*Chunk) DrawChunkTiles

func (c *Chunk) DrawChunkTiles(screen *ebiten.Image, offsetX int, offsetY int)

func (*Chunk) SetX

func (c *Chunk) SetX(x int)

func (*Chunk) SetY

func (c *Chunk) SetY(y int)

func (*Chunk) Tile

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

func (*Chunk) X

func (c *Chunk) X() int

func (*Chunk) Y

func (c *Chunk) Y() int

type Chunks

type Chunks map[string]*Chunk

func (Chunks) Draw

func (c Chunks) Draw(screen *ebiten.Image, offsetX int, offsetY int)

Draw is used to draw all of the chunks on the screen for debugging purposed. Currently this will draw every chunk, not get what is visible in the viewport.

func (Chunks) FindChunkAtPosition

func (c Chunks) FindChunkAtPosition(x, y int) *Chunk

func (Chunks) FindTileAtPosition

func (c Chunks) FindTileAtPosition(x, y int) *Tile

func (Chunks) GetChunk

func (c Chunks) GetChunk(name string) *Chunk

func (Chunks) NewChunk

func (c Chunks) NewChunk(x, y int)

type Coordinates

type Coordinates struct {
	X int
	Y int
}

type Tile

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

func NewTile

func NewTile() *Tile

func (*Tile) Draw

func (t *Tile) Draw(screen *ebiten.Image, offsetX int, offsetY int)

func (*Tile) DrawStatus

func (t *Tile) DrawStatus() bool

func (*Tile) Move

func (t *Tile) Move(x, y int)

func (*Tile) SetDrawStatus

func (t *Tile) SetDrawStatus(b bool)

func (*Tile) SetX

func (t *Tile) SetX(x int)

func (*Tile) SetY

func (t *Tile) SetY(y int)

func (*Tile) X

func (t *Tile) X() int

func (*Tile) Y

func (t *Tile) Y() int

type Unit

type Unit int
const (
	ChunkSize  Unit = 32
	TileSize   Unit = 16
	ChunkPixel      = ChunkSize * TileSize
)

func (Unit) Int

func (u Unit) Int() int

type Viewport

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

Viewport is responsible for drawing everything on the screen.

func NewViewport

func NewViewport(screenX int, screenY int, debugger *debug.Debugger) *Viewport

func (*Viewport) Draw

func (v *Viewport) Draw(screen *ebiten.Image, world *World)

func (*Viewport) DrawScreenTiles

func (v *Viewport) DrawScreenTiles(screen *ebiten.Image, world *World)

func (*Viewport) OffsetX

func (v *Viewport) OffsetX() int

func (*Viewport) OffsetY

func (v *Viewport) OffsetY() int

func (*Viewport) ScreenX

func (v *Viewport) ScreenX() int

func (*Viewport) ScreenY

func (v *Viewport) ScreenY() int

func (*Viewport) SetOffsetX

func (v *Viewport) SetOffsetX(offsetX int)

func (*Viewport) SetOffsetY

func (v *Viewport) SetOffsetY(offsetY int)

func (*Viewport) SetScreenX

func (v *Viewport) SetScreenX(screenX int)

func (*Viewport) SetScreenY

func (v *Viewport) SetScreenY(screenY int)

func (*Viewport) SetWorldPosition

func (v *Viewport) SetWorldPosition(offsetX, offsetY int)

func (*Viewport) SetWorldPositionX

func (v *Viewport) SetWorldPositionX(worldPositionX int)

func (*Viewport) SetWorldPositionY

func (v *Viewport) SetWorldPositionY(worldPositionY int)

func (*Viewport) Update

func (v *Viewport) Update(offsetX, offsetY int)

func (*Viewport) WorldPositionX

func (v *Viewport) WorldPositionX() int

func (*Viewport) WorldPositionY

func (v *Viewport) WorldPositionY() int

type World

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

func NewWorld

func NewWorld(input *input.Input, screenX int, screenY int, debugger *debug.Debugger) *World

func (*World) ChunkAtMouse

func (w *World) ChunkAtMouse() *Chunk

func (*World) Draw

func (w *World) Draw(screen *ebiten.Image)

func (*World) InitWorld

func (w *World) InitWorld(screenX, screenY int)

Init World renders all of the chunks of the map when first loading the map. Afterward new chunks will be detected and added in the Update game loop.

We break up rendering into 4 quadrants of the viewport in which the X and Y numbers will always remain positive or negative for simplicity. So far example only things in the top right quadrant of the viewport.

func (*World) MoveOffset

func (w *World) MoveOffset(x, y int)

func (*World) MoveWorld

func (w *World) MoveWorld(direction input.Direction)

func (*World) Offset

func (w *World) Offset() (x, y int)

func (*World) OffsetX

func (w *World) OffsetX() int

func (*World) OffsetY

func (w *World) OffsetY() int

func (*World) SetOffset

func (w *World) SetOffset(x, y int)

func (*World) TileAtMouse

func (w *World) TileAtMouse() *Tile

func (*World) Update

func (w *World) Update()

func (*World) WorldPositionAtMouse

func (w *World) WorldPositionAtMouse() (int, int)

func (*World) WorldXPositionAtMouse

func (w *World) WorldXPositionAtMouse() int

func (*World) WorldYPositionAtMouse

func (w *World) WorldYPositionAtMouse() int

Jump to

Keyboard shortcuts

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