Skip to content

Repository files navigation

🏝️ Castoff

A top-down open-world survival game that runs entirely in your browser.

Wash ashore with nothing. Chop, mine, forage, craft, build, fight, and sail between islands before thirst, hunger, or the wolves get to you first.

Play Now

Angular TypeScript Canvas Zero deps License


What is this?

Castoff is a complete survival sandbox built from scratch β€” no game engine, no physics library, no sprite packs. The world is generated procedurally and drawn with raw Canvas 2D calls, wrapped in an Angular shell that handles the UI.

It's a real loop: manage three vitals, gather across a biome-varied archipelago, climb a tool tier, fortify a base, survive the night, and sail to new islands.

Features

🌍 Procedural open world

A 100Γ—100 tile archipelago generated at runtime with wobbly, organic coastlines and blended shorelines β€” three islands, each with its own resource character:

Island Location Character
Home Center Balanced β€” a fair start
Rocky Isle Northeast Stone-rich, sparse trees
Forest Isle Southwest Dense forest and berries β€” and wolves

πŸŽ’ Survival loop

Health, thirst, and hunger drain in real time. Let thirst or hunger bottom out and health starts draining too. Eat berries, drink at the shore, or rest beside a campfire to recover.

βš’οΈ Crafting & tool tiers

Tools aren't cosmetic β€” the best one you own auto-equips as your weapon, and a matching tool doubles your gather yield.

Item Cost Effect
πŸͺ“ Axe 3 wood 2Γ— wood per chop Β· 14 dmg
⛏️ Pickaxe 2 wood, 2 stone 2Γ— stone per mine Β· 12 dmg
πŸ—‘οΈ Spear 4 wood, 2 stone Longest reach Β· 18 dmg
πŸ›Ά Raft 8 wood, 3 stone Sail between islands
πŸ”₯ Campfire 6 wood Light source + passive healing
🧱 Wall 4 wood Solid barrier β€” fortify a base
πŸ“¦ Chest 5 wood Persistent storage

Bare fists deal 8 damage β€” an axe nearly doubles that.

πŸŒ™ Day & night cycle

A full cycle runs every three minutes. Nights fall genuinely dark: visibility collapses to a bubble around you, punched open by any campfire you've built. Wolves see much farther after sundown, so darkness is a real threat rather than a palette swap.

βš”οΈ Combat

Two enemy types with distinct AI, speed, and aggression. Crabs patrol the sand; wolves hunt the forest isle β€” faster, harder-hitting, with eyes that glow at night. Both wander until they spot you, then chase and strike.

β›΅ Sailing

Build a raft, board it at any shoreline, and cross open water. Step onto land and you disembark automatically.

πŸ—ΊοΈ Live minimap

All three islands, your heading, your structures, and live enemy positions at a glance.

πŸ’Ύ Autosave

Progress persists to localStorage every 5 seconds and on tab close β€” position, vitals, inventory, harvested resources, built structures, and time of day all survive a refresh.

Controls

Input Action
W A S D / arrows Move
E Open the context action wheel
1 – 4 Pick a wheel action (or click it)
Space Attack
Esc Close wheel / chest

The action wheel is contextual β€” it only offers what's valid where you stand. Next to a tree you get Chop; at the shore, Drink and Build Raft; facing open ground, Build Wall and Build Chest.

Getting started

git clone https://github.com/arafatomer66/castoff.git
cd castoff
npm install
npm start

Then open http://localhost:4200.

npm run build         # production build
npm run build:pages   # build for GitHub Pages (sets base href)

Requires Node 24+.

Architecture

The core design decision: Angular renders the UI, raw Canvas renders the world. Pushing 10,000 tiles through change detection every frame would be pointless overhead β€” so the game loop lives in plain TypeScript classes, and only the state the HUD actually cares about crosses into Angular, as signals.

src/app/game/
β”œβ”€β”€ game-engine.service.ts   # Game loop, rendering, signal bridge to the UI
β”œβ”€β”€ core/
β”‚   β”œβ”€β”€ camera.ts            # Viewport follow + worldβ†’screen transform
β”‚   β”œβ”€β”€ input.ts             # Key state + edge detection
β”‚   └── util.ts              # Deterministic hash, clamp, lerp, colour
β”œβ”€β”€ world/
β”‚   β”œβ”€β”€ tilemap.ts           # Procedural archipelago generation
β”‚   β”œβ”€β”€ world.ts             # Spatial buckets, collision, resource scatter
β”‚   β”œβ”€β”€ actions.ts           # Context-sensitive action wheel builder
β”‚   β”œβ”€β”€ resource-node.ts     # Trees, rocks, berry bushes
β”‚   β”œβ”€β”€ structure.ts         # Campfires, walls, chests
β”‚   └── tile-types.ts        # Terrain palette + walkability
β”œβ”€β”€ entities/
β”‚   β”œβ”€β”€ player.ts            # Position, vitals, inventory
β”‚   └── enemy.ts             # Crab & wolf state
β”œβ”€β”€ combat/combat.ts         # Weapon tiers, enemy AI, damage resolution
β”œβ”€β”€ persistence.ts           # localStorage save/load
β”œβ”€β”€ game-canvas/             # Canvas host component
└── hud/                     # Stats, hotbar, action wheel, minimap, chest

Notable implementation details

  • Deterministic generation β€” a hash function seeds terrain and resource placement, so the same world regenerates identically on every load. Saves need only store deltas (what you harvested), never the whole map.
  • Spatial bucketing β€” resource nodes are indexed by tile, keeping proximity queries O(nearby) instead of scanning every node each frame.
  • Cached minimap terrain β€” rasterized once at 1px-per-tile and blitted per frame, rather than re-walking 10,000 tiles.
  • Composite-op lighting β€” night is a dark overlay with light sources punched out via destination-out, giving soft radial falloff cheaply.
  • Zero game dependencies β€” every sprite is drawn with Canvas primitives. Nothing but Angular itself is installed.

Deployment

Pushing to main triggers a GitHub Actions workflow that builds the app and publishes it to GitHub Pages. It's a fully static bundle with no backend, so the whole game ships as a handful of files.

Roadmap

  • More biomes and a larger archipelago
  • Tool durability and higher tiers
  • Cookable food and a crafting bench
  • Mobile touch controls
  • Ambient audio and effects

License

MIT β€” do what you like with it.


Built with Angular, Canvas, and no game engine whatsoever.

About

🏝️ Open-world browser survival game β€” craft, build, fight, and sail between procedurally generated islands. Angular + Canvas, zero game engine.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages