placeholder

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 13 Imported by: 5 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package placeholder is a small asset pack for prototypes, tutorials and the examples, dedicated to the public domain under CC0 1.0 (License): sprite sheets, a tileset with a Tiled tileset and a sample level, a pixel font, sound effects and a music loop, and three glTF models.

Every file was drawn, synthesized or modeled in Go for this repository by the generator under internal/gen, which writes the same bytes on every run, and the package embeds them and FS returns them. Each image and sound has the import settings sidecar game assets reads (package importsettings): a sprite sheet's slices it into 16 by 16 frames, the tileset's and the font page's keep their pixels sharp, and a sound's sets its loudness and, for the music, its loop. CREDITS.md in FS() lists every file with its license, so a game that ships the pack's files can ship its credits too.

Sheet, Font, Level, Model and Sound load the pack's assets ready for packages sprite, text, tilemap, gltf and NSGo's audio. A game that copies the files into its own project instead builds them with game assets like any other art.

Index

Examples

Constants

View Source
const License = "CC0-1.0"

License is the SPDX identifier of the license of every file in the pack: Creative Commons Zero v1.0 Universal, a dedication to the public domain.

Variables

This section is empty.

Functions

func FS

func FS() fs.FS

FS returns the pack's files, read-only, by their slash-separated paths, such as "sprites/player.png": the sprite sheets with their JSON and import settings sidecars under sprites/, the tileset, its Tiled tileset and a sample level under tiles/, the bitmap font under fonts/, the sounds under sounds/, the models under models/, and CREDITS.md, which lists every file with its license.

func Font

func Font() (*text.Font, error)

Font loads the pack's proportional pixel font, fonts/pixel.fnt and its page fonts/pixel.png: printable ASCII, 7 pixels tall above the baseline with descenders below it, lines 10 pixels apart.

func Image

func Image(file string) (core.ImageSource, error)

Image returns the PNG image at the slash-separated path file in the pack as an image source of its PNG data, sized in points as it is in pixels.

func Level

func Level() (*tilemap.Tilemap, error)

Level loads the sample level tiles/level.tmj: 40 by 15 tiles of 16 pixels on the tileset tiles/tileset.tsj, with a "decor" and a "ground" tile layer and an "objects" layer of points whose types are spawn, coin, gem, slime and bat, and an exit rectangle. The tileset's tiles carry the properties solid, oneWay, ladder, hazard and water, so the map's tile flags mark solid and one-way tiles, and water, lava and the torch are animated.

Example

Level loads the sample level and finds where the player starts.

package main

import (
	"fmt"

	"github.com/nsgo-dev/game/pkg/placeholder"
)

func main() {
	level, err := placeholder.Level()
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(level.Width, "x", level.Height, "tiles of", level.TileWidth)
	for _, o := range level.ObjectLayer("objects").Objects {
		if o.Type == "spawn" {
			fmt.Println("spawn at", o.X, o.Y)
		}
	}
}
Output:
40 x 15 tiles of 16
spawn at 40 208

func Model

func Model(file string) (*gltf.Document, error)

Model loads the glTF model models/<file>: "crate.glb", a 1 m cube; "robot_arm.gltf", a two-bone arm, skinned, with a "Wave" animation; or "gem.glb", a gem 1 m tall. Each stands on the origin, +Y up and -Z forward.

func Sheet

func Sheet(name string) (*sprite.Atlas, error)

Sheet loads the sprite sheet sprites/<name>.png with its frames and animations from sprites/<name>.json: "player", "slime", "bat", "coin", "items", "effects" or "ui". Frame i is named <name>_<i>, and each animation is named after its Aseprite tag, such as "run" in the player's sheet or "heart" in the items'.

Example

Sheet loads the player's sprite sheet, whose run animation a sprite plays.

package main

import (
	"fmt"

	"github.com/nsgo-dev/game/pkg/placeholder"
	"github.com/nsgo-dev/game/pkg/sprite"
)

func main() {
	sheet, err := placeholder.Sheet("player")
	if err != nil {
		fmt.Println(err)
		return
	}
	run := sheet.Animations["run"]
	fmt.Println(len(sheet.Frames), "frames")
	fmt.Println("run:", len(run.Frames), "frames of", run.Frames[0].Duration, "looping:", run.Loop)
	hero := sprite.NewSprite(run.Frames[0].Frame)
	fmt.Println(hero.Frame.Name, "origin", hero.OriginX, hero.OriginY)
}
Output:
8 frames
run: 4 frames of 100ms looping: true
player_2 origin 8 8

func Sound

func Sound(name string) (core.AudioSource, error)

Sound returns the WAV file sounds/<name>.wav as an audio source: the effects "jump", "coin", "hit", "explosion", "shoot", "powerup", "click" and "select", or "music_loop", four bars that loop without a seam.

Example

Sound reads a sound effect, ready for NSGo's audio package to load and play.

package main

import (
	"fmt"

	"github.com/nsgo-dev/game/pkg/placeholder"
)

func main() {
	jump, err := placeholder.Sound("jump")
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(string(jump.Data[:4]), string(jump.Data[8:12]))
	fmt.Println(placeholder.License)
}
Output:
RIFF WAVE
CC0-1.0

Types

This section is empty.

Directories

Path Synopsis
internal
gen
Package gen draws every file of the placeholder asset pack in code: sprite strips, a tileset with a Tiled tileset and map, a bitmap font, sounds and models, with the import settings sidecar of each image and sound.
Package gen draws every file of the placeholder asset pack in code: sprite strips, a tileset with a Tiled tileset and map, a bitmap font, sounds and models, with the import settings sidecar of each image and sound.

Jump to

Keyboard shortcuts

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