Meta Description" name="description" />
<!DOCTYPE html>
<html lang="hi">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>GTA 5 Mini Game</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: #222; overflow: hidden; touch-action: none; font-family: sans-serif; }
canvas { display: block; background: #5c9442; margin: 0 auto; }
.controls {
position: absolute;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
display: grid;
grid-template-columns: repeat(3, 55px);
grid-template-rows: repeat(2, 55px);
gap: 10px;
}
.btn {
background: rgba(0,0,0,0.6);
border: 2px solid #fff;
border-radius: 50%;
color: #fff;
font-size: 22px;
display: flex;
justify-content: center;
align-items: center;
user-select: none;
}
.btn:active { background: #fff; color: #000; }
#up { grid-column: 2; grid-row: 1; }
#left { grid-column: 1; grid-row: 2; }
#down { grid-column: 2; grid-row: 2; }
#right { grid-column: 3; grid-row: 2; }
#info {
position: absolute;
top: 10px;
left: 10px;
background: rgba(0,0,0,0.7);
color: #fff;
padding: 6px 12px;
border-radius: 5px;
font-size: 14px;
}
</style>
</head>
<body>
<div id="info">π GTA 5 2D - Michael's Mansion</div>
<canvas id="game"></canvas>
<div class="controls">
<div class="btn" id="up">β²</div>
<div class="btn" id="left">β</div>
<div class="btn" id="down">βΌ</div>
<div class="btn" id="right">βΊ</div>
</div>
<script>
const canvas = document.getElementById('game');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
// Player (Michael)
const player = { x: canvas.width / 2, y: canvas.height - 120, size: 18, speed: 3.5 };
// Michael's House
const house = { x: canvas.width / 2 - 100, y: 50, w: 200, h: 120 };
const keys = { up: false, down: false, left: false, right: false };
function bind(id, k) {
const el = document.getElementById(id);
el.ontouchstart = (e) => { e.preventDefault(); keys[k] = true; };
el.ontouchend = (e) => { e.preventDefault(); keys[k] = false; };
el.onmousedown = () => keys[k] = true;
el.onmouseup = () => keys[k] = false;
}
bind('up', 'up'); bind('down', 'down'); bind('left', 'left'); bind('right', 'right');
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Road
ctx.fillStyle = '#333';
ctx.fillRect(0, canvas.height - 90, canvas.width, 50);
// Driveway
ctx.fillStyle = '#555';
ctx.fillRect(house.x + 70, house.y + house.h, 60, canvas.height - 90 - (house.y + house.h));
// Michael's House
ctx.fillStyle = '#e6d7b8';
ctx.fillRect(house.x, house.y, house.w, house.h);
ctx.strokeStyle = '#222';
ctx.lineWidth = 3;
ctx.strokeRect(house.x, house.y, house.w, house.h);
// Door & Windows
ctx.fillStyle = '#4a2e18';
ctx.fillRect(house.x + 80, house.y + house.h - 30, 40, 30);
ctx.fillStyle = '#7ec8e3';
ctx.fillRect(house.x + 20, house.y + 25, 35, 25);
ctx.fillRect(house.x + 145, house.y + 25, 35, 25);
// Pool
ctx.fillStyle = '#00aaff';
ctx.fillRect(house.x + house.w + 15, house.y + 20, 60, 80);
// Player (Michael - Red Shirt)
ctx.fillStyle = '#cc3333';
ctx.beginPath();
ctx.arc(player.x, player.y, player.size, 0, Math.PI * 2);
ctx.fill();
// Head
ctx.fillStyle = '#ffcc99';
ctx.beginPath();
ctx.arc(player.x, player.y, player.size * 0.5, 0, Math.PI * 2);
ctx.fill();
// Name Label
ctx.fillStyle = '#fff';
ctx.font = '12px Arial';
ctx.textAlign = 'center';
ctx.fillText('Michael', player.x, player.y - player.size - 4);
}
function update() {
if (keys.up && player.y - player.size > 0) player.y -= player.speed;
if (keys.down && player.y + player.size < canvas.height) player.y += player.speed;
if (keys.left && player.x - player.size > 0) player.x -= player.speed;
if (keys.right && player.x + player.size < canvas.width) player.x += player.speed;
}
function loop() {
draw();
update();
requestAnimationFrame(loop);
}
loop();
</script>
</body>
</html>
1
1
5KB
5KB
183.0ms
252.0ms
183.0ms