Untitled
Anonymous
HTML
11/16/2026 6:02 PM
9.6 KB
9
Indexable
Never
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Custom PC Game Maker</title>
<style>
* { box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
body {
margin: 0; padding: 0;
background-color: #121212; color: #ffffff;
display: flex; height: 100vh; overflow: hidden;
}
/* Sidebar Controls */
.sidebar {
width: 340px; background: #1e1e24; padding: 20px;
border-right: 1px solid #333; display: flex; flex-direction: column;
gap: 15px; overflow-y: auto;
}
h1 { font-size: 20px; margin: 0 0 5px 0; color: #00d2ff; }
p.subtitle { font-size: 13px; color: #aaa; margin: 0 0 10px 0; }
label { font-size: 13px; font-weight: bold; display: block; margin-bottom: 5px; color: #ddd; }
input[type="text"], select, input[type="range"] {
width: 100%; padding: 8px; border-radius: 5px;
border: 1px solid #444; background: #2b2b36; color: #fff;
}
input[type="color"] {
width: 100%; height: 38px; border: none; border-radius: 5px;
background: #2b2b36; cursor: pointer;
}
.row { display: flex; gap: 10px; }
.row > div { flex: 1; }
button {
padding: 12px; border: none; border-radius: 6px; font-weight: bold;
cursor: pointer; font-size: 14px; transition: 0.2s;
}
.btn-preview { background: #3a86ff; color: white; }
.btn-preview:hover { background: #2667cc; }
.btn-download { background: #00b894; color: white; margin-top: auto; }
.btn-download:hover { background: #00997a; }
/* Main Preview Area */
.main {
flex: 1; display: flex; flex-direction: column;
align-items: center; justify-content: center; background: #0d0d10; padding: 20px;
}
.preview-header { margin-bottom: 10px; color: #888; font-size: 14px; }
iframe {
width: 820px; height: 540px; border: 2px solid #333;
border-radius: 8px; background: #000; box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}
</style>
</head>
<body>
<div class="sidebar">
<div>
<h1>🎮 PC Game Maker</h1>
<p class="subtitle">Customize your game and export it as a standalone HTML file.</p>
</div>
<div>
<label>Game Title</label>
<input type="text" id="gameTitle" value="Neon Dodger">
</div>
<div>
<label>Game Genre</label>
<select id="gameType">
<option value="dodger">Arcade Dodger (WASD / Arrows)</option>
<option value="shooter">Space Shooter (Arrows + Spacebar)</option>
</select>
</div>
<div class="row">
<div>
<label>Player Color</label>
<input type="color" id="playerColor" value="#00d2ff">
</div>
<div>
<label>Enemy Color</label>
<input type="color" id="enemyColor" value="#ff4757">
</div>
<div>
<label>Background</label>
<input type="color" id="bgColor" value="#111116">
</div>
</div>
<div>
<label>Player Speed: <span id="pSpeedVal">6</span></label>
<input type="range" id="playerSpeed" min="3" max="15" value="6" oninput="document.getElementById('pSpeedVal').innerText = this.value">
</div>
<div>
<label>Enemy Speed: <span id="eSpeedVal">4</span></label>
<input type="range" id="enemySpeed" min="2" max="12" value="4" oninput="document.getElementById('eSpeedVal').innerText = this.value">
</div>
<button class="btn-preview" onclick="updatePreview()">â–¶ Update & Test Game</button>
<button class="btn-download" onclick="downloadGame()">⬇ Download Game (.html)</button>
</div>
<div class="main">
<div class="preview-header">Live Interactive Preview (Click inside game to play)</div>
<iframe id="previewFrame"></iframe>
</div>
<script>
function generateGameCode() {
const title = document.getElementById('gameTitle').value || 'My Custom Game';
const type = document.getElementById('gameType').value;
const pColor = document.getElementById('playerColor').value;
const eColor = document.getElementById('enemyColor').value;
const bgColor = document.getElementById('bgColor').value;
const pSpeed = parseInt(document.getElementById('playerSpeed').value);
const eSpeed = parseInt(document.getElementById('enemySpeed').value);
return `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>${title}</title>
<style>
body {
margin: 0; background: #08080a; color: #fff;
display: flex; flex-direction: column; align-items: center; justify-content: center;
height: 100vh; font-family: sans-serif; overflow: hidden;
}
canvas {
background: ${bgColor}; border: 2px solid #444;
box-shadow: 0 0 20px rgba(0,0,0,0.8);
}
.hud {
width: 800px; display: flex; justify-content: space-between;
margin-bottom: 8px; font-size: 18px; font-weight: bold;
}
</style>
</head>
<body>
<div class="hud">
<span>${title}</span>
<span>Score: <span id="score">0</span></span>
</div>
<canvas id="game" width="800" height="480"></canvas>
<script>
const canvas = document.getElementById('game');
const ctx = canvas.getContext('2d');
const scoreEl = document.getElementById('score');
let score = 0;
let gameOver = false;
const keys = {};
const player = { x: 380, y: 420, w: 36, h: 36, speed: ${pSpeed} };
let enemies = [];
let bullets = [];
window.addEventListener('keydown', e => {
keys[e.code] = true;
if (e.code === 'Space' && '${type}' === 'shooter' && !gameOver) {
bullets.push({ x: player.x + player.w / 2 - 3, y: player.y, w: 6, h: 14, speed: 9 });
}
if (e.code === 'Enter' && gameOver) resetGame();
});
window.addEventListener('keyup', e => keys[e.code] = false);
function resetGame() {
score = 0;
scoreEl.innerText = score;
enemies = [];
bullets = [];
player.x = 380;
player.y = 420;
gameOver = false;
loop();
}
function spawnEnemy() {
if (Math.random() < 0.04) {
const size = 25 + Math.random() * 25;
enemies.push({
x: Math.random() * (canvas.width - size),
y: -size,
w: size, h: size,
speed: ${eSpeed} + Math.random() * 2
});
}
}
function collide(a, b) {
return a.x < b.x + b.w && a.x + a.w > b.x && a.y < b.y + b.h && a.y + a.h > b.y;
}
function update() {
if (keys['ArrowLeft'] || keys['KeyA']) player.x -= player.speed;
if (keys['ArrowRight'] || keys['KeyD']) player.x += player.speed;
if ('${type}' === 'dodger') {
if (keys['ArrowUp'] || keys['KeyW']) player.y -= player.speed;
if (keys['ArrowDown'] || keys['KeyS']) player.y += player.speed;
}
player.x = Math.max(0, Math.min(canvas.width - player.w, player.x));
player.y = Math.max(0, Math.min(canvas.height - player.h, player.y));
bullets.forEach((b, i) => {
b.y -= b.speed;
if (b.y < 0) bullets.splice(i, 1);
});
spawnEnemy();
enemies.forEach((en, ei) => {
en.y += en.speed;
if (collide(player, en)) gameOver = true;
bullets.forEach((b, bi) => {
if (collide(b, en)) {
enemies.splice(ei, 1);
bullets.splice(bi, 1);
score += 10;
scoreEl.innerText = score;
}
});
if (en.y > canvas.height) {
enemies.splice(ei, 1);
if ('${type}' === 'dodger') {
score += 1;
scoreEl.innerText = score;
}
}
});
}
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Player
ctx.fillStyle = '${pColor}';
ctx.fillRect(player.x, player.y, player.w, player.h);
// Bullets
ctx.fillStyle = '#fff200';
bullets.forEach(b => ctx.fillRect(b.x, b.y, b.w, b.h));
// Enemies
ctx.fillStyle = '${eColor}';
enemies.forEach(en => ctx.fillRect(en.x, en.y, en.w, en.h));
if (gameOver) {
ctx.fillStyle = 'rgba(0,0,0,0.75)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = '#fff';
ctx.font = 'bold 36px sans-serif';
ctx.textAlign = 'center';
ctx.fillText('GAME OVER', canvas.width / 2, canvas.height / 2 - 15);
ctx.font = '18px sans-serif';
ctx.fillText('Press ENTER to Play Again', canvas.width / 2, canvas.height / 2 + 25);
}
}
function loop() {
if (!gameOver) {
update();
draw();
requestAnimationFrame(loop);
} else {
draw();
}
}
loop();
<\/script>
</body>
</html>`;
}
function updatePreview() {
const iframe = document.getElementById('previewFrame');
iframe.srcdoc = generateGameCode();
}
function downloadGame() {
const code = generateGameCode();
const title = (document.getElementById('gameTitle').value || 'custom-game')
.toLowerCase().replace(/[^a-z0-9]/g, '-');
const blob = new Blob([code], { type: 'text/html' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = title + '.html';
a.click();
URL.revokeObjectURL(url);
}
// Load initial game on page start
window.onload = updatePreview;
</script>
</body>
</html>
Editor is loading...
Leave a Comment