I'll build a polished Mario-style platformer game with all the requested features. Let me start by exploring the project structure and then build the game.
Now let me build the game. I'll create a canvas-based Mario platformer with all the requested features. Let me update the HTML title and create the game files.
Now let me create the game engine and all components. I'll build this as a canvas-based game rendered within React.
Now let me create the game logic/engine:
Let me fix those unused imports:
Now let me create the main App component with the canvas game:
Now let's build and see if there are any issues:
The build succeeds. Let me now review the game to make sure the gameplay loop is solid and fix a few issues I anticipate:
- The player might spawn falling through the ground on start
- Need to make sure the initial level has good pacing
- Touch controls need to work properly
Let me review and improve the engine:
I need to fix the player spawn position. The player should start above the ground level:
Now let me also look at the level generation to make sure the first section is interesting and fair. Let me look at the start:
The level generation looks good. Let me also enhance the initial area with some guaranteed coins that are easy to collect to hook the player immediately:
Now I need to add the ENEMY_SPEED and COIN_SIZE imports in engine.ts. Let me check what's already imported:
Good, ENEMY_SPEED and COIN_SIZE are already imported. Let me build again to check:
Builds successfully. Now let me review the CSS to make sure the game looks good on mobile:
Now let me also improve the rendering a bit - add a proper score increment animation when collecting coins, and make the game-over screen nicer. Let me also look at the respawn logic since I notice a potential issue with lives decrementing:
I see a bug - lives are being decremented in handlePlayerHit AND again in handleRespawnOrGameOver. The player starts with 3 lives but loses 2 on each hit. Let me fix that:
Also the player falling off screen should trigger death properly. Let me fix the fall death to also handle the lives system:
Let me look at the player fell off logic:
I see - when a player falls, handlePlayerDeath is called, but it doesn't decrement lives. The handlePlayerHit does decrement lives. Let me fix so falling also costs a life:
Now I need to also fix handlePlayerHit - it already decrements lives, which is correct for hit by enemy, but handlePlayerDeath also gets called from within handlePlayerHit (when lives <= 0), causing double decrement. Let me look at the flow more carefully:
When hit by enemy: handlePlayerHit → lives - 1, then if lives <= 0 → handlePlayerDeath → lives - 1 again (now -1).
When falling: handlePlayerDeath → lives - 1. Then after deathTimer → handleRespawnOrGameOver → checks lives <= 0.
Let me fix this properly:
Now the flow is clean: handlePlayerDeath always decrements lives by 1 and marks player dead. handlePlayerHit either takes a hit (if lives > 1) or triggers full death. After death timer expires, handleRespawnOrGameOver checks if lives <= 0 for game over.
Let me also add score for distance traveled and make it a bit more dynamic. Let me also check the respawn logic once more:
Let me add distance score and fix a potential issue where player death from falling could trigger multiple times:
Let me also make the camera follow smoother and add score based on distance more nicely:
Now let me also check one more potential issue - the enemy wall collision logic seems incorrect. The x-axis check for wall collisions in updateEnemies happens after movement, meaning the enemy could already be overlapping. Let me improve it:
The enemy collision is workable but could be tighter. Let me improve it to separate X and Y collisions:
Now let me also improve the touch controls - I want to make sure they feel responsive and work well. Let me also make the canvas properly scale on mobile:
The touch controls look good. Let me now build once more and make final polish:
Let me add a few more polish improvements. I want to make the game-over transition smoother, add a score animation for the distance, and ensure the viewport meta tag prevents zooming on mobile:
Let me also add a few more tweaks to the renderer for visual polish - background decoration elements and better visual feedback:
The renderer looks clean. Let me verify there are no type issues with the unused imports in renderer:
Coin is used. Let me add it back:
Let me check which types are actually used in the renderer:
All types are used. Let me do one final build to confirm everything works:
The game builds successfully. Let me now do a final review pass of the key files to make sure everything is polished:
Let me review one more thing - the updatePlayer function has the dead check, but we need to make sure the player doesn't update when dead and falling off screen doesn't trigger repeatedly:
Good, dead player handling is correct. The game engine, rendering, audio, and UI are all solid. Let me do one more refinement - I want to make sure the touch controls are visible and the game layout works well on different screen sizes. Let me also tweak the pause button to show on desktop too:
The layout looks good. Let me also add padding on the canvas container for mobile to prevent it from going edge-to-edge, and handle the case where the canvas might be wider than the screen on mobile landscape:
Let me do the final build:
The game builds successfully. Let me do a final summary of all the files:
Here's a summary of the complete Super Pixel Run game I built:
Architecture (6 files)
Game Engine (src/game/)
constants.ts — Game physics constants (gravity, speeds, sizes), color palette, tile sizes
types.ts — TypeScript interfaces for Player, Enemy, Coin, Platform, Particle, GameData, etc.
engine.ts — Core game logic:
- Procedural infinite level generation using seeded pseudo-random segments
- Full physics with separated X/Y collision resolution
- Player mechanics: acceleration/friction, coyote time, jump buffering, variable jump height
- Enemy AI with platform collision and reversal
- Coin collection, question block hits, brick bumps
- Combo system for successive enemy stomps
- Lives system, death/respawn, and game-over with local high score persistence
renderer.ts — Canvas 2D rendering:
- Parallax scrolling background (hills, clouds, bushes)
- Pixel-art Mario character with running/jumping animations
- Animated Goomba enemies with expressive faces
- Spinning coins, bouncing question blocks, brick patterns, pipes
- Particle systems, floating score text, screen shake
- Full UI: score, coins, lives, distance, combo indicator
- Menu screen with animated character and starfield
- Game-over screen with high score table
particles.ts — Particle factory functions (coin sparkles, stomp bursts, death explosions, run dust, landing puffs, block debris)
audio.ts — Web Audio API synthesized sound effects (jump, coin, stomp, death, block hit, combo, game over, start fanfare)
App (src/App.tsx)
- React component with canvas rendering via
requestAnimationFrame
- Fixed 60fps timestep with accumulator pattern
- Keyboard input (Arrow keys / WASD + Space)
- Touch controls: D-pad buttons + large JUMP button for mobile
- Pause button overlay
- Canvas auto-scaling to fit viewport
Key Features
- Instant fun: Coin arc right in front of player, first enemy at perfect stomp distance
- Tight controls: Coyote time (6 frames), jump buffering (8 frames), variable jump height
- Juicy feedback: Screen shake, particle explosions, squash/stretch, floating score text, combo multiplier
- Complete game loop: Start screen → Play → Pause (ESC) → Game Over → Instant restart
- Local high scores: Persisted via localStorage, displayed on menu and game-over screens
- Infinite procedural levels: Increasing difficulty with gaps, pipes, platforms, question blocks, enemies
- 60fps performance: Fixed timestep, frustum culling, efficient canvas rendering
- Mobile-ready: Touch controls, viewport lock, no-scroll CSS, responsive canvas scaling
Files built: index.html, src/game/constants.ts, src/game/types.ts, src/game/particles.ts, src/game/audio.ts, src/game/renderer.ts, src/game/engine.ts, src/App.tsx, src/index.css