game

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: MIT Imports: 40 Imported by: 0

Documentation

Overview

Package game is the Linefire runtime: it loads a player asset and a level and runs a minimal ship-in-a-world prototype. The ship stays centered on screen always pointing up; the world rotates and translates around it (the camera follows the ship's position and heading).

Index

Constants

View Source
const (
	SkirmishMapArena = "arena"
	SkirmishMapMaze  = "maze"
)

Skirmish map modes: the open field is the default show; the maze is the cave generator fitted to the screen, where rock blocks sight lines and shots and the fight happens around corners.

Variables

This section is empty.

Functions

func Run

func Run(content fs.FS, player *asset.Asset, lvl *level.Level, mapDir, mapName string) error

Run opens the window and starts the game loop. content is where the game data lives (the embedded bundle, or a directory on disk); mapDir is content's map subdirectory and mapName is the current map's file stem, so portals can load sibling maps by name (and detect same-map targets).

Types

type BattleOptions added in v0.0.28

type BattleOptions struct {
	Programs []string // one Filo source per faction, Programs[0] = faction 1 (empty = house brain)
	Factions int      // teams, clamped to 2..maxFactions (0 = 2)
	Ships    int      // hulls per faction (0 = 8)
	Map      string   // SkirmishMapArena (default) or SkirmishMapMaze
	Seed     int64    // arena generation and placement seed
	MaxTicks int      // battle length cap in ticks (0 = 7200: two minutes of game time)
}

RunBattle fights one skirmish without a window: the ships are placed up front, there are no reinforcements, and the simulation steps at full CPU speed until one faction stands alone or the tick budget runs out. Hundreds of battles fit in a few seconds of processing, which is what makes program development honest — a change to an AI is measured over many fights, not eyeballed over one. The graphical skirmish and this runner step the same code: updateEnemies, the Filo pilots, the shots, the damage.

Placement is deterministic for a given Seed; each hull's temperament (standoff spread, orbit direction) still draws from the game's own dice, so two runs of the same seed are close but not identical.

type BattleResult added in v0.0.28

type BattleResult struct {
	Winner int         // the faction left standing; 0 = draw (timeout, or mutual destruction)
	Ticks  int         // how long the fight ran
	Alive  map[int]int // live hulls per faction at the end
}

BattleResult is how one fight ended.

func RunBattle added in v0.0.28

func RunBattle(content fs.FS, mapDir string, opts BattleOptions) (BattleResult, error)

RunBattle builds the battlefield, lands the fleets and fights to the end.

type Game

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

Game is the ebiten.Game runtime.

func New

func New(player *asset.Asset, lvl *level.Level, mapDir string, simple bool) *Game

New builds a game from a player asset and a level. simple skips the per-area flood negative-space map and the fog-of-war (line-wall view, no discovery grid / fog texture): the procedural map uses it so a large streamed region renders fast and rebuilds cheaply on a chunk crossing. New builds a game that reads its data straight from the operating system (the default for tests and dev, which pass a directory such as "../gameassets"). Run uses newWithContent to serve the same data from the embedded bundle instead.

func NewSkirmish added in v0.0.19

func NewSkirmish(content fs.FS, mapDir string, opts SkirmishOptions) (*Game, error)

NewSkirmish builds the faction battle for a transparent desktop window: an endless horde dealt round-robin across the teams, and a fresh procedurally generated arena every ~20 seconds. The caller runs it with ebiten.RunGameWithOptions and ScreenTransparent.

func (*Game) Draw

func (g *Game) Draw(screen *ebiten.Image)

Draw renders the world around the centered, upward-pointing ship. Because the world swings by a large per-frame angle during a turn, a single still frame on a sample-and-hold display reads as a doubled line (stroboscopic stepping). To fill the gap, the moving world is accumulated over several intermediate camera poses between the previous and current frame and averaged. The ship itself is fixed at the screen center, so it is drawn once, crisp, on top.

func (*Game) Layout

func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int)

Layout renders at the display's native pixel density: the offscreen the game draws into is sized in device pixels and mapped 1:1 to the framebuffer, so vector strokes are anti-aliased at full resolution with no resampling step.

func (*Game) Update

func (g *Game) Update() error

type SkirmishOptions added in v0.0.19

type SkirmishOptions struct {
	Sound    bool   // create the audio context (default silent)
	Debug    bool   // show the debug HUD (there is no F3 to toggle it: skirmish reads no keys)
	Factions int    // teams sharing the arena, clamped to 2..maxFactions (0 = 2)
	Map      string // SkirmishMapArena (default) or SkirmishMapMaze

	// Programs is one Filo SOURCE per faction (Programs[0] drives faction 1,
	// and so on); an empty entry leaves that faction on the house brain. The
	// contract a program flies under is pilot.go's doc. Reading files is the
	// caller's job: the game takes source text.
	Programs []string
}

Jump to

Keyboard shortcuts

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