The Combat Loop Prototype
Last reviewed
IntermediateWhat you'll learn
~60 min- Ask an AI tool in plan mode to build a playable Phaser 3 combat prototype
- Implement player melee combat with blade combos and dodge roll i-frames
- Build enemy AI with hitbox detection, health tracking, and death state
- Add health bars, hit feedback effects, and a blood rage meter
What you’re building
This is the one. Everything before this lesson was research, planning, and business strategy. Right now you are building the first thing someone can actually play. A BloodRayne-inspired combat room — side-scrolling, fast, violent — running in your browser. Thirty minutes from now you will be slashing through an enemy with blade combos, dodging attacks with i-frames, watching health bars drain, and filling a blood rage meter that rewards aggression. All built with your AI tool through a short plan-mode conversation.
Rayne never waited around. Neither should you.
Every game studio pitch starts with a playable prototype. Not a slide deck. Not a design document. A thing someone can pick up and feel. When you show investors, collaborators, or a publisher what “BloodRayne remake” means, you open a browser tab and hand them the keyboard. This lesson builds that artifact. It is rough, it uses placeholder art, and the animation is basic — but the combat loop is real, and that is what matters.
The game runs entirely in the browser using Phaser 3. No Unity install, no Godot download, no compiled binaries. You edit code, refresh the browser, and see the result. That tight feedback loop is exactly why Phaser is the right engine for prototyping with AI CLI tools — the AI writes JavaScript, you open index.html, and you are playing.
Every action game is a loop: read input, update state, render frame. The combat prototype adds layered state — player state (idle, attacking, dodging, hurt), enemy state (idle, patrol, attacking, dying), and global state (health, rage meter). This state machine pattern applies to any interactive system, not just games.
The showcase
Here is what you will have when the AI finishes building:
- Player character with idle, run, attack, dodge, and hurt animations (colored rectangles for now — art comes later)
- Blade combo system — press Z up to three times for a light-light-heavy chain, each hit with different damage and knockback
- Dodge roll on X with invincibility frames — 0.3 seconds where you pass through enemy attacks untouched
- Enemy that patrols, chases when you get close, attacks on a cooldown, and has a health bar that drains
- Player health bar at the top left, enemy health bar above the enemy sprite
- Hit feedback — screen flashes red on player damage, enemy flashes white on hit, knockback on both
- Blood rage meter that fills with every successful hit, displayed as a red bar below the health bar
- Keyboard controls — arrow keys to move, Z to attack, X to dodge
Everything runs from a single index.html file that loads Phaser 3.90.0 from a CDN. No bundler and no npm install for this one. Open the file in your browser and play.
Before you start
If your AI tool is open from an earlier lesson, leave it (/exit, or Ctrl+D in Antigravity) so you are at your terminal prompt. Create a folder for this prototype and go into it:
mkdir -p ~/retro-remake/10-combat-loop-prototype && cd ~/retro-remake/10-combat-loop-prototypeIn Windows PowerShell:
mkdir ~/retro-remake/10-combat-loop-prototype; cd ~/retro-remake/10-combat-loop-prototypeIf you use a desktop agent app, open ~/retro-remake/10-combat-loop-prototype as your workspace folder. Then start your AI tool the way Workbench Setup showed.
Switch to plan mode
Switch your session into Plan mode (Shift+Tab, /plan, or the mode picker) so the agent asks about controls, feel, and combat rules before writing code.
The conversation
Each message below is an example. Use your own wording.
Say what you want
Ask for a playable browser combat room inspired by BloodRayne:
I want to build a playable 2D side-scrolling BloodRayne combat prototype that runs directly in my browser from a single index.html file. Ask me what you need first.Answer its questions
Your agent will ask about controls, combo timing, dodge invincibility, enemy behavior, and the blood rage meter. Answer each question in a short sentence:
| If it asks | You might say |
|---|---|
| What controls and movement should the player have? | Arrow keys to run and jump, Z for a three-hit blade combo, and X to dodge roll. |
| How should the blade combo and dodge roll work? | Hits deal 10, 15, and 25 damage within a 500ms window; dodge gives 300ms of i-frames. |
| What should the enemy do? | Patrol, chase within 250px, telegraph for 300ms before a 20-damage melee strike, and respawn after dying. |
| How does the blood rage meter work? | Fills 8% per hit, drains slowly, and at 100% doubles player damage for 5 seconds. |
| What visual style and hit feedback should it use? | Use a standard 2D browser game setup with colored rectangles, hit flash, knockback, blood particles, and screen shake. |
Read the plan
Before approving the plan, verify these five details:
- Single-file browser setup: loads
phaser@3.90.0from CDN inside oneindex.htmlfile with an 800x450 Arcade Physics canvas and colored rectangle graphics (no external image assets). - Three-hit combo chain: Z chains Hit 1 (10 damage, 200ms), Hit 2 (15 damage, 250ms), and Hit 3 (25 damage, 400ms) with a 500ms continuation window and a visible attack hitbox in front of Rayne.
- Dodge roll with real i-frames: X dashes 150px over 300ms with an 800ms cooldown, disabling enemy attack damage while dodging and leaving a brief afterimage.
- Enemy state machine and telegraph: the 100 HP soldier moves through
IDLE,PATROL,CHASE(within 250px),ATTACK(300ms yellow flash telegraph, 20 damage, 1.5s cooldown),HURT, andDEAD(respawning after 3 seconds). - HUD and blood rage: top-left player health bar and blood rage meter (fills 8% per hit, drains 2%/s idle, doubles damage for 5s at 100%), floating enemy health bar, hit-stop on death, and control hints at the bottom.
If the plan forgets the attack telegraph or the combo reset window, correct it in plain English:
Make the enemy flash yellow for 300ms before dealing damage so I can time the dodge, and reset the combo if 500ms pass between swings.When the plan covers all five items, approve it and let your agent build index.html. Once you verify it in the browser, ask your agent to save a Git checkpoint.
Every number in your plan (200px/s run speed, 500ms combo window, 300ms dodge duration) is a starting value you can adjust by feel after playing a round.
What you get
After the AI finishes (usually a few minutes), your project folder structure looks like this:
10-combat-loop-prototype/ index.htmlThat is the entire game. One file. Open it in your browser.
Play it
Ask your agent to open or serve the combat prototype in your browser:
Open index.html in my browser, or start a local preview server and give me the link so I can play the combat prototype.If you prefer to open it yourself from a terminal:
cd ~/retro-remake/10-combat-loop-prototype# Option 1: Just open the file directlyopen index.html # macOSxdg-open index.html # Linuxexplorer.exe . # Windows (WSL): then double-click index.html
# Option 2: If you need a local server (some browsers block local file access)npx serve .Arrow keys to move. Z to attack — hit it three times fast for the full combo chain. X to dodge through the enemy’s attacks. Watch the health bars. Fill the blood rage meter and feel the damage double.
You are playing a game that did not exist before you started this session.
If something is off
These are the most common issues and the follow-up prompts that fix them:
| Problem | Follow-up prompt |
|---|---|
| Player falls through the floor | Rayne falls straight through the floor when the game starts. Make the ground platform solid so both Rayne and the enemy land and walk on it cleanly. |
| Combo doesn’t chain — each Z press is hit 1 | Every time I press Z it repeats the first light slash. Make pressing Z within 500ms advance from Hit 1 (10 damage) to Hit 2 (15 damage) to Hit 3 (25 damage), and reset only if I wait too long. |
| Dodge roll doesn’t grant invincibility | I still take damage when I dodge through an enemy swing. Make Rayne completely immune to enemy attacks for the full 300ms dodge roll. |
| Enemy doesn’t chase the player | The soldier keeps pacing back and forth and never chases me. Have the enemy switch from patrol to chasing me at 120px/s whenever I get within 250px. |
| Health bars don’t update | The player and enemy health bars stay full even when hits land. Redraw both health bars and the blood rage meter every time damage is dealt or rage fills. |
Deep dive
You have a playable prototype. Here is what is happening under the hood and why each system matters.
The combo system is a state machine
The three-hit chain is not three separate attacks — it is a single system with a timer. When you press Z, the game checks: are we inside the combo window? If yes, advance to the next hit (slash, cross-slash, cleave). If the window expired, start over at hit 1. This is the same pattern every action game uses, from Devil May Cry to Hades. The combo window duration (500ms by default) is the first thing you will want to tune — too short and the combo feels impossible, too long and it feels sluggish.
I-frames make dodge feel fair
Invincibility frames during the dodge roll are not a cheat — they are a core design mechanic. Without i-frames, dodging through an attack still deals damage, which makes the dodge feel useless. With i-frames, the player is rewarded for timing their dodge correctly. The 300ms duration and 800ms cooldown create a risk-reward decision: dodge at the right moment and you are untouchable, spam it and you are stuck in cooldown when the next attack comes.
Blood rage rewards aggression
BloodRayne was never a defensive game. Rayne charged in, slashed through enemies, and fed on them to heal. The blood rage meter captures that identity mechanically — stay aggressive and you get rewarded with doubled damage. The drain-over-time (2% per second) means you cannot build rage and then play safe. You have to stay in the fight. This is a design statement: this game rewards the player who pushes forward.
Hit feedback is not optional
The screen flash, knockback, particle burst, and hit-stop on death are not polish — they are communication. Without feedback, the player does not know whether their attack connected. With feedback, every hit feels impactful. Game developers call this “juice” and it is the single biggest difference between a prototype that feels like a tech demo and one that feels like a game.
🔍Why Phaser 3 for a BloodRayne prototypeclick to expand
Phaser 3 runs in the browser. That means: no compile step, no engine install, instant iteration. The AI CLI writes JavaScript, you refresh the page, and you are playing. For a prototype whose purpose is to prove the combat loop feels right, this speed matters more than graphical fidelity. When you are ready for production-quality art and performance, you can port the proven design to Unity, Godot, or Unreal. But you prove the design here, in the browser, where iteration is measured in seconds, not minutes.
Customize it
You have a working combat room. Now make it yours, one message at a time.
Add a second enemy type
Keep the melee soldier and add a 60 HP purple ranged enemy that stays 200 to 300px away, retreats if I get close, and fires a 15-damage yellow projectile every 2 seconds.Add a health drain on blood rage activation
When blood rage activates at 100%, heal Rayne for 2 HP per second across the 5-second duration and float a small green +2 label above her on each tick.Add a combo finisher
If I land all 3 combo hits and press Z again within 300ms, trigger a 40-damage arc finisher with a 150px radius, a 100ms hit-stop, gold FINISHER text, and a 3-second cooldown.Try it yourself
- Walk through the plan-mode conversation above to build the prototype.
- Open
index.htmlin your browser and play through a full enemy encounter. - Pay attention to what feels wrong — is the combo window too tight? Is the enemy too aggressive? Is the dodge distance too short? Write down three things you would change.
- Pick one of those three things and write a follow-up prompt to fix it. Be specific about the values you want (exact pixels, exact milliseconds).
- Try one of the customization prompts above.
- Kill the enemy five times in a row using only combos. If you can do it without dodging, the enemy is too passive — adjust its aggression with a follow-up prompt.
This is the loop for the rest of the game-building lessons: generate, play, feel, adjust. The AI writes the code. You make the design decisions. Rayne would approve.
Seriously. You just built a playable combat prototype in your browser from a text prompt. Not a mockup, not a wireframe — a thing with controls, health bars, and a combo system. Every game that ever shipped started as something rougher than this. You are building a BloodRayne remake and you have combat. Next you return to the business side with the Storefront Revenue Simulator. When you come back to building, the Movement and Camera Feel Lab adds the physics that make running, jumping and dashing feel as fluid as the original.