Every game on AIgames123 started as a prompt.
A real-time trading game where you buy and sell SpaceX shares as the
(fictional) stock swings through market phases, breaking-news events,
and hype cycles. Built as a single self-contained HTML file using
Chart.js for the live price chart and the Web Audio API for sound.
single-file HTML
Chart.js
Web Audio API
simulation
Build a complete single-file HTML stock trading game called "SpaceX IPO". Everything (HTML, CSS, JS) must be in ONE .html file with no external files except the Chart.js CDN.
Core mechanics:
- The player starts with $10,000 cash and 0 shares.
- There is one fictional stock: SpaceX (ticker SPCX), starting at $50.
- A live line chart (Chart.js) shows the last 60 price ticks, updating once per second.
- Each tick, the price moves by a random walk: newPrice = price * (1 + drift + volatility * randomNormal()). Make drift and volatility change depending on the current "market phase" (see below).
- Buy and Sell buttons trade 1, 10, or "Max" shares at the current price. Show the player's cash, shares held, and total net worth (cash + shares*price) updating live.
Market phases (cycle through these, each lasting 20-40 ticks):
- Accumulation (low volatility, slight up drift)
- Bull run (high up drift)
- Euphoria (very high volatility, prices spike)
- Correction (sharp down drift)
- Recovery (returns toward normal)
Show the current phase name on screen.
Win/lose: there's no hard end โ it's an endless sandbox. Track and display the player's all-time peak net worth.
Use a clean dark UI. Make the buy button green, sell button red. Keep all code in one file. Comment the tunable constants (starting cash, base volatility, tick rate) at the top in a CONFIG object so they're easy to adjust.
Why this works: Being explicit about "ONE file, no
external files except the CDN" prevents the model from splitting code
across files you can't host. Spelling out the exact price formula and
listing the phases by name gives reproducible, debuggable behavior
instead of vague "make it realistic."
I have a single-file HTML stock trading game ("SpaceX IPO"). I want to add a random "breaking news" event system that nudges the price. Give me a self-contained JavaScript module I can paste into the existing file.
Requirements:
- Every 15-30 ticks (randomized), trigger one news event.
- Each event has: a headline string, and a price multiplier applied over the next few ticks (e.g. +18%, -25%).
- Mix of positive and negative events themed around a space company, e.g.:
- "Starship test flight nails the landing!" (big positive)
- "FAA grounds launches pending review" (negative)
- "New Starlink contract signed" (moderate positive)
- "Investor sells large stake" (moderate negative)
- "Mars colony teaser goes viral" (hype spike then partial reversal)
- Show the headline as a toast/banner at the top for ~4 seconds when it fires.
- Make sure events feel balanced over a long session โ roughly net-neutral, so the game isn't trivially easy or impossible.
Return only the JS, with a clear function I can call from my existing game loop like maybeTriggerNews(currentTick).
Why this works: Asking for "a module I can paste into
the existing file" with a named entry point (maybeTriggerNews())
keeps new code from clashing with what ChatGPT already built. Listing
example headlines steers tone; asking for "net-neutral over a long
session" is a concrete balancing constraint the model can reason about.
Here's my single-file SpaceX IPO trading game (pasted below). It works but feels flat. Help me polish it without breaking anything:
1. Add sound using the Web Audio API only (no audio files) โ a short "blip" on buy, a lower tone on sell, and a quick rising arpeggio when net worth hits a new all-time high. Keep it subtle and let the player mute it.
2. Add small achievements that pop as toasts: first trade, first $100k net worth, survive a full Correction phase without selling, etc. Track them in localStorage so they persist.
3. Add juice: animate the net-worth number when it changes (count up/down), flash the price green/red on each tick depending on direction, and add a subtle screen shake on big news events.
4. Review the trading logic for bugs โ especially: can the player buy with money they don't have? Can shares or cash go negative? Does "Max" buy round correctly?
Please keep everything in the single HTML file, preserve the existing CONFIG object, and explain what you changed and why. Show me the full updated file.
Why this works: Pasting the existing code and saying
"without breaking anything" plus "preserve the CONFIG object" anchors
the changes to what already exists. Numbered, specific asks (Web Audio
only, persist in localStorage) are easy to verify, and explicitly
asking it to review for bugs โ like negative balances โ turns
the model into a code reviewer, not just a generator.
๐ก The pattern: Notice the division of labor โ one tool
scaffolds the core loop, another adds a self-contained feature, a third
polishes and hunts bugs. You don't have to use three tools, but breaking
a game into "core โ features โ polish" prompts tends to produce cleaner
results than asking for everything at once. Built something with these?
Upload your game โ