Documentation
¶
Overview ¶
useful for when you're not blind
Index ¶
- Constants
- Variables
- func Clear(color core.Color)
- func DrawTexture(texture Texture, pos core.Vec2, angle float64, color core.Color)
- func DrawTextureExt(texture Texture, srcPos core.Vec2, srcSize core.Vec2, dstPos core.Vec2, ...)
- func EndDrawing()
- func Free()
- func FreeAllTextures()
- func GenerateChunk(randgen *rand.Rand, chunkPos core.Vec3i) (map[core.Vec3i]*Tile, map[core.Vec3i]*Tile)
- func Init()
- type Texture
- type Tile
- type TileData
- type TileId
- type TileWorld
- func (t *TileWorld) Draw()
- func (t *TileWorld) GetTile(pos core.Vec3i, ground bool) *Tile
- func (t *TileWorld) NewTile(pos core.Vec3i, ground bool, tileId TileId, entity entities.EntityRef, ...) *Tile
- func (t *TileWorld) ScreenToTile(pos core.Vec2, textureSize core.Vec2i) core.Vec3i
- func (t *TileWorld) SetCameraPosition(pos core.Vec3)
- func (t *TileWorld) TileToScreen(pos core.Vec3i, textureSize core.Vec2i) core.Vec2
- type VariationId
Constants ¶
const ChunkSize int64 = 16
chunk size (they're square)
const MaxLayer int64 = 48
how up can you go
const MinLayer int64 = -16
how down can you go
const TotalLayers int64 = 64
mate
Variables ¶
var TileNames map[TileId]string = map[TileId]string{ TileAir: "stellarthing:Air", TileBobGuy: "stellarthing:BobGuy", TileMarsRock: "stellarthing:MarsRock", TileBlueGuy: "stellarthing:BlueGuy", TileGreenGuy: "stellarthing:GreenGuy", TileLife: "stellarthing:Life", }
printable tile IDs so i don't have to memorize 2370611866
var Tiles map[TileId]map[VariationId]*TileData = map[TileId]map[VariationId]*TileData{ TileAir: { 0: &TileData{ Texture: "assets/air.png", Tint: core.ColorWhite, }, }, TileBobGuy: { 0: &TileData{ Texture: "assets/bob_guy.png", Tint: core.ColorWhite, }, }, TileMarsRock: { 0: &TileData{ Texture: "assets/mars_rock.png", Tint: core.ColorWhite, }, }, TileBlueGuy: { 0: &TileData{ Texture: "assets/blue_guy.png", Tint: core.ColorWhite, }, }, TileGreenGuy: { 0: &TileData{ Texture: "assets/green_guy.png", Tint: core.ColorWhite, }, }, TileLife: { 0: &TileData{ Texture: "assets/life.png", Tint: core.ColorWhite, }, }, }
tile data from IDs and variations
Functions ¶
func DrawTexture ¶
draws a texture. if you want a comically large parameter list use DrawTextureExt instead
func DrawTextureExt ¶
func DrawTextureExt(texture Texture, srcPos core.Vec2, srcSize core.Vec2, dstPos core.Vec2, dstSize core.Vec2, origin core.Vec2, angle float64, tint core.Color)
this is utter insanity. srcPos and srcSize are used for cropping the image, dstPos and dstSize are the actual position and size, origin is a multiplier so (0, 0) is the top left, (0.5, 0.5) is the center, and (1, 1) is the bottom right. everything else is self-explanatory
func FreeAllTextures ¶
func FreeAllTextures()
Types ¶
type Texture ¶
type Texture struct {
// contains filtered or unexported fields
}
texture :)
func LoadTexture ¶
supported formats are PNG, BMP, TGA, JPG, GIF, QOI, PSD, DDS, HDR, KTX, ASTC, PKM, and PVR
type Tile ¶
type Tile struct { TileId TileId EntityRef entities.EntityRef Variation VariationId }
optimized tile. for actual data use TileData
type TileData ¶
type TileData struct { // path for the string, loaded by the renderer then put in the Texture cache Texture string // used for moving entities Position core.Vec3 // man UsingCustomPos bool // lol Tint core.Color }
it's tile data
type TileId ¶
type TileId uint32
yeah
const TileAir TileId = 0
const TileBlueGuy TileId = 3620194283
const TileBobGuy TileId = 370779849
const TileGreenGuy TileId = 1097781405
const TileLife TileId = 4262882056
const TileMarsRock TileId = 2370611866
type TileWorld ¶
type TileWorld struct { Seed int64 // set with SetCameraPosition :) CameraPosition core.Vec3 // mate CameraOffset core.Vec2 // the top left corner StartPos core.Vec2i // the bottom right corner EndPos core.Vec2i LoadedGroundTiles map[core.Vec3i]*Tile LoadedObjectTiles map[core.Vec3i]*Tile LoadedChunks []core.Vec3i // this sucks TheyMightBeMoving []*Tile // contains filtered or unexported fields }
world of tiles :D
var CurrentWorld *TileWorld
current world.
func NewTileWorld ¶
makes a new world. the startPos is the top left corner and the endPos is the bottom right corner.
func (*TileWorld) NewTile ¶
func (t *TileWorld) NewTile(pos core.Vec3i, ground bool, tileId TileId, entity entities.EntityRef, variation VariationId) *Tile
as the name implies, it makes a new tile. if the variation doesn't exist, it's gonna copy the default variation too
func (*TileWorld) ScreenToTile ¶
gets a tile position from screen positions
func (*TileWorld) SetCameraPosition ¶
sets the camera position and loads chunks
type VariationId ¶
type VariationId uint32
tiles can have variations. the default variation is always 0