
Civilization (Civ Demake)
Port nativo de Civilization (Civ Demake) para PC.
Civilization (Civ Demake)
Port nativo basado en su ficha de origen.
README del repositorio
Civ Demake
A small, from-scratch Civ1-style game for Windows, written in Zig. It keeps the 320x320 indexed-color look, map rules, unit movement, Goto, Settler work, cities, fog, and Civ1 combat behavior in a direct code base.
The game is a work in progress. The present part is fully playable by two local players, but it has no AI, economy, save files, sound, or full city work yet.
What is present
- An 80x50 world with X wrap and fixed-seed map generation.
- Terrain, coasts, rivers, resources, huts, roads, railroads, mines, irrigation, pollution, fortresses, cities, and fog.
- All 28 Civ1 unit types, stable unit slots, movement, Goto, work orders, stacks, veteran units, Barbarians, and nuclear effects.
- Combat rules checked against the original Win16 game.
- A 320x320, 8-bit indexed framebuffer in a 960x960 native Windows window.
- Water motion through palette cycling.
- Unit movement, attack, death-burst, path, and selection-blink pictures.
- Headless map-dump, PNG-shot, improvement, and unit test modes.
Build
The main target is Windows x86-64. Use Zig
0.17.0-dev.1441+d5181a9c9. Python is needed for the atlas build.
$zig = 'C:\zig-x86_64-windows-0.17.0-dev.1441+d5181a9c9\zig.exe'
& $zig build
& $zig build test
& $zig build -Doptimize=ReleaseSafe test
& $zig build -Doptimize=ReleaseFast
zig build puts civ.exe and atlas.bin in zig-out/bin.
ReleaseFast is the small, fast production build.
Run
& $zig build run --
& $zig build run -- 0xDEADBEEF
& $zig build run -- --dump 0xC1DE1234
& $zig build run -- --shot shot.png 0xC1DE1234
& $zig build run -- --improvements-demo
& $zig build run -- --units-demo
zig build run -- first makes the program when needed and then runs it. Text
after -- is sent to civ.exe.
Keys
| Key | Act |
|---|---|
| Arrows, WASD, numpad | Move the selected unit, or the map cursor |
Space | Select the active player's unit under the cursor |
G, then G | Start Goto and set its end tile |
Enter | End the player turn |
R | Make a road or railroad |
I | Make irrigation |
M | Make a mine |
K | Clean pollution |
B | Make a city |
F | Make a fortress |
F10 | Open the unit-add menu |
F11 | Write the map dump |
F12 | Make a new world and reset the date |
Only unit movement makes more fog tiles known.
Technical design
The game uses a direct set of small modules. There is no ECS, event bus, general render backend, or console layer.
Worldowns terrain, resources, huts, fog, improvements, regions, cities, and units.MapgenScratchowns all temporary map-generation memory.Pathfinderowns one shared Dial-bucket search and route.Gameowns players, money, turn, date, and difficulty state.Appowns the camera, selection, input modes, and short picture state.Rendererowns the indexed framebuffer and palette. It has no Win32 calls.Hostowns the Win32 window, DIB, key state, clicks, and frame wait.main.zigjoins CLI work, headless modes, the app, and the native host.
Normal frame, update, and render work takes no allocator. Main fixed-size limits
are checked at compile time: World <= 24 KiB, Pathfinder <= 8 KiB,
MapgenScratch <= 128 KiB, City == 5 bytes, and Unit == 7 bytes.
Code hierarchy
This is both a code map and a dependency guide. Arrows point from a higher-level part to the lower-level part it uses.
flowchart TD
build["build.zig<br/>build, tests, atlas step"]
main["main.zig<br/>CLI and main loop"]
host["host.zig<br/>Win32 host"]
root["root.zig<br/>game module"]
app["app.zig<br/>camera, input, modes"]
subgraph rules["Game rules and world"]
game["game.zig<br/>turns, dates, players"]
unit["unit.zig<br/>movement, work, combat"]
path["path.zig<br/>Dial-bucket routes"]
mapgen["mapgen.zig<br/>world generation"]
world["world.zig<br/>map and entities"]
rng["rng.zig<br/>fixed RNG"]
common["common.zig<br/>types and map rules"]
end
subgraph view["Indexed view and files"]
render["render.zig<br/>pure 8-bit renderer"]
atlas["atlas.zig<br/>named sprite access"]
asset["asset.zig<br/>ATL1 loader"]
font["font.zig<br/>8x8 text"]
png["png.zig<br/>PNG writer"]
end
subgraph art["Build-time art"]
manifest["assets/atlas.json<br/>layout source"]
sheets["assets/atlas/*.png<br/>seven indexed sheets"]
encoder["tools/encode_atlas.py"]
output["atlas.bin + generated Zig layout"]
end
build --> main
build --> encoder
main --> host
main --> root
root --> app
root --> rules
root --> view
app --> game
app --> unit
app --> path
app --> world
app --> render
unit --> game
unit --> path
unit --> world
unit --> rng
mapgen --> world
mapgen --> rng
path --> world
world --> common
render --> atlas
render --> asset
render --> font
render --> game
render --> path
render --> unit
render --> world
manifest --> encoder
sheets --> encoder
encoder --> output
output --> atlas
output --> asset
Source tree
| Path | Purpose |
|---|---|
src/ | Game, render, platform, file, and in-module test code |
assets/atlas/ | Seven logical indexed PNG sheets |
assets/atlas.json | Sprite names, grids, sizes, and packing order |
tools/ | Atlas import/build and font-data tools |
docs/ | Map-generation and atlas reference notes |
SPR32X32.png | Original art oracle; not read by a normal build |
HANDOFF.md | Current state, hashes, and work notes |
The normal build joins the seven source sheets into one compact ATL1 file and
makes a Zig sprite layout from the same JSON manifest. Hand-written Zig has no
packed atlas coordinates. The game loads only atlas.bin at run time.
Lines of code
Measured on 2026-07-22. LoC here means non-empty physical lines, with comments
and in-module tests included. Blank lines are not included. Generated
src/font_data.zig is shown on its own and is not in the hand-written total.
| Part | Files | LoC |
|---|---|---|
Hand-written Zig in src/ | 16 | 2,970 |
| Zig build code | 1 | 48 |
| Python tools | 3 | 304 |
| Hand-written total | 20 | 3,322 |
| Generated Zig font data | 1 | 100 |
There are 27 Zig test blocks. They live next to the code they check and run with
zig build test.
More detail
Comentarios (0)
Inicia sesión para dejar un comentario.
Sé el primero en comentar sobre este juego.
