← Work

Hats & Spores

An incremental farming game for phones. Mushrooms grow on timers, gnomes harvest them, and coins buy upgrades and new farms.

Role
Solo: design, code, economy, release
Platforms
iOS, Android
Stack
Flutter, Flame, AdMob, in-app purchase
Status
v1.0.1 · App Store · Google Play
Site
hatsandspores.artemkorzh.dev
Farm 1, Meadow biome, with gnomes harvesting and the upgrade panel Mossy Swamp biome Crystal Cave biome Night Grove biome
Four of eight biomes, captured by the game's own screenshot mode

Architecture

One object, GameState, owns the simulation: coins, spores, every farm, plot timers and gnome harvests. Everything else reads from it.

core/

Plain Dart, no drawing. GameState (a ChangeNotifier with an event stream), quests, saving, audio, monetisation. Every number and formula is in game_config.dart.

game/ · Flame

The swipeable farm strip, plots, mushrooms, gnome poses and coin pop-ups. Reads GameState every frame and holds no rules.

ui/ · Flutter

HUD, upgrade panel, tab bar and sheets, rebuilt by ListenableBuilders on GameState.

Harvests, purchases, unlocks and quest claims are published on GameState.events. Audio, coin pop-ups and gnome animations subscribe to that stream, so none of them is wired into game logic. Quests derive their progress from the same lifetime counters the Stats screen shows, so nothing updates per frame just to track a quest.

Many farms, few nodes

Farms are endless: after the first eight biomes, new farms keep coming in a reshuffled biome order. Only the current farm page and its two neighbours are mounted in Flame, so the game runs the same at 50 farms as at 3. Swiping to a neighbour slides; jumping from the farm list cuts straight there, which avoids building every page in between.

Each plot runs its own timer. New plots start up to 30% grown so harvests stay out of step and the farm never pulses in unison.

Tuning the economy

Pacing is measured, not guessed. A script plays like a person: it taps every second for 15 minutes, then checks in every 3 minutes, buys the upgrade with the best income per coin, claims quests as soon as they finish and buys the cheapest shop upgrade it can afford.

MilestoneTargetMeasured
Third plot1:000:48
First gnome3:001:30
Farm 25:005:48
Farm 1 maxed15:00~25:00
Farm 345:00~43:00
Farm 4 / 52h+2:07 / 3:46

The fertilizer trap

Fertilizer used to be uncapped: each level cost 2.4× the last for a fixed +50%. Deep levels on old farms became a trap. Level 12 on Farm 1 cost 2.37M coins for +0.6 coins per harvest, while a level on Farm 7 cost less and paid about 1,000× more. Fertilizer is now capped at 6, every upgrade has a maximum so old farms “finish”, and farm prices from Farm 4 on were raised to compensate. Existing saves keep their levels.

// farms past the hand-tuned table
growTime(i)  = max(10 − i, 4) s
coins(i)     = coins(i − 1) × 3.5
unlock(i)    = unlock(i − 1) × 5

Offline progress

offlineCoins = gnomeIncomePerSec × min(timeAway, cap) × rate
// base: rate 20%, cap 2h · with shop upgrades: 35%, 3h

Only plots with gnomes earn while you are away. The rule behind the numbers is that being away must never beat playing: with Farms 1–4 and the offline upgrades maxed, a full night pays roughly the price of Farm 5 but none of its upgrades. The “Welcome back” sheet only appears after 60 seconds away; shorter gaps pay silently.

Saving

The game writes save.json every 10 seconds and whenever the app is paused or closed. It writes to a temporary file and renames it, so a crash mid-write leaves the previous save intact. A save that fails to parse is kept as save.corrupt.json and a new game starts instead of crashing. Fields added in later versions have defaults, so old saves always load.

The purchase is deliberately not in the save. It is cached locally and restored from the store on every launch, so starting a new game never loses it.

Audio

The music is a seamless loop. iOS can't play OGG, and MP3 encoders add silence at the end, so it ships as AAC in an MP4 container whose edit list trims the encoder padding and keeps the loop point tight. A script cut the original on the beat to whole bars and blended the end back into the start.

Sound effects play at ±5% random pitch so repeats don't sound mechanical, with up to six voices at once. Gnome harvests are silent on purpose; otherwise an idle farm would never stop popping. The upgrade sound is a wooden thunk with no chime, so it can't be mistaken for a phone notification.

Ads and the purchase

Ads are rewarded only, and only when the player asks for one: double offline coins, swap a quest, or double coins for 30 minutes followed by a 4-hour cooldown. Google's UMP consent form runs before any ad is requested. A single non-consumable purchase unlocks Farm 7 onward and grants every bonus without an ad, under the same limits.

Debug builds on macOS swap in a stand-in where an ad “plays” for one second and the purchase is free, so every monetisation flow can be tested without a phone.

Biomes
8
Logic tests
32
Farms
∞