This model didn't return a displayable web page for this challenge.
View raw output
# Super Mario Bros. Interactive Level
Here's a self-contained HTML page with an interactive Mario-style level. It includes platforming elements, enemies, coins, and a flagpole goal - all in the spirit of classic Nintendo games.
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Interactive Mario Level</title>
<style>
body {
margin: 0;
overflow: hidden;
background: linear-gradient(to bottom, #1E90FF, #87CEEB);
font-family: 'Arial', sans-serif;
}
#game {
position: relative;
width: 800px;
height: 400px;
margin: 20px auto;
background-color: #7EC0EE;
overflow: hidden;
border: 4px solid #333;
border-radius: 8px;
}
#ground {
position: absolute;
bottom: 0;
width: 1600px;
height: 32px;
background-color: #5C9403;
}
.platform {
position: absolute;
background-color: #C14F4F;
border: 2px solid #8C3A3A;
border-radius: 4px;
}
.brick {
position: absolute;
width: 32px;
height: 32px;
background-color: #E08030;
border: 2px solid #B05820;
border-radius: 2px;
}
.question-block {
position: absolute;
width: 32px;
height: 32px;
background-color: #F8D030;
border: 2px solid #C0A020;
border-radius: 2px;
animation: bounce 0.5s infinite alternate;
}
@keyframes bounce {
from { transform: translateY(0); }
to { transform: translateY(-2px); }
}
.coin {
position: absolute;
width: 16px;
height: 16px;
background-color: #F8D030;
border-radius: 50%;
border: 2px solid #E0B020;
animation: spin 0.5s infinite linear;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
#mario {
position: absolute;
width: 32px;
height: 48px;
background-color: #E04018;
border-radius: 8px;
left: 100px;
bottom: 32px;
z-index: 10;
transition: transform 0.1s;
}
#mario::before {
content: '';
position: absolute;
top: -10px;
left: 2px;
width: 28px;
height: 20px;
background-color: #E04018;
border-radius: 50% 50% 0 0;
}
#mario::after {
content: 'M';
position: absolute;
top: -5px;
left: 12px;
color: white;
font-weight: bold;
}
.goomba {
position: absolute;
width: 32px;
height: 32px;
background-color: #B06820;
border-radius: 50% 50% 0 0;
bottom: 32px;
}
.goomba::before {
content: '';
position: absolute;
width: 20px;
height: 8px;
background-color: #804010;
top: -4px;
left: 6px;
border-radius: 50%;
}
.goomba::after {
content: '';
position: absolute;
width: 6px;
height: 6px;
background-color: #000;
top: 8px;
left: 8px;
border-radius: 50%;
}
.pipe {
position: absolute;
width: 64px;
background-color: #20A020;
border: 2px solid #108010;
border-top: none;
}
.pipe-top {
width: 64px;
height: 16px;
background-color: #30B030;
border: 2px solid #108010;
border-radius: 4px 4px 0 0;
}
.flagpole {
position: absolute;
width: 4px;
height: 200px;
background-color: #808080;
z-index: 5;
}
.flag {
position: absolute;
width: 30px;
height: 20px;
background-color: #E04018;
clip-path: polygon(0 0, 100% 50%, 0 100%);
z-index: 5;
}
#score {
position: absolute;
top: 10px;
left: 10px;
color: white;
font-size: 16px;
text-shadow: 2px 2px 0 #000;
}
#lives {
position: absolute;
top: 30px;
left: 10px;
color: white;
font-size: 16px;
text-shadow: 2px 2px 0 #000;
}
#end-screen {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.8);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: white;
font-size: 24px;
text-align: center;
z-index: 100;
display: none;
}
#restart-btn {
margin-top: 20px;
padding: 10px 20px;
background-color: #E04018;
border: none;
border-radius: 4px;
color: white;
font-size: 18px;
cursor: pointer;
}
#restart-btn:hover {
background-color: #F05020;
}
#instructions {
position: absolute;
bottom: 10px;
left: 50%;
transform: translateX(-50%);
color: white;
text-align: center;
font-size: 14px;
text-shadow: 1px 1px 0 #000;
}
</style>
</head>
<body>
<div id="game">
<div id="ground"></div>
<div id="mario"></div>
<div id="score">Score: 0</div>
<div id="lives">Lives: 3</div>
<div id="end-screen">
<h2>Level Complete!</h2>
<p id="final-score">Your Score: 0</p>
<button id="restart-btn">Play Again</button>
</div>
<div id="instructions">
Arrow keys to move | Space to jump
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const game = document.getElementById('game');
const mario = document.getElementById('mario');
const scoreDisplay = document.getElementById('score');
const livesDisplay = document.getElementById('lives');
const endScreen = document.getElementById('end-screen');
const finalScore = document.getElementById('final-score');
const restartBtn = document.getElementById('restart-btn');
let score = 0;
let lives = 3;
let marioX = 100;
let marioY = 400 - 32 - 48; // Bottom - ground - mario height
let velocityY = 0;
let isJumping = false;
let gameWidth = 800;
let gameHeight = 400;
let groundHeight = 32;
let cameraX = 0;
let gameRunning = true;
// Game elements
const platforms = [];
const bricks = [];
const questionBlocks = [];
const coins = [];
const goombas = [];
const pipes = [];
// Create level elements
function createLevel() {
// Platforms
createPlatform(300, 300, 100, 16);
createPlatform(500, 250, 100, 16);
createPlatform(700, 200, 100, 16);
createPlatform(900, 150, 100, 16);
createPlatform(1100, 200, 100, 16);
createPlatform(1300, 250, 100, 16);
// Bricks
createBrick(350, 268);
createBrick(550, 218);
createBrick(750, 168);
createBrick(950, 118);
createBrick(1150, 168);
createBrick(1350, 218);
// Question blocks
createQuestionBlock(400, 268);
createQuestionBlock(600, 218);
createQuestionBlock(800, 168);
createQuestionBlock(1000, 118);
createQuestionBlock(1200, 168);
// Coins
createCoin(200, 300);
createCoin(220, 300);
createCoin(240, 300);
createCoin(450, 200);
createCoin(850, 150);
createCoin(1250, 200);
// Goombas
createGoomba(400);
createGoomba(800);
createGoomba(1200);
// Pipes
createPipe(600, 400 - groundHeight, 64, 80);
createPipe(1000, 400 - groundHeight, 64, 60);
// Flagpole at the end
createFlagpole(1500, 100);
}
function createPlatform(x, y, width, height) {
const platform = document.createElement('div');
platform.className = 'platform';
platform.style.left = x + 'px';
platform.style.top = y + 'px';
platform.style.width = width + 'px';
platform.style.height = height + 'px';
game.appendChild(platform);
platforms.push({x, y, width, height, element: platform});
}
function createBrick(x, y) {
const brick = document.createElement('div');
brick.className = 'brick';
brick.style.left = x + 'px';
brick.style.top = y + 'px';
game.appendChild(brick);
bricks.push({x, y, element: brick});
}
function createQuestionBlock(x, y) {
const block = document.createElement('div');
block.className = 'question-block';
block.style.left = x + 'px';
block.style.top = y + 'px';
game.appendChild(block);
questionBlocks.push({x, y, element: block, hit: false});
}
function createCoin(x, y) {
const coin = document.createElement('div');
coin.className = 'coin';
coin.style.left = x + 'px';
coin.style.top = y + 'px';
game.appendChild(coin);
coins.push({x, y, element: coin, collected: false});
}
function createGoomba(x) {
const goomba = document.createElement('div');
goomba.className = 'goomba';
goomba.style.left = x + 'px';
game.appendChild(goomba);
goombas.push({x, y: 400 - groundHeight - 32, element: goomba, direction: 1, speed: 1});
}
function createPipe(x, y, width, height) {
const pipeTop = document.createElement('div');
pipeTop.className = 'pipe-top';
pipeTop.style.left = x + 'px';
pipeTop.style.top = y + 'px';
game.appendChild(pipeTop);
const pipe = document.createElement('div');
pipe.className = 'pipe';
pipe.style.left = x + 'px';
pipe.style.top = y + 16 + 'px';
pipe.style.height = height - 16 + 'px';
game.appendChild(pipe);
pipes.push({x, y, width, height, element: pipe, top: pipeTop});
}
function createFlagpole(x, height) {
const flagpole = document.createElement('div');
flagpole.className = 'flagpole';
flagpole.style.left = x + 'px';
flagpole.style.top = (400 - height) + 'px';
flagpole.style.height = height + 'px';
game.appendChild(flagpole);
const flag = document.createElement('div');
flag.className = 'flag';
flag.style.left = (x + 4) + 'px';
flag.style.top = (400 - height + 20) + 'px';
game.appendChild(flag);
}
// Game controls
const keys = {
left: false,
right: false,
up: false
};
document.addEventListener('keydown', function(e) {
if (!gameRunning) return;
switch(e.key) {
case 'ArrowLeft':
keys.left = true;
break;
case 'ArrowRight':
keys.right = true;
break;
case 'ArrowUp':
case ' ':
keys.up = true;
if (!isJumping) {
velocityY = -12;
isJumping = true;
}
break;
}
});
document.addEventListener('keyup', function(e) {
switch(e.key) {
case 'ArrowLeft':
keys.left = false;
break;
case 'ArrowRight':
keys.right = false;
break;
case 'ArrowUp':
case ' ':
keys.up = false;
break;
}
});
restartBtn.addEventListener('click', function() {
resetGame();
endScreen.style.display = 'none';
gameRunning = true;
});
function resetGame() {
score = 0;
lives = 3;
marioX = 100;
marioY = 400 - groundHeight - 48;
velocityY = 0;
isJumping = false;
cameraX = 0;
scoreDisplay.textContent = 'Score: 0';
livesDisplay.textContent = 'Lives: 3';
// Clear all elements
platforms.forEach(p => p.element.remove());
bricks.forEach(b => b.element.remove());
questionBlocks.forEach(q => {
q.hit = false;
q.element.style.display = 'block';
});
coins.forEach(c => {
c.collected = false;
c.element.style.display = 'block';
});
goombas.forEach(g => g.element.remove());
pipes.forEach(p => {
p.element.remove();
p.top.remove();
});
// Clear arrays
platforms.length = 0;
bricks.length = 0;
questionBlocks.length = 0;
coins.length = 0;
goombas.length = 0;
pipes.length = 0;
// Recreate level
createLevel();
}
// Collision detection
function checkCollision(obj1, obj2) {
return obj1.x < obj2.x + obj2.width &&
obj1.x + 32 > obj2.x &&
obj1.y < obj2.y + obj2.height &&
obj1.y + 48 > obj2.y;
}
function checkPlatformCollision() {
for (const platform of platforms) {
if (marioX + 32 > platform.x &&
marioX < platform.x + platform.width &&
marioY + 48 >= platform.y &&
marioY + 48 <= platform.y + 10) {
marioY = platform.y - 48;
velocityY = 0;
isJumping = false;
return true;
}
}
return false;
}
function checkBrickCollision() {
for (const brick of bricks) {
if (checkCollision({x: marioX, y: marioY, width: 32, height: 48},
{x: brick.x, y: brick.y, width: 32, height: 32})) {
if (marioY + 48 <= brick.y + 10 && velocityY > 0) {
// Hit from below
marioY = brick.y - 48;
velocityY = 0;
isJumping = false;
addScore(50);
return true;
}
}
}
return false;
}
function checkQuestionBlockCollision() {
for (const block of questionBlocks) {
if (!block.hit && checkCollision({x: marioX, y: marioY, width: 32, height: 48},
{x: block.x, y: block.y, width: 32, height: 32})) {
if (marioY + 48 <= block.y + 10 && velocityY > 0) {
// Hit from below
block.hit = true;
block.element.style.animation = 'none';
block.element.style.backgroundColor = '#E08030';
velocityY = -5; // Small bounce
addScore(100);
// Spawn a coin above the block
createCoin(block.x, block.y - 32);
return true;
}
}
}
return false;
}
function checkCoinCollision() {
for (const coin of coins) {
if (!coin.collected &&
marioX + 32 > coin.x &&
marioX < coin.x + 16 &&
marioY + 48 > coin.y &&
marioY < coin.y + 16) {
coin.collected = true;
coin.element.style.display = 'none';
addScore(200);
return true;
}
}
return false;
}
function checkGoombaCollision() {
for (let i = 0; i < goombas.length; i++) {
const goomba = goombas[i];
if (checkCollision({x: marioX, y: marioY, width: 32, height: 48},