stone

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: GPL-2.0 Imports: 8 Imported by: 2

README

Introduction

Stone is simple library that allows rendering Tiled maps with Pixel library.

Originally created as part of Mural GUI.

Usage

First, make sure you have dependencies required by Pixel.

Get sources from git:

go get -u github.com/isangeles/stone

Create map:

tmxMap, err := stone.NewMap("path/to/map.tmx")
if err != nil {
   panic(fmt.Errorf("Unable to create map: %v", err))
}

Draw map in Pixel window:

for !win.Closed() {
    // ...
    pos = pixel.V(0, 0) // e.g. camera pos
    tmxMap.Draw(win, pixel.IM.Moved(pos))
}

Check example package for more examples.

Contributing

You are welcome to contribute to project development.

If you looking for things to do, then check TODO file or contact maintainer(ds@isangeles.dev).

When you find something to do, create new branch for your feature. After you finish, open pull request to merge your changes with master branch.

Contact

License

Copyright 2019-2024 Dariusz Sikora <ds@isangeles.dev>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Documentation

Overview

Stone allows rendering TMX maps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Layer

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

Struct for map layer.

func (*Layer) Name

func (l *Layer) Name() string

Name returns layer name from tmx data.

func (*Layer) Tiles

func (l *Layer) Tiles() []*Tile

Tiles returns all layer tiles.

type Map

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

Struct for graphical representation of TMX map.

func NewMap

func NewMap(path string) (*Map, error)

NewMap creates new map from .tmx file with specified path.

func (*Map) Draw

func (m *Map) Draw(tar pixel.Target, matrix pixel.Matrix)

Draw use specified matrix to draw map on target. Draws whole map starting from position specified in given matrix.

func (*Map) DrawPart

func (m *Map) DrawPart(tar pixel.Target, matrix pixel.Matrix, size pixel.Vec)

DrawSize use specified matrix and size to draw map on target. Draws part of the map in specified size starting from position specified in given matrix.

func (*Map) Layers

func (m *Map) Layers() []*Layer

Layers returns all map layers.

func (*Map) PositionLayer

func (m *Map) PositionLayer(p pixel.Vec) *Layer

PositionLayer returns visible layer on specified position on map or nil if there is no tiles on this position.

func (*Map) Size

func (m *Map) Size() pixel.Vec

Size returns size of the map.

func (*Map) TileSize

func (m *Map) TileSize() pixel.Vec

TileSize returns size of singe map tile.

type Tile

type Tile struct {
	*pixel.Sprite
	// contains filtered or unexported fields
}

Struct for map tile.

func (*Tile) Bounds

func (t *Tile) Bounds() pixel.Rect

Bounds returns tile size bounds.

func (*Tile) Position

func (t *Tile) Position() pixel.Vec

Position returns tile position.

Directories

Path Synopsis
example
camera
Example for rendering TMX map with movable camera.
Example for rendering TMX map with movable camera.
layers
Example for identifying map layer on specific position.
Example for identifying map layer on specific position.
layerscamera
Example for identifying map layer on specific position while moving camera.
Example for identifying map layer on specific position while moving camera.
map
Example for rendering TMX map.
Example for rendering TMX map.

Jump to

Keyboard shortcuts

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