Case study - Final project, CS50x 2026

Orange Clicker

A browser incremental game about running an orange grove. It began as my week 0 Scratch project, where one clickable orange and one tree whose price doubled were enough. This is the same idea rebuilt with a Flask server, a SQLite database, and an economy that survives a reload.

Completed - November 2026Single player - Runs locallyFlask - SQLite - Vanilla JavaScript
  • Incremental game
  • Game design
  • Flask
  • SQLite
  • JavaScript
  • CS50x
Orange Clicker grove: orange click target, upgrade shop with tree, gloves and picker, season progress and achievements
Real capture The grove: click target, upgrade shop, season progress and achievements

01 - Origin

The same orange, built properly the second time

The Scratch version was a clicker, not a game: clicking paid one orange, the only upgrade doubled in price on every purchase, and everything reset when the page reloaded. It was fun for about ninety seconds.

Rebuilding it as the CS50x final project forced the interesting questions: how do you keep progress without the browser owning it, how do you make passive income matter when a player can click nine times a second, and what happens when someone closes the tab for eight hours.

02 - How it works

The server owns the numbers

The browser can only ask to pick, buy or end a season. The server validates the request, updates SQLite, and returns the whole new state, so nothing the client sends can create oranges.

There is no background loop. Every request first pays out rate x elapsed time, which means offline progress is not a separate feature: it is the same function running after a longer gap, at half rate and capped at eight hours.

Six tables hold the save, the upgrade catalogue, owned levels, finished seasons, the achievement catalogue and unlocked achievements. The production rate is never stored. It is summed from the levels a player owns, then multiplied by workers and the season bonus, so it cannot drift out of sync with what was actually bought.

Ending a season is three writes: record the season, delete the upgrade levels, reset the counters. The permanent bonus is derived from the season rows, so nothing else needs patching.

03 - Balance

Making automation worth buying

In the first version, a tree was worth half an orange per second and gloves grew more cheaply than trees, so clicking beat automation permanently. Comparing oranges per second per orange spent, the two crossed at about level seventy-seven: the trees were decoration.

A tree now produces a full orange per second, gloves grow faster, and the crossover lands near level eleven. Clicking owns the first two minutes, then the grove takes over.

Clicking still matters, but as a multiplier rather than a source. Twenty-five clicks charge a harvest surge that doubles production for twenty seconds, and because it multiplies the rate its value grows with the grove instead of falling behind it.

Ending a season resets the grove for a permanent bonus: twenty-five percent per finished season, plus one percent for every ten thousand oranges ever banked, with the requirement doubling each time.

04 - A bug found by playing

Timestamps are part of the economy

Clicking paid far more than the number on the button. SQLite stores CURRENT_TIMESTAMP to the second, so a tick at 05.9 seconds was recorded as 05, and the next request at 06.1 computed 1.1 seconds of production. At nine clicks per second the save was minting money.

Measured: twenty clicks over 1.66 seconds at a rate of 100 per second produced 2,404 oranges, where the clicks accounted for 360 and real elapsed production for about 166. Switching every tick write to millisecond precision fixed it; the same test now adds exactly 360, and a genuine ten-second gap pays 1,000.9.

Built as the final project for CS50x 2026. The coursework README documents the schema, the tick, the balance curves and the timestamp bug. AI assistance was used for implementation under my direction, as CS50 permits for the final project, and is disclosed in the project README and in the code headers.