How to make a vertical scrolling shooter game
Step 1 — Download the companion guide and share it with Gemini
Download this Markdown file to your computer. It is tailor-made for Google Gemini, which you can use free with a Google account.
- Open Gemini in your browser and sign in with a free Google account.
- Use its attachment or upload control to attach
share-with-gemini.mdfrom your Downloads folder. - Copy the message below, paste it into Gemini with the attachment, and send it. Ask for clarification whenever you need it.
Starter message for Gemini
Please read the attached share-with-gemini.md guide and walk me through building the game step by step. Explain each step for a beginner, wait for me to finish it, and help me troubleshoot before moving on. What you will build
Build a portrait, vertical-scrolling browser shooter inspired by the mechanics of the arcade game 1942, but with your own spaceships, title, art, and sounds. It has eight stages, two bosses, power-ups, sound effects, touch controls, and a saved high score. Do not copy the original game's art, music, or name.
The free tools
Use VS Code, a free GitHub account and Copilot Free for coding; Gemini with a free Google account for optional image generation; Photopea or Piskel for image editing; jsfxr for sound; and Live Server for testing. Publish free on itch.io or GitHub Pages. Piskel and Kenney are alternatives if you do not want AI-generated art. Free-tier limits and interfaces can change, so check the linked providers for current details.
Lock the v1 plan
- Use plain JavaScript and HTML5 Canvas: no framework, build step, or music. Draw at 480 × 640 pixels and scale to the screen.
- Build eight sectors in order: Sirius, Vega, Rigel, Betelgeuse, Antares, Polaris, Altair, and Deneb. Bosses appear at the end of stages 4 and 8; stage 8 is the last stage.
- Start with three lives; award extra lives at 50,000 and 150,000 points. Build with geometric placeholders first, then swap in your own sprites.
- Keep the sound library local, use relative file paths, and publish to itch.io or GitHub Pages.
Set up VS Code and your project
- Create a folder: On Windows, open File Explorer, go to Desktop or Documents, right-click an empty area, choose New → Folder, and name it
space-shooter. On a Mac, open Finder, go to Desktop or Documents, choose File → New Folder, and name itspace-shooter. - Open the folder: In VS Code, choose File → Open Folder, select
space-shooter, and confirm any trust prompt only if you trust the folder. On macOS, use the same menu and select Open. - Open Extensions: Click the Extensions icon in the sidebar, or press Ctrl+Shift+X on Windows/Linux or Cmd+Shift+X on Mac.
- Install Live Server: Search for Live Server, select the extension by Ritwick Dey (30M+ installs), and click Install.
- Install Copilot: In the same Extensions view, install GitHub Copilot and GitHub Copilot Chat. Sign in to a free GitHub account when VS Code prompts you; no credit card is required for Copilot Free. Create an account at GitHub if needed.
- Open Agent mode: Open Copilot Chat with Ctrl+Alt+I on Windows/Linux or Cmd+Option+I on Mac, or use the chat icon. Select Agent in the chat mode dropdown. If it is missing, check that Copilot is installed and you are signed in; consult the VS Code Copilot setup guide if the interface has changed.
Copilot Free includes 2,000 code completions and 50 chat/agent requests per month. An agent task may consume more than one request. Save requests for the four prompts and troubleshooting; check the current plan limits if they change. If you run out, continue by hand or wait for the allowance to reset.
Run and stop the game locally
After the first prompt creates index.html, find it in VS Code's Explorer, right-click it (on Mac, Control-click also works), and choose Open with Live Server. The browser opens a local address, usually http://127.0.0.1:5500/. Save edits to reload the page. To stop the server, click Port: 5500 in VS Code's bottom-right status bar; the port number may differ if 5500 is busy.
Project files and relative paths
The first prompt creates the first three files. Add sfxr.js during the sound phase and your images at the sprite handoff.
space-shooter/
index.html
game.js
stages.js
sfxr.js
assets/
sprites/
player-ship.png
enemy-fighter.png
enemy-weaver.png
enemy-kamikaze.png
enemy-gunship.png
boss-capital-ship.png
power-core.png
background-starfield-far.png
background-starfield-near.png index.html contains the canvas, responsive CSS, and script tags. game.js handles the loop, rendering, physics, collisions, and HUD; stages.js holds the eight timelines in STAGES. Once sound is added, load sfxr.js first, then stages.js, then game.js, using ordinary script tags.
Use paths relative to the game folder, such as assets/sprites/player-ship.png, not /assets/sprites/player-ship.png. A leading slash points at the website root and breaks games hosted in a subfolder. Match capitalization exactly, including on Windows and macOS.
How the game works
Game loop, player, and background
requestAnimationFrame repeatedly updates and draws the game. Use delta time (seconds since the last frame), capped at 0.05 seconds so switching tabs does not cause a huge jump. Move the player with WASD or arrows, clamp it to the canvas, and aim for 260 pixels per second. Space or Z fires. Give the ship a small circular hitbox so it feels fair.
With X or Shift, a barrel roll gives roughly 0.9 seconds of invincibility; the ship spins and cannot fire during the roll. Give three rolls per life. Scroll two layers of procedural stars downward and wrap them; the nearer layer moves faster. After the sprite swap, draw each starfield image twice to wrap it, and draw the near layer with ctx.globalCompositeOperation = 'screen' or 'lighter', or use a transparent near layer. Restore the normal composite mode afterward.
Enemies and scripted waves
Instead of random spawns, each stage timeline in stages.js lists [time, enemyType, x, pattern]. Fighters fly down and fire aimed shots; weavers follow a sine wave; kamikazes dive toward the player's position; and gunships move slowly, take 8–10 hits, and fire three-way spreads. Stage 1 starts with fighters, stage 2 adds weavers, stage 3 adds kamikazes, and stage 4 adds gunships. Increase speed, fire rate, and health gradually.
Crimson squadrons contain five or ten ships. Destroy the entire formation to drop a power core and award a formation bonus: 500 for five ships or 1,000 for ten.
Bullets, collisions, and power cores
Keep separate lists for fast upward player shots and slower aimed or spread enemy shots. Reuse bullet objects with pooling and cap enemy bullets at roughly 60–80. Use circle-distance collision checks for bullets and ships, ship-to-ship collisions, and pickups. Contact between a player and an enemy destroys both.
- Green: upgrade from two guns to four. Gray: add two wingman drones.
- White: clear enemies on screen. Orange: temporarily stop enemy fire.
- Yellow: add a roll. Black: add a life. Red: add 1,000 points.
On death, remove weapon upgrades and wingmen. Keep the player hitbox smaller than the visible ship.
Bosses, score, and touch
At the end of stages 4 and 8, a capital ship enters from above, hovers, displays a health bar, and cycles aimed bursts, fan spreads, and sweeping fire. Award 30,000 and 50,000 points respectively. After each stage, tally shoot-down percentage (100% earns 50,000 points) and 1,000 per unused roll. Winning the last stage adds 10,000,000 points and shows a final score and restart.
Place score top-left, high score top-center, lives top-right, rolls bottom-left, and stage bottom-right. Save the high score in localStorage; provide a title screen, P/Escape pause, game-over screen, and restart. For touch, drag relative to finger movement, enable autofire, and add an on-screen roll button. Set touch-action: none on the canvas so it does not scroll the page during play.
Build in six phases
- Skeleton: Create the canvas, loop, procedural starfield, moving and firing placeholder player, and one enemy. Finish when you can fly and shoot.
- Combat: Add enemy bullets, collision, explosions, score, lives, game over, and restart. Finish when a short game loop works.
- Shooter identity: Add stage timelines, crimson squadrons, power cores, upgrades, wingmen, and barrel rolls. Finish when the game has its arcade identity.
- Campaign: Add all eight stages, both bosses, stage intros, bonus tallies, and the difficulty ramp. Finish when a full playthrough works.
- Polish: Add local sound, title screen, touch controls, saved high score, and pause. Test on a phone.
- Ship: Publish on itch.io or GitHub Pages and test the public link.
Sprite handoff between phases 2 and 3: Once movement, firing, roll, hitboxes, and collision feel right, prepare the PNGs below. Replace shape drawing with drawImage at the same sizes and hitboxes, and replace procedural dots with the two starfield layers. Check that the game still plays the same. The first prompt already requests a roll; if it is not ready yet, add and test it before the handoff.
Four ready-to-paste Copilot Agent prompts
With the space-shooter folder open, switch Copilot Chat to Agent. Copy one prompt at a time, paste it into the chat, and send it. Review and accept the proposed changes, then run and test the game with Live Server before continuing. Describe any error to Copilot or Gemini. The prompts are a starting point: compare each result with the phase checklist and add any missing features.
Prompt 1 — Scaffold
In the open space-shooter folder in VS Code, create a vertical scrolling space shooter game, plain JavaScript and HTML5 Canvas, no frameworks, no build step. Three files: index.html, game.js (core engine, game loop, rendering, physics, HUD), and stages.js (the 8 scripted stage timelines as a STAGES array). Load them in index.html with standard script tags, stages.js before game.js. 480x640 portrait canvas. CSS scales the canvas cleanly on desktop and mobile: aspect-ratio: 3 / 4, centered on the page, sized to fit the viewport height and width, and touch-action: none on the canvas so touch controls won't scroll or zoom the page. Use crisp geometric placeholder shapes first: an orange triangle for the player ship, a green triangle for the enemy, rectangles for bullets, and a procedural two-layer dot starfield drawn in code (far layer small dim dots, near layer larger bright dots, near layer faster, both wrapping). No image files in Phase 1 — sprites come later. When the starfield image layers replace the procedural dots later, draw the near layer with ctx.globalCompositeOperation = 'screen' (or 'lighter') — or give it a transparent background — so its dark background drops out and doesn't cover the far layer. Player spaceship moves with arrow keys/WASD, fires with Space, barrel roll with X (0.9s invincibility, 3 per life, can't shoot during roll). One alien enemy type that flies down and shoots aimed bullets. Circle collision, score, 3 lives, game over screen with restart. Use requestAnimationFrame with delta time and object pooling for bullets. Prompt 2 — Waves
Add a wave system to this game: 8 stages, each a timeline array of [time, enemyType, x, pattern]. Put the 8 stage timelines in stages.js as a STAGES array (one entry per sector: Sirius, Vega, Rigel, Betelgeuse, Antares, Polaris, Altair, Deneb), and have game.js read the current stage's timeline from it. Add enemy types fighter, weaver (sine path), kamikaze (dives at player), gunship (slow, 10 HP, 3-way spread). Add crimson squadrons of 5 ships: destroying all 5 drops a power core pickup. Power core types: green weapon upgrade (2 to 4 guns), gray wingman drones (two escorts), white screen clear, orange no enemy fire (enemies can't shoot for a time), yellow extra barrel roll, black extra life, red 1000 points. Prompt 3 — Boss
Add a boss fight at the end of stages 4 and 8: a large alien capital ship that enters from the top, hovers, has a health bar, and cycles three attack patterns (aimed bursts, fan spread, sweeping fire). Defeating the boss shows a stage-clear bonus screen (shoot-down percentage and unused barrel rolls) then starts the next stage. Beating the stage 8 boss shows the game-won screen. Prompt 4 — Polish
Add Web Audio sound effects using the jsfxr library for shoot, explosion, power-up, and barrel roll sounds. Download the jsfxr library file sfxr.js from https://sfxr.me/sfxr.js into the game folder and load it with a local script tag in index.html (before game.js). Generate presets with sfxr.generate and play them using sfxr.toWebAudio with an AudioContext; do not use sfxr.play, which requires the separate RIFFWAVE library. Unlock audio on the first user interaction. No CDN, no audio files — all sounds generated in code. Add a title screen, pause with P, high score saved in localStorage, and touch controls: drag to move, autofire on touch devices, on-screen barrel roll button. Make and prepare sprites
Use Gemini with a free Google account, or choose a no-AI alternative below. Free image-generation availability and limits can change. Generate only the sprites needed for the next phase; start with the player, fighter, and starfield layers. Reuse a finished image as a reference where available to keep the style consistent.
For ships, reuse this base description: top-down 2D game sprite, pixel art style, single ship centered, plain solid magenta (#FF00FF) background, no shadows, no text
. Ask for an orange-and-cyan player fighter facing up; green-and-purple fighter, purple curved-wing weaver, red-and-black spike kamikaze, green armored gunship, and green-and-purple capital ship facing down. For the power core, request a single glowing hexagonal energy cell instead of a ship. For the backgrounds, request seamless pixel-art starfield tiles: dim stars and faint nebula for the far layer, bright stars on black for the near layer, without ships or text.
| Sprite | Filename | Size |
|---|---|---|
| Player | player-ship.png | 48 × 48 |
| Fighter | enemy-fighter.png | 40 × 40 |
| Weaver | enemy-weaver.png | 40 × 40 |
| Kamikaze | enemy-kamikaze.png | 36 × 36 |
| Gunship | enemy-gunship.png | 64 × 48 |
| Boss | boss-capital-ship.png | 160 × 120 |
| Power core | power-core.png | 28 × 28 |
| Far starfield | background-starfield-far.png | 480 × 480 tile |
| Near starfield | background-starfield-near.png | 480 × 480 tile |
Draw bullets in code: player bullets 8 × 16 and enemy bullets 6 × 6. Ask for large images (about 512 pixels for sprites and 1024 for backgrounds), then resize them; the generator may choose its own output dimensions.
- Open each downloaded image in Photopea. For ships and the power core, choose Select → Color Range, select the magenta, confirm, and delete it. Unlock the layer first if needed. Magenta avoids removing green parts of alien ships.
- Choose Image → Image Size, enter the table dimensions, and select nearest-neighbor resampling for crisp pixels. If needed, unlink the dimensions to enter both values. Export as PNG to preserve transparency, not JPG.
- In VS Code Explorer, create
assetsinside the project, thenspritesinsideassets. On Windows or Mac, right-click the parent folder and choose New Folder. Copy the PNGs there and check their names and capitalization. - Replace placeholders with the images and test again. Keep the near starfield from covering the far layer using the blend or transparency described above.
No AI? Draw your own pixel-art ships and export PNGs with Piskel, or use suitable Kenney assets and check each pack's license. Rename and size files to match your code. Keep one consistent art style.
Set up sound with jsfxr
- Open sfxr.js in your browser. Save the page as
sfxr.jsin thespace-shooterfolder: use Ctrl+S on Windows/Linux or Cmd+S on Mac. Make sure it is not saved with an extra.txtextension. - In
index.html, load it locally before the other scripts, then loadstages.jsandgame.jsin that order. Do not use a CDN or separate audio files.
<script src="sfxr.js"></script>
<script src="stages.js"></script>
<script src="game.js"></script> Use jsfxr presets such as laserShoot, explosion, powerUp, hitHurt, and pickupCoin for shooting, explosions, pickups, hits, and the stage-clear jingle; use a short noise sweep for the roll. Use sfxr.generate and sfxr.toWebAudio with an AudioContext; sfxr.play depends on a separate RIFFWAVE library and is not needed for this local-only setup. Browsers block sound until a click or keypress, so initialize or resume audio after the first interaction. There is no music in v1. The library's filename is sfxr.js, not jsfxr.js.
Publish your game
Choose either free option. Test locally first, and keep index.html and all game assets together with relative paths.
Option A: itch.io
- Create a free itch.io account and choose Upload new project. Enter a title and description, choose a Games/HTML project, and select No payments.
- Make a ZIP of the contents of the game folder, not the enclosing folder. On Windows, open the folder in File Explorer, press Ctrl+A, right-click, and choose Compress to ZIP file (or Send to → Compressed (zipped) folder; Windows 11 may show it under Show more options). On Mac, open the folder in Finder, press Cmd+A, Control-click the selected items, and choose Compress.
- Open the ZIP and confirm
index.html, both JavaScript files,sfxr.js, andassetsare at its top level. If they are inside anotherspace-shooterfolder, recreate the ZIP from the contents. - Upload the ZIP and check This file will be played in the browser. Choose an embedded 480 × 640 viewport, enable fullscreen and mobile support, and use click-to-play so the first click can unlock audio. Set portrait orientation if offered.
- Save as a draft, open the page and test the embedded game, then make it public. To update, upload the new ZIP, mark it playable, and remove the old upload.
Some browsers restrict storage in embedded games, so a saved high score may not persist on itch.io. A missing asset can show as a 403 rather than a 404; check filenames and paths.
Option B: GitHub Pages
- Sign in to GitHub and create a public repository, for example
space-shooter. Add a README if you like. - On the repository page, choose Add file → Upload files. Open your local
space-shooterfolder in File Explorer (Windows) or Finder (Mac), select its contents with Ctrl+A or Cmd+A, and drag those contents into the upload area. Preserve theassets/spritesfolders. Confirmindex.htmlis at the repository root, not inside another folder, then commit the files using the page's Commit changes button. - Optionally create an empty
.nojekyllfile at the repository root via Add file → Create new file to prevent Jekyll from skipping future files whose names start with an underscore. - Under Settings → Pages, choose Deploy from a branch, branch main, folder / (root), and save. Wait for the deployment, then open the Pages URL shown in settings, usually
https://<username>.github.io/<repository>/. - For updates, upload changed files and commit them again. If you see an old version, hard-refresh with Ctrl+F5 on Windows or Cmd+Shift+R on Mac. GitHub Desktop is an optional tool for repeat updates.
What to leave for later
Finish the playable v1 before exploring music, local image-generation setups such as ComfyUI, 3D models in Blender, or a framework such as Phaser. They are possible later, but none is required for this guide.
Troubleshooting and common mistakes
- Blank page or missing images: Run with Live Server instead of double-clicking the HTML file. Check the browser console, exact filename capitalization, and relative paths. On Windows use F12; on Mac use Cmd+Option+I, then select Console.
- Colored boxes around sprites: Remove the magenta in Photopea and export transparent PNGs, not JPEGs.
- No sound: Click the game or press a key first. Confirm the local file is named
sfxr.jsand loads beforegame.js. Leave click-to-play enabled on itch.io. - Bad phone sizing or scrolling: Check the canvas has
aspect-ratio: 3 / 4, fits the viewport, and usestouch-action: none. - Copilot requests exhausted: Check your remaining allowance and reset date; continue manually or resume after it resets. Inline completions have a separate allowance.
- itch.io will not load: Inspect the ZIP for root-level
index.html, correct case, and relative paths. Check the browser console for missing files, including 403 responses. - GitHub Pages returns 404: Allow time for deployment; check the repository's Actions and Pages settings. Verify
index.htmlis at the root and paths use the correct case. - High score disappears on itch.io: Browser restrictions on embedded storage can prevent it from persisting; gameplay can still work.
Avoid starting with a framework or generating a huge sprite set before the placeholder game works. Avoid random waves, oversized player hitboxes, unbounded new bullets, starting audio before interaction, root-relative paths, and copying other games' artwork.