Game Design & Development · Build a Classic
Lemonade Tycoon Builder: Make Your Own Business Game
Every morning you check the weather, decide how many cups to make and what to charge, and then find out whether you guessed right. Lemonade Stand has been teaching that loop to students since the 1970s, and it is a perfect economy simulation: a few numbers, one formula for demand, and a lot of tension. In this lesson you build the whole engine in about 90 lines of JavaScript, work out the best price with arithmetic, and then change the data to turn it into your own business: a school store, a food truck, a 3D-print farm, or something nobody has opened yet.
1 · Why this game works
A tycoon game is a machine for making decisions with a price on them. Nothing here needs fast thumbs. The fun comes from three design ideas.
- A trade-off with a sweet spot. Charge too little and you sell out but earn almost nothing per cup. Charge too much and nobody stops. The best price is somewhere in the middle, and you can find it with math.
- Information you can't fully trust. The forecast is right most of the time, not always. Betting on it is a decision about probability, not a puzzle with one answer.
- Growth that feeds itself. Spend money on a sign or a cooler today and every later day earns more. That is compound growth, and the question is always whether there are enough days left to pay it back.
The program is the same loop every day. Learn it and you can build almost any shop, farm or factory game:
…then tomorrow's forecast arrives. Like every game loop, it is a state machine: the game is always in one state (a morning waiting for your choices, or the end), and each button moves it on.
2 · The Tycoon Lab: play it, then break it
This is the finished engine. Everything about the business, including what it sells, the weather, the events, the upgrades and every balance number, lives in the config on the left. Pick a preset, press Run my game, and run the stand for a few days. Open the analyst's chart and see whether it agrees with your gut. Then change something small and run it again. You are already designing.
[ ], objects in { }. An error message will tell you which line is broken (usually a missing comma). Things to try: "topPrice"is the price where nobody buys. Raise it and your customers become less price-sensitive."baseCustomers"is how many people walk by on a normal day.- Each weather type has a
demandmultiplier. Rain at0.4means 40% as many customers. Aweightof 4 happens four times as often as a weight of 1. "forecastAccuracy"(0 to 1) is how often the forecast is right. At 1 there is no uncertainty, and the game gets much easier. At 0.3 it is nearly useless.- An event can change
demand(a multiplier for today),cost(added to what each item costs today) orcash(a one-time bill or bonus). - An upgrade multiplies your demand forever. Try making one cheap and strong, and see how it ruins the game's balance.
- Add
"seed": 7and the dice roll the same every time, which is handy for testing your balance.
3 · Build the engine yourself in seven steps
The Lab above has extras (a chart, an end screen, a currency and item names you can change). To understand it, first build the core. Make a file called lemonade.html, paste the page skeleton below, and then add each step inside its <script> tag in order. After every step, save, reload, and run it. Don't move on until the checkpoint is true.
Step 1 · Put the whole business in one data object
Before any logic, write down what the game is: prices, costs, weather and events. Keeping the content in GAME and the rules in functions means a spin-off only needs to change this one block. This is called data-driven design, and every engine you will ever use works this way.
GAME.weather.length. It should print 4.Step 2 · Track the state
The state is everything that changes while the game runs. Notice that boost starts at 1 and is multiplied every time you buy an upgrade. That one number is the whole compound-growth engine.
Step 3 · Small helpers
say() writes a line to the log, money() formats a number as dollars, and weighted() is the trick behind weather and event tables: add up the weights, pick a number in that range, and walk down the list until it runs out. draw() shows the current state and builds the upgrade buttons.
if statements.Step 4 · The demand formula
This is the heart of the game, and it is only three lines. How many people would buy? Start with the crowd for today (base customers × weather × your upgrades × any event). Then each person only buys if the price is below what they are willing to pay. We model that with a straight line: at a price of $0 everyone buys, at topPrice nobody does, and in between the share falls steadily.
demand(1, GAME.weather[1], 1) (a cloudy day at $1). It should print 30: 60 customers, and half of them are willing to pay $1.Step 5 · A morning and a business day
morning() rolls the real weather and then a forecast: with probability forecastAccuracy the forecast is right, and otherwise it is a fresh random roll. The player only sees the forecast. openStand() then reads the price and cup count, asks the demand formula how many people want one, and sells min(demand, cups). Unsold cups are wasted, and customers you couldn't serve walk away. Both mistakes cost money in different ways.
Step 6 · Upgrades
An upgrade costs cash now and multiplies boost from then on. It is the same decision as buying a bigger oven or a delivery bike: the answer depends on how many days are left.
Step 7 · Win, lose, and wire it up
A game needs an ending. After every day, check the two ways the season can finish, then connect the button.
Show the complete program
4 · Find the best price with arithmetic
Here is the secret of the demand formula. If you sell every customer who wants a cup, then profit per day is
profit(p) = (p − cost) × customers × (1 − p ÷ topPrice) − rent
The first part is zero when the price equals the cost, and the second part is zero when the price equals topPrice. A curve that is zero at two prices peaks exactly halfway between them, so the best price is
best price = (cost + topPrice) ÷ 2
Try the numbers below. The chart is profit against price for a normal day, and the dot is the best price. Move topPrice and cost and watch where the peak goes.
Two warnings. First, this assumes you made enough cups. In the real game you must guess the day's crowd from an imperfect forecast, so the formula tells you the price and the forecast tells you the quantity. Second, a price that is perfect on paper is only the start: playtest. Set "seed" in the Lab, ask a friend to play three seasons while you stay quiet, and watch where they get stuck. If everyone finds the best price on day one, make the formula less obvious or add a reason to change it, such as an event that adds to the cost.
Tuning the goal. A good goal is one that a player using the best price and buying the right upgrades wins most of the time, while one who ignores the math almost never does. A simulation of thousands of seasons of the default stand found that a player with the best price and the sign and cooler won about four seasons in five, one who skipped the upgrades about one in three, and one who always charged 90% of the top price never won. You can run your own experiment with a loop and Math.random(): that is how real studios balance games.
5 · Design your spin-off
A good spin-off keeps the structure (a price, a stock decision, an uncertain day, an upgrade) and changes the world. Translate each part of the original, and you will notice that most of the game is already written.
| Part of the game | Lemonade stand | School store | 3D-print farm | Your spin-off |
|---|---|---|---|---|
| What you sell | Cups of lemonade | Snacks and supplies | Printed models | ? |
| Cost each | Lemons, sugar, cup | What the store paid | Filament and power | ? |
| The day's crowd | Weather | Game night, spirit week | Science fair rush | ? |
| Surprise | Sugar price jumps | A broken freezer | A failed print | ? |
| Fixed cost | Stand rent | None (volunteers) | Printer maintenance | ? |
| Upgrade | Painted sign, cooler | Bigger display, card reader | A second printer | ? |
Not sure where to start? Roll the idea dice.
Twists that change the rules, not just the pictures
- A rival: a second stand across the street. If your prices differ, customers move toward the cheaper one.
- Loans: borrow $20 on day 1 and owe it back with interest. This is compound growth working against you.
- Quality: add a recipe slider. Better ingredients cost more but raise
topPrice, so the best price moves. - Reputation: a second meter that rises when you sell out fairly and falls when you waste stock or overcharge. High reputation raises tomorrow's crowd.
- Leftovers: unsold items carry over, but some spoil each night. Now stock is a real long-term decision.
- Seasons: make the weather weights depend on the day, so winter is slow and summer is a rush.
Design sheet
When the sheet is done, put it in the Lab config (or into the GAME object of your own lemonade.html), run it, and balance it with the calculator above.
6 · Art guide: what you need to draw
The Lab uses emoji (🍋 ☀️ 🌧️) as stand-ins so the game works on day one. A finished game replaces them with your own art. Make a list before you open a drawing tool. Draw every Must first (the game can ship with only those), then Should, then Bonus.
Title screen Must
1 picture · The game name and your shop. Leave a quiet area for the Start button.
The shop Must
1 picture, plus 1 per upgrade · The main screen. Draw it so each upgrade (sign, cooler, second printer) visibly appears.
Product Must
1 sprite · The thing you sell, with a transparent background so it works on any scene.
Day icons Must
1 per kind of day · Sun, rain, rush. They must be readable at half size, because they sit beside the forecast.
Ending screens Must
3 pictures · Win, went broke, and season ended short. Each should make the player want one more try.
Customers Should
3 to 5 sprites · Different people lining up. A crowd that grows with demand shows the formula working.
Event cards Should
1 per event · A small illustration for the fair, the inspector or the broken printer.
Cash chart skin Bonus
1 picture · A background for your own line graph of cash by day.
- Pick a palette first. Five to eight colours written down as hex codes, and every picture uses only those. This does the most to make student art look like one game.
- One style, one viewpoint. Pixel art, flat shapes or ink: pick one. Keep the counter and the horizon at the same height in every scene.
- Draw big, show small. Check each icon at half size. If you can't tell what it is, simplify it.
- Only your own art. If you use something you didn't make, write down who made it and the license.
- Always write the
alton each<img>: one short sentence about what it shows.
Put each picture's file name in the data next to the thing it shows (art: "art/sign.png" on an upgrade, icon: "art/rain.png" on a weather type), so the logic stays untouched. The Lab still draws emoji; it doesn't read these art fields. Where to draw: Web Studio Draw mode, or Pixel Art & Sprites.
7 · Challenges
Pick one or two. They get harder as you go down the list.
- Show the history. Keep an array of each day's cash and draw it as a line graph on a
<canvas>. Which day did you turn a corner? - Recipe slider. Add a quality choice with three levels. Each level changes both
costandtopPrice. Where does the best price land now? - A loan. At the start, offer $30 that you repay at 10% per day. Work out on paper whether it ever pays off.
- Leftovers. Let unsold stock carry over, with 30% spoiling each night. How does that change how many you make?
- A rival. A computer stand with its own price takes customers from you: the cheaper stand gets more of the crowd. What's your best response, and does the game have a stable price?
- Save and resume. Put the state in
localStorageso a closed tab doesn't end the season. The Menus, Saving & Shipping lesson explains how.
8 · Where it came from, and designing with care
Lemonade Stand is one of the oldest educational computer games. A version was written in the 1970s on a school time-sharing system and later spread on the Apple II through the Minnesota Educational Computing Consortium, the same group that made The Oregon Trail famous in school computer labs. Both games are small and text-heavy, and both have a whole economy or survival model inside them. You can build either one yourself after one lesson.
Economics in a game is also a place to think about who gets hurt by a number. When you design a business game:
- Price gouging. In this model a heat wave or a storm raises demand, so the "best" price goes up exactly when people are most desperate. In real life many places ban that after disasters. Does your game reward it, punish it, or just describe it? Decide on purpose.
- Fair rewards. If a timer, a streak or a "buy now" button pushes players to keep coming back or spend real money, ask whether it respects them. A school game should never ask for real money.
- Real businesses. If your spin-off sells something real (food, medicine, services), check that your prices and costs are believable, and say where you found them.
- Real lemonade stands. In some places a child needs a permit or a parent's permission to sell food. The game is a model. Check the rules before you start a real stand.
9 · Show what you built
Hand in your lemonade.html (or the file from the Lab) and a design sheet. Your teacher will look for:
| Criterion | Meets the goal when… |
|---|---|
| It works | You can start it, play it, and reach all three endings without errors. |
| Data-driven | Prices, weather, events and upgrades live in one data object, and the logic doesn't hard-code them. |
| Real choices | At least two decisions where both options have a cost (price, stock, upgrade timing). |
| Balanced with math | You worked out the best price on paper, checked it against the game, and playtested; a careful player can win and a careless one can lose. |
| A twist | One rule or mechanic that makes it more than a re-skin. |
| Designed with care | Events are original, numbers are believable, and nothing pushes players to feel tricked. |
Next: plan your whole build in Game Jam Week, build the other classic of the genre in Trail Game Builder, or add real art and animation with the 2D Game Developer Pathway.