sct

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package sct implements reading of Total Annihilation SCT (Section) map files.

SCT files contain tile-based terrain sections used by the TA map editor. Each section has a grid of 32×32 pixel tiles, height data, and a 128×128 minimap.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WritePNG

func WritePNG(w io.Writer, img image.Image) error

WritePNG encodes an image to PNG format.

Types

type Header struct {
	Version    uint32 // Always 3
	PtrMinimap uint32 // Offset to 128×128 minimap
	NumTiles   uint32 // Number of 32×32 tiles
	PtrTiles   uint32 // Offset to tile pixel data
	Width      uint32 // Section width in tiles
	Height     uint32 // Section height in tiles
	PtrData    uint32 // Offset to section data (tile indices + height)
}

Header is the 28-byte SCT file header.

type HeightData

type HeightData struct {
	Height uint8
}

HeightData is one height sample (4 per tile). In V3 files this is 4 bytes; in V2 files it is 8 bytes.

type Section

type Section struct {
	Header    Header
	Tiles     [][]byte     // NumTiles entries, each 1024 bytes (32×32 palette indices)
	TileMap   []int16      // Width×Height tile indices into Tiles
	HeightMap []HeightData // (Width*2)×(Height*2) height samples at 16px resolution
	AttrW     int          // Width * 2 (attribute grid width)
	AttrH     int          // Height * 2 (attribute grid height)
	Minimap   []byte       // 128×128 palette indices
}

Section is a parsed SCT file.

func LoadFromReader

func LoadFromReader(r io.ReadSeeker) (*Section, error)

LoadFromReader parses an SCT file from the given reader.

func (*Section) RenderHeightMap

func (s *Section) RenderHeightMap() *image.Gray

RenderHeightMap renders the height data as a normalized greyscale image. The attribute grid is AttrW × AttrH (2× the tile grid, at 16px resolution).

func (*Section) RenderMinimap

func (s *Section) RenderMinimap(palette color.Palette) *image.RGBA

RenderMinimap renders the minimap as an RGBA image using the given palette.

func (*Section) RenderTileMap

func (s *Section) RenderTileMap(palette color.Palette) *image.RGBA

RenderTileMap renders the full tile map as an RGBA image using the given palette.

Jump to

Keyboard shortcuts

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