I'll create a premium survivor.io-style game with custom sprites, smooth gameplay, and polished visuals. Let me start by exploring the project structure.
Now I'll plan the game. This will be a premium survivor.io clone with:
- Canvas-based rendering with custom pixel-art sprites (drawn programmatically)
- WASD/Joystick movement
- Auto-attacking weapons with projectiles
- Wave-based enemy spawning with bosses
- XP/Level-up system with upgrade choices
- Beautiful HUD with health bar, XP bar, timer, kill count
- Particle effects, screen shake, damage numbers
- Game over / start screens with premium feel
- Minimap, chest drops, magnet pickups
Let me create the files. I'll split into multiple files for organization.
Now let me create the main game files. I'll start with the sprite drawing system, then the game logic, then the UI.
TypeScript is inferring the array type as string[] instead of string[][]. I need to fix the type explicitly.
The issue is that the hero array is being inferred as string[] because of trailing commas. I'll rewrite the sprites file more carefully with explicit type annotations and arrays wrapped properly. Let me just rewrite the whole thing.
The issue is that string[] row arrays make TypeScript infer string[] (flat) instead of string[][]. I need to use a different pattern. Let me use as const with nested arrays typed explicitly:
Now let me create the game types and main game engine:
Now let me create the weapons and upgrades definitions:
Now the main game engine. This is the biggest file. Let me build it as a class that manages the world, rendering, and updates.
Just unused variable warnings. Let me fix them:
The errors didn't actually update. The linter may be caching. Let me read the file at those specific lines and check what's going on:
The errors are stale from previous edits (the linter might be showing older errors). Let me remove the unused r in whip and check current state. Looking at line 573, the r is set but never used - I should use it or remove it. Let me fix the remaining issues:
Now let me try a build to see the actual current errors:
Build is successful! The earlier warnings were stale. Now let me create the React UI with the menu, HUD, level-up screen, and game-over screen.
The import paths are wrong because the file is in src/ui/. Let me fix the imports and unused vars:
The linter seems to be showing stale errors. Let me check the actual file:
The errors are stale. Let me try a build:
Now I need to update App.tsx to use the new HUD component:
Build works! Now let me review the code for issues. There are a few things I want to improve:
-
The closest is computed in update() but only used to update hero.facing once - this is fine but the findClosestEnemy for fire is recomputed in fireWeapon. Let me actually pass it in.
-
I should add the hero weapon firing target via the precomputed closest for the wand.
-
The bible weapon — the orbit hit logic looks at entities near orbit, but I'm calling it during fireWeapon. The orbitR may be 110 but radius is small, so this should work.
-
The level-up screen — there's an issue. When the level up happens during update, it triggers onLevelUp which builds options and shows modal. But the modal must close when option is picked. Let me trace it...
-
The closest variable is being declared but the auto-aim needs proper handling — when an enemy exists, we want the wand to fire at it, not at the mouse. Let me check the code.
Looking at Game.ts: findClosestEnemy(600) is used for auto-aim facing, then fireWeapon recomputes closest for wand. That works.
Let me also fix one thing: I want to use the closest found in update for fireWeapon to avoid double-scanning. Let me refactor:
Now let me also fix the bible angle — it should be per-weapon, not per-bible. Actually since multiple bibles are a thing, the offset loop is correct. But I see that i indexing in drawBible is iterating all weapons, not just bibles. Let me fix:
Now let me also fix a logic issue with the wand — when closest is null, it should still fire toward the facing direction. Also I notice the closest parameter in fireWeapon is passed but not used. Let me refactor:
Now let me think about what else to polish:
- Bosses should drop chests and have visual presence - done.
- The "Survivor.io" feel needs a "map" of enemies spawning from edges - done with off-screen spawning.
- The hero is too small - let me check the HERO_SCALE. With 4 scale, 16px hero = 64px. That's reasonable.
- No minimap - survivor.io has one. Let me add it.
- Need pause/restart during play - done.
- Damage numbers need to be more juicy - already have float-up.
- Background feels flat - let me add some flair.
Let me also add a few important things:
- Game start/intro countdown "Ready" → "Go!"
- A small minimap in the corner
- The hero weapon is too low impact visually - let me make projectiles look better
Let me also verify the rendering doesn't have issues by checking the closest facing logic. The auto-aim should mean the hero always faces the nearest enemy. I want to make sure this is correct.
Actually, looking at the code more carefully, I see an issue with heroFacingX/Y. In the input handler, I set these from mouse when aiming, but in update, I set these from closest enemy. The order is: input handlers run, then update runs. So during update, the closest is computed and overrides mouse aim. That's actually the intended auto-aim behavior.
Let me also add a minimap and improve visuals. Let me also check for an issue: when wave timer starts, the first wave should come quickly, but waveTimer is initialized to 3, so first wave is at t=3. But spawnTimer starts at 0 so enemies should spawn at t=0+epsilon. Good.
Let me add a minimap to the HUD:
The error is stale - the Minimap function is defined after the JSX. Let me just rebuild:
Let me also add a small intro countdown and improve the level up modal positioning. Let me also add an enemy "warning" marker on the screen edge when off-screen, and improve the feel.
Actually let me focus on making the experience feel premium. Let me:
- Add screen-edge indicator arrows for off-screen enemies (very survivor.io feel)
- Add a "GAME" feel with a small countdown "3, 2, 1, GO"
- Improve the weapon selection visual
Actually let me also add a critical gameplay improvement: the hero should have an idle animation, and the wave intro should be more dramatic. Let me also add a "Level Up" text that flashes.
Let me check the current state and add a few visual polishes. First let me look at the current state of the game and see what's missing for the "premium" feel:
Let me add a few more things to make it feel really premium. First, let me add an off-screen enemy indicator (arrows pointing to enemies off-screen) and a level-up flash. I'll modify the render method:
Now let me also add a "level up" celebration flash on the canvas. Actually, the React UI handles that with the modal. But I want the canvas to show a brief flash:
Now I want to fix one subtle thing: when the level up modal is shown, the game should pause. Looking at the code, the update() returns early when status isn't 'playing'. Good. But the rendering still continues which is fine.
But there's a subtle bug: when the modal closes, we set status to 'playing' but the state is still tracked. The issue is that the timer/wave timer keeps running even during the modal. Actually since update returns early when not 'playing', the timers don't advance. Good.
Now let me also add a small intro "Ready" animation. Let me modify the start to show a brief countdown. Actually, let me just make the message "GO!" appear:
Let me also check the magnet icon should be a true magnet shape - I think my drawing is OK.
One more thing: when the game starts, the waveTimer is 3, but spawnTimer is 0, so it spawns immediately. Good.
Now let me also improve a few more things to make this feel polished:
- Add a "KILL!" pop-up when you kill lots of enemies quickly
- Make the hero glow when invincible
- Add a damage flash on the hero when hit
- Add pickup notifications
Let me also fix something I noticed: the closest is set as this.hero.facing, so the hero rotates. But the sprite flip is based on Math.cos(this.hero.facing) < 0. This might cause the hero to flip when facing left, which is good.
Let me also check that pause works during modal. When levelup modal is open, status is 'levelup', so update doesn't run. Good.
Let me also add a special touch: when you kill a boss, show "BOSS DOWN!" and a brief slow-mo. Already there.
Let me also think about the "no enemies" case - if all enemies are dead, the game waits for next wave. Good.
Let me also test the build and add a small "Game paused" / "Go!" intro overlay. Let me add the intro to the React side:
Stale error again. Let me build:
Let me think about the "GO!" intro - I want a 3-2-1-GO countdown. Let me improve it:
Actually let me check what happens to state.time and state.status during the intro. When game starts, state.time is 0, state.status = 'playing', message = "SURVIVE!" with messageTime = 2. So:
- t=0: SURVIVE! shows
- t=0..2: introTime (0..2) is truthy, but it might show 3 then GO at 0.5. Let me reconsider.
Actually state.time starts at 0 and increases. introTime = state.time. So:
- t=0: 3
- t=0.5: 3 (Math.ceil(0.5) = 1) - that's wrong!
Wait, Math.ceil(0.5) = 1. I need Math.ceil(introTime). At t=0, that's Math.ceil(0) = 0. That's wrong too. Let me fix:
The countdown should show 3, 2, 1, GO! during 0..2 seconds. So:
- t=0 to 0.5: "3"
- t=0.5 to 1.0: "2"
- t=1.0 to 1.5: "1"
- t=1.5 to 2.0: "GO!"
Let me rewrite:
Now let me think about more polish. I noticed an issue with the spawn: when the game starts, spawnTimer is 0, so the first enemies spawn immediately, but the hero can't move for 2 seconds (during intro). That's actually fine - we want the wave to be there waiting.
But wait, the first wave timer is 3s, and spawnTimer is 0, so it spawns immediately. The hero can't fight yet. Let me delay the first spawn:
Actually, the way it works is good - enemies spawn off-screen and approach the player. So even if the player is in countdown, the enemies are still moving toward the player. Once GO! appears, the player can fight.
Let me also fix one issue I noticed: when level-up modal is open, the timer for messageTime is still being decremented in update, but since update returns early when not playing, the message stays. Good.
Let me also add a small feature: the gems should sparkle/pulse. Let me also check the magnet pickup - I think I should spawn it occasionally. And there's no bomb pickup spawner.
Let me also add a feature where the kill count gets a "multiplier" or a "combo" feel. Actually, the current implementation is solid. Let me focus on making it look amazing.
Let me improve the visual effects:
- Hero gets a damage flash when hurt
- Add a hit indicator (red flash on the edge of screen)
- Add a critical hit visual effect
Let me also reduce the bomb drop chance since I have no way to actually collect it through gameplay - oh wait, I do have a bomb sprite but I never spawn bombs. Let me remove it or spawn it from bosses. Actually, let me just leave it.
One thing I want to add: a "Magnet" pickup that boosts magnet range. Let me add it as a rare drop from zombies:
Actually let me focus on what matters - the game is already great. Let me also make sure the game feels tight. Let me look at the current state of things by reviewing the Hud component:
Now let me add a critical feature: a damage indicator (red flash on edges of screen when hit). And let me also add a "low HP" warning pulse:
Now let me also add a "floating xp" indicator that pops up when you level up. Actually I already have the message system. Let me think about more improvements.
One key thing I want: the player should be able to "feel" the chaos. Let me add a few more visual effects:
- When the wave starts, a screen-wide wave indicator
- When you kill many enemies in a short time, a "x5 COMBO!" or similar
Let me also make the cursor disappear during gameplay (immersive feel). Actually no, let me leave that.
Let me also add a sound for "killed" (visual only). Actually we don't have audio so let me skip that.
Let me look at one more thing - the upgrade options. They need to actually scale with luck. Let me re-check rollUpgradePool. Actually the luck logic is just shuffling, which is OK. Let me also make sure reroll is meaningful - I should reduce options that are already at max level for that weapon.
Actually I think the game is in great shape. Let me build and do a final check:
Let me also think about issues. Let me trace through what happens when the user starts the game:
- User clicks PLAY
startGame() is called
started = true, gameOver = null
gameRef.current.start() is called
- Game starts: weapons = [wand], hero at center
- state.status = 'playing', time = 0, message = "SURVIVE!", messageTime = 2
- First render: shows "SURVIVE!" message, then "3" countdown
Wait, the SURVIVE message and countdown will both show. Let me check... The message shows when state.messageTime > 0 and the intro shows when state.time < 2. So both will show at once. That's actually fine - "SURVIVE!" + "3" countdown is fine.
Actually let me change the start message to not show during the intro. Let me set the initial message to be empty:
Actually no, let me leave it. The "SURVIVE!" message is part of the intro. After 2s, the message fades and we move on.
Let me also check the closest logic. When the closest is set, the hero faces it. But the hero also has a mouse-aim. The mouse-aim is set in the input handler. Then in update, the closest overrides. So actually the mouse aim never takes effect because update always runs after input.
Wait, let me re-read. The heroFacingX/Y is only used in update() to compute hero.facing. The hero.facing is then used in drawHero for flip and fireWeapon for whip/axe angles. So if I want the player to aim with mouse, I should set hero.facing to the mouse direction. But with auto-aim, the closest is better.
Let me think about this. Survivor.io has auto-aim that always targets the nearest enemy. So auto-aim is correct.
But what if I want to use the mouse for aim and override auto-aim? In survivor.io, you actually use a virtual joystick on mobile. On desktop, you can use mouse for direction (movement) and the weapons auto-fire.
OK so the current logic is correct. The hero's facing is always toward the closest enemy. Movement is WASD or joystick.
But wait, the player would want to see what direction the hero is facing. So drawing the hero with the facing is good. The hero.flip is based on Math.cos(this.hero.facing) < 0. This means when facing left, flip. That's a good visual.
Let me also make sure that when the player has a wand but no enemies, nothing weird happens. The wand only fires if there's a target. Good.
Let me also test the build one more time and make sure everything looks good. Actually let me also add one more visual improvement: the projectiles should have a stronger glow. Let me check the projectile sprite.
The projectile sprite is already a 24x24 radial gradient. That should be fine.
Let me also think about a potential bug: when the game starts, the wave timer is 3, so first wave is at t=3. But spawnTimer is 0, so it spawns at t=0+epsilon. The first wave will have base count (4) of zombies. The wave timer is set to 25-35s after that. So the first wave comes at t=0, then at t=3 the next wave starts (timer=3). Hmm, that means waves happen rapidly at first. Let me fix:
Actually the wave is at t=3 (since waveTimer starts at 3), and the first spawn is at t=0. So the player has 3 seconds to fight the first wave of 4 zombies, then the next wave of 6 zombies (wave 2). That's OK actually.
But the wave 1 doesn't actually increment wave number until t=3. So the first spawn is "pre-wave 1". Let me adjust so the first wave starts immediately:
Actually I think it's fine. Let me move on.
One more thing: when the level-up modal closes, I want the game to continue from where it was. Let me check the code... g.state.status = 'playing'; setLevelUpOptions(null); - good.
Now let me also add a small touch: the game should show a "press space to start" hint. Actually no, the play button does that.
Let me also add: when the player clicks on the canvas while in menu, nothing happens. That's fine.
Let me also think about the React state updates. The setUi is called every frame via onStateChange. That's 60 times per second. That could be slow because React re-renders. Let me batch the state updates.
Actually, looking at the code, onStateChange is called every frame in update(). That triggers a React re-render. React's re-render is fast but it could affect performance. Let me throttle to 20 FPS or so:
Looking again, the state is shallow-copied. The React re-render only updates the HUD text/bars. The canvas is rendered separately by the game loop. So React is just syncing HUD. 60 FPS React re-renders are fine for simple HUD.
But wait, setUi is called even when the state hasn't changed (every frame). Let me make it conditional or batched. Actually for now let's leave it - the performance should be OK on modern devices.
Let me also think about the issue: when level-up modal is open, the game state is still updating every frame via onStateChange. But update() returns early when not 'playing'. So the state doesn't change much. The message timer is also not updating. So the only thing changing is the state object which has a new reference each frame. The React render sees the new reference and re-renders. But the content is the same. The useState shallow comparison would say "changed" because object reference is different.
Let me just leave it. Modern React is fast.
OK let me do a final polish. Let me also fix a potential issue: the closest is only used in fireWeapon for wand/fireball/axe. The whip uses hero.facing which is the closest direction. The bible uses orbit hit. So all weapons work.
One last thing: I want to make sure the game pauses properly. Let me trace:
- Game running, state.status = 'playing'
- User presses Escape → state.status = 'paused', setPaused(true)
- Pause modal shows
- update() returns early (status is 'paused')
- User clicks Resume → state.status = 'playing', setPaused(false)
- update() continues
Good.
Now let me also make sure the level-up flow works:
- Hero gains XP, levels up
- triggerLevelUp() is called
- state.status = 'levelup', flash and shake
- onLevelUp callback is called
- UI builds options and shows modal
- User picks option → apply() called → g.applyUpgrade(id) + state.status = 'playing'
- setLevelUpOptions(null) → modal closes
Good.
Now let me build and check:
Let me now think about any remaining issues. Let me look at the build to see if there are issues with the dist:
Single file dist. Let me verify the dist has the right content. Let me also make a few final improvements:
- The hero needs to look more like a "survivor" - maybe a sword
- The bomb pickup should be spawned by bosses
Let me also add a touch: when the player is invincible, they should flash. Looking at the code: if (this.hero.invincible > 0 && Math.floor(this.hero.invincible * 20) % 2 === 0) { ctx.globalAlpha = 0.4; } - this creates a flash effect. Good.
Let me also check the magnet pickup. The pickup collector code has magnet handling that boosts magnetStrength. But where does the magnet pickup get spawned? Let me check... I see it's not spawned anywhere. Let me add a small chance for brute to drop a magnet:
Actually, let me look at the killEntity code:
I see the magnet pickup is not spawned. Let me add a magnet drop to brutes occasionally:
Now let me also add a small important gameplay feature: a damage indicator on the screen edge (where the damage came from). And let me also think about what else would make this feel premium.
Actually I think the current implementation is already very good. Let me build and finalize:
Let me also add one more critical feature: a "Game Paused" indicator when the level up is open. Actually, the canvas keeps rendering so the player sees the action frozen. Good.
Let me also add a small detail: when the player hovers a weapon, show its stats. Let me also think about whether I should add more variety.
Actually, I just realized the issue with "foundClosest" - it's only used to set facing and passed to fireWeapon. But fireWeapon for wand, axe, fireball, whip - they all need a target. The bible uses orbit. So the closest is used appropriately.
Let me also check one more thing: the closest variable in update() uses 700 range. But findClosestEnemy(500) is also used in fireWeapon for wand if closest is null. That's a slight inconsistency. Let me make it consistent:
Now let me also think about one more critical thing: the fireWeapon for the wand now never returns null. So we always fire. Good.
But wait, for the wand to fire, we need a target. If there's no target, we don't fire (which is the desired behavior). Good.
Now let me also look at the dist size. 290kb is reasonable for a game with sprites.
Let me also verify one issue: the hero.facing is atan2(dy, dx). When dy=0, dx=-1 (facing left), atan2(0, -1) = π. So Math.cos(π) = -1 < 0, flip. Good.
Let me also make sure the sprite for hero is drawn facing right. Looking at the sprite:
- The cape is at top
- Eyes are looking forward
- Arms are out to the sides
I think the sprite looks symmetric enough. The flip is good.
Let me also do a final check on the dist:
Now let me also think about one critical detail: I want the game to feel really juicy. Let me add a "kill flash" - when you kill an enemy, the screen has a tiny flash. And let me also add a screen-wide hit indicator when you take damage.
Actually let me also reconsider: the player gets hit by an enemy. We already flash and shake. But there's no directional indicator showing where the hit came from. Let me add a small red arrow on the screen edge:
Actually, let me also add a hit indicator that comes from the direction of the damage. I think this is the most important thing missing. Let me add it:
Actually, looking at the code, I already have shake and hurtTimer for the hero. The red border vignette shows when low HP. Let me add a brief red flash on the entire screen when hit. Let me check the current flash mechanism - it's used for screen flash but only for level up. Let me add a hit flash:
Let me also reduce the hit flash intensity to be subtle. The flash alpha is Math.min(0.6, this.state.flashTime * 1.5). With flashTime=0.1, alpha=0.15. That's good and subtle.
Now let me also make sure the game is actually fun. Let me think about balance:
- Starting HP: 100
- Zombie damage: 8, so 12-13 hits to die
- Zombie HP: 14, wand damage: 12, so 1-2 wand hits to kill
- Wand cooldown: 1s
That feels OK. The first wave should be a breeze, then ramp up.
Let me also check the level-up XP requirements:
xpToNext(1) = floor(5 + 8 + 1.5) = 14. So you need 14 XP to reach level 2. Each zombie gives 2 XP (split into 1+1 gems), so you need to kill 7 zombies for level 2. Each brute gives 5 XP. First wave has 4 zombies. So you need about 2 waves to level up first time. That's OK.
xpToNext(5) = floor(5 + 40 + 11.4) = 56. So level 5 needs 56 XP. Reasonable.
Let me also verify the build:
Let me also check that the index.html title is right and add a favicon:
Good. Now let me think about one more important thing: the game uses canvas2d with image-rendering: pixelated. The sprites are drawn at 3-4x scale. The hero is 16x18 pixels → 64x72 pixels. That's a reasonable size for a game like this.
Let me also check if there's an issue with the hero being too small on a large screen. On a 1920x1080 screen, the hero at 64x72 pixels is small. But it works for this kind of game. Survivor.io on mobile is similar.
Let me also add a final touch: the "How to Play" should mention the actual controls. Let me re-read it... it says WASD for keyboard. But on mobile there's no WASD. Let me check the modal:
Looking at HelpModal: it correctly mentions touch joystick. Good.
Now let me also think about the overall architecture. I have:
src/App.tsx - entry
src/ui/Hud.tsx - main UI and game loop
src/game/Game.ts - game engine
src/game/sprites.ts - sprite generation
src/game/types.ts - types
src/game/weapons.ts - weapon and upgrade definitions
This is a clean architecture.
Let me also verify there are no issues with the closest in update. The issue is that findClosestEnemy(Infinity) could be slow if there are many enemies. Let me cap it:
Now let me also think about one final issue. When the user is in the menu and the game is initialized, the game loop is running but update() returns early because status === 'menu'. The render still runs and shows... what? The hero, the entities (empty), the world. That's fine.
But wait, the menu is overlaid on top of the canvas. The canvas shows the world with the hero in the center. That's actually a nice effect - the player sees the world in the background.
Let me also make sure the menu hides the world. Actually no, the world background looks nice. Let me keep it.
Let me also make sure the closest doesn't cause the hero to face weird angles. When the closest is set, hero.facing = atan2(dy, dx). When the closest is right next to the hero, dx and dy are small but non-zero. atan2 still works. Good.
OK let me also make sure the projectile rendering is correct. The trail is drawn first, then the sprite. The trail alpha decreases over time. Good.
Let me also do a final check on the gameplay loop. Let me trace a complete scenario:
- Game starts, hero at center, wand equipped
- t=0: 3..2..1..GO! countdown
- t=0+epsilon: spawn 4 zombies
- t=3: wave 2, spawn 6 zombies
- Hero kills zombies, gains XP
- Level up → modal appears, game pauses
- User picks upgrade, game resumes
- More waves, eventually wave 5 → boss spawns
- Player kills boss, gets chest, opens it for level up
- Player dies at some point → game over screen
- User can restart or go to menu
This all looks correct.
Let me also make sure the HeroStats are correct. The hero has:
- HP, maxHP, regen
- speed, armor
- pickupRange, magnetStrength
- critChance, critDamage
- damageMultiplier, projectileSpeedMultiplier
- areaMultiplier, cooldownMultiplier
- mightMultiplier, luck
- revive
All applied appropriately.
One last thing: I want to add a "level up" text that flashes on the canvas briefly. Let me add it as a damage number style:
Actually I think the React modal already does that. Let me leave it.
Let me also think about one more thing: the survivor.io game has a "stat sheet" on the right side. But that's clutter. Let me leave it.
Let me do a final build and call it done:
Files built: index.html, src/index.css, src/game/sprites.ts, src/game/types.ts, src/game/weapons.ts, src/game/Game.ts, src/ui/Hud.tsx, src/App.tsx