🎮ArcadeLab

Grand Theft Auto VI — Playable Web Demo

by GlitchPanther20
379 lines10.1 KB
▶ Play
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Grand Theft Auto VI — Playable Web Demo</title>
  <style>
    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    body {
      font-family: system-ui, -apple-system, sans-serif;
      background: linear-gradient(135deg, #1a0b2e 0%, #ff4e88 55%, #ff9a3c 100%);
      color: #ffffff;
      min-height: 100vh;
      overflow: hidden;
    }

    /* Landing Screen */
    #landing {
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      text-align: center;
      padding: 2rem;
    }

    .badge {
      font-size: 0.85rem;
      letter-spacing: 0.2em;
      text-transform: uppercase;
      background: rgba(0, 0, 0, 0.35);
      padding: 0.4rem 1rem;
      border-radius: 999px;
      margin-bottom: 1.25rem;
    }

    h1 {
      font-size: clamp(2.5rem, 8vw, 5.5rem);
      line-height: 1;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      text-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
      margin-bottom: 1rem;
    }

    p {
      max-width: 34rem;
      font-size: 1.1rem;
      line-height: 1.6;
      margin-bottom: 2rem;
      color: rgba(255, 255, 255, 0.92);
    }

    .cta-btn {
      border: none;
      cursor: pointer;
      color: #1a0b2e;
      background: #ffffff;
      font-size: 1rem;
      font-weight: 700;
      padding: 0.9rem 2.2rem;
      border-radius: 6px;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .cta-btn:hover {
      transform: translateY(-2px);
      box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    }

    /* Game Screen */
    #game-container {
      display: none;
      position: relative;
      width: 100vw;
      height: 100vh;
      background: #14141c;
    }

    canvas {
      display: block;
      width: 100%;
      height: 100%;
    }

    /* GTA Style HUD */
    .hud {
      position: absolute;
      top: 20px;
      right: 24px;
      text-align: right;
      font-weight: 800;
      text-shadow: 2px 2px 0 #000;
      pointer-events: none;
    }

    .money {
      font-size: 2rem;
      color: #57d163;
    }

    .wanted {
      font-size: 1.4rem;
      color: #ffd166;
      letter-spacing: 4px;
      margin-top: 4px;
    }

    .controls-hint {
      position: absolute;
      bottom: 20px;
      left: 24px;
      background: rgba(0, 0, 0, 0.65);
      padding: 0.65rem 1rem;
      border-radius: 6px;
      font-size: 0.9rem;
      color: #eee;
      pointer-events: none;
    }

    .exit-btn {
      position: absolute;
      top: 20px;
      left: 24px;
      background: rgba(0, 0, 0, 0.65);
      color: #fff;
      border: 1px solid rgba(255, 255, 255, 0.3);
      padding: 0.5rem 1rem;
      border-radius: 6px;
      cursor: pointer;
      font-weight: 600;
    }

    .exit-btn:hover {
      background: rgba(255, 78, 136, 0.85);
    }
  </style>
</head>
<body>

  <!-- Landing Page -->
  <div id="landing">
    <span class="badge">Leonida • Vice City</span>
    <h1>Grand Theft Auto VI</h1>
    <p>Explore sun-soaked streets, neon nights, and high-stakes action. Click below to drop straight into the streets.</p>
    <button id="explore-btn" class="cta-btn">Explore</button>
  </div>

  <!-- Playable Game Screen -->
  <div id="game-container">
    <button id="exit-btn" class="exit-btn">← Menu</button>
    <div class="hud">
      <div class="money" id="cash-display">$00000500</div>
      <div class="wanted" id="wanted-display">★☆☆☆☆</div>
    </div>
    <div class="controls-hint">
      <strong>Controls:</strong> W A S D or Arrow Keys to Drive • Collect neon cash pickups • Dodge police!
    </div>
    <canvas id="gameCanvas"></canvas>
  </div>

  <script>
    const landing = document.getElementById('landing');
    const gameContainer = document.getElementById('game-container');
    const exploreBtn = document.getElementById('explore-btn');
    const exitBtn = document.getElementById('exit-btn');
    const canvas = document.getElementById('gameCanvas');
    const ctx = canvas.getContext('2d');
    const cashDisplay = document.getElementById('cash-display');
    const wantedDisplay = document.getElementById('wanted-display');

    let animationId;
    let keys = {};
    let cash = 500;
    let wantedLevel = 1;

    // Player Car
    const car = {
      x: 400,
      y: 300,
      width: 24,
      height: 44,
      angle: 0,
      speed: 0,
      maxSpeed: 6,
      accel: 0.2,
      friction: 0.96
    };

    // Collectible Cash & Police
    let pickups = [];
    let cop = { x: 100, y: 100, speed: 2.3 };

    function resizeCanvas() {
      canvas.width = window.innerWidth;
      canvas.height = window.innerHeight;
    }
    window.addEventListener('resize', resizeCanvas);

    window.addEventListener('keydown', (e) => { keys[e.key.toLowerCase()] = true; });
    window.addEventListener('keyup', (e) => { keys[e.key.toLowerCase()] = false; });

    function spawnPickup() {
      pickups.push({
        x: Math.random() * (canvas.width - 80) + 40,
        y: Math.random() * (canvas.height - 80) + 40,
        size: 12
      });
    }

    function updateHUD() {
      cashDisplay.textContent = '$' + String(cash).padStart(8, '0');
      wantedDisplay.textContent = '★'.repeat(wantedLevel) + '☆'.repeat(5 - wantedLevel);
    }

    function spawnIntoGame() {
      landing.style.display = 'none';
      gameContainer.style.display = 'block';
      resizeCanvas();

      // Reset position & state
      car.x = canvas.width / 2;
      car.y = canvas.height / 2;
      car.speed = 0;
      car.angle = 0;
      cash = 500;
      wantedLevel = 1;
      cop = { x: 80, y: 80, speed: 2.2 };
      pickups = [];
      for (let i = 0; i < 5; i++) spawnPickup();
      updateHUD();

      gameLoop();
    }

    function exitToMenu() {
      cancelAnimationFrame(animationId);
      gameContainer.style.display = 'none';
      landing.style.display = 'flex';
    }

    exploreBtn.addEventListener('click', spawnIntoGame);
    exitBtn.addEventListener('click', exitToMenu);

    function drawCityGrid() {
      // Dark asphalt background
      ctx.fillStyle = '#1b1b26';
      ctx.fillRect(0, 0, canvas.width, canvas.height);

      // Neon Vice City street grid
      ctx.strokeStyle = '#2d2d44';
      ctx.lineWidth = 40;
      const gridSize = 220;

      for (let x = 0; x < canvas.width; x += gridSize) {
        ctx.beginPath();
        ctx.moveTo(x, 0);
        ctx.lineTo(x, canvas.height);
        ctx.stroke();
      }
      for (let y = 0; y < canvas.height; y += gridSize) {
        ctx.beginPath();
        ctx.moveTo(0, y);
        ctx.lineTo(canvas.width, y);
        ctx.stroke();
      }

      // Dashed yellow road lines
      ctx.strokeStyle = '#ffd166';
      ctx.lineWidth = 2;
      ctx.setLineDash([12, 12]);
      for (let x = 0; x < canvas.width; x += gridSize) {
        ctx.beginPath();
        ctx.moveTo(x, 0);
        ctx.lineTo(x, canvas.height);
        ctx.stroke();
      }
      for (let y = 0; y < canvas.height; y += gridSize) {
        ctx.beginPath();
        ctx.moveTo(0, y);
        ctx.lineTo(canvas.width, y);
        ctx.stroke();
      }
      ctx.setLineDash([]);
    }

    function update() {
      // Acceleration & Braking
      if (keys['w'] || keys['arrowup']) car.speed += car.accel;
      if (keys['s'] || keys['arrowdown']) car.speed -= car.accel;

      // Clamp speed & apply friction
      car.speed = Math.max(-car.maxSpeed / 2, Math.min(car.maxSpeed, car.speed));
      car.speed *= car.friction;

      // Steering (only when moving)
      if (Math.abs(car.speed) > 0.1) {
        const dir = car.speed > 0 ? 1 : -1;
        if (keys['a'] || keys['arrowleft']) car.angle -= 0.055 * dir;
        if (keys['d'] || keys['arrowright']) car.angle += 0.055 * dir;
      }

      // Move car
      car.x += Math.sin(car.angle) * car.speed;
      car.y -= Math.cos(car.angle) * car.speed;

      // Keep car on screen
      car.x = Math.max(20, Math.min(canvas.width - 20, car.x));
      car.y = Math.max(20, Math.min(canvas.height - 20, car.y));

      // Check cash pickups
      for (let i = pickups.length - 1; i >= 0; i--) {
        const p = pickups[i];
        const dist = Math.hypot(car.x - p.x, car.y - p.y);
        if (dist < 28) {
          pickups.splice(i, 1);
          cash += 250;
          if (cash % 1000 === 0 && wantedLevel < 5) {
            wantedLevel++;
            cop.speed += 0.35;
          }
          updateHUD();
          spawnPickup();
        }
      }

      // Move police car toward player
      const dx = car.x - cop.x;
      const dy = car.y - cop.y;
      const copAngle = Math.atan2(dy, dx);
      cop.x += Math.cos(copAngle) * cop.speed;
      cop.y += Math.sin(copAngle) * cop.speed;

      // Busted check
      if (Math.hypot(car.x - cop.x, car.y - cop.y) < 28) {
        alert('BUSTED! Final Cash: $' + cash);
        keys = {};
        spawnIntoGame();
      }
    }

    function draw() {
      drawCityGrid();

      // Draw Cash Pickups
      pickups.forEach((p) => {
        ctx.fillStyle = '#57d163';
        ctx.shadowColor = '#57d163';
        ctx.shadowBlur = 12;
        ctx.beginPath();
        ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
        ctx.fill();
        ctx.shadowBlur = 0;
      });

      // Draw Police Car
      ctx.save();
      ctx.translate(cop.x, cop.y);
      ctx.fillStyle = '#ffffff';
      ctx.fillRect(-12, -20, 24, 40);
      // Flashing red/blue siren
      ctx.fillStyle = Math.floor(Date.now() / 150) % 2 === 0 ? '#ff2a55' : '#00a8ff';
      ctx.fillRect(-10, -4, 20, 8);
      ctx.restore();

      // Draw Player Sports Car (Neon Pink)
      ctx.save();
      ctx.translate(car.x, car.y);
      ctx.rotate(car.angle);
      ctx.fillStyle = '#ff4e88';

Game Source: Grand Theft Auto VI — Playable Web Demo

Creator: GlitchPanther20

Libraries: none

Complexity: complex (379 lines, 10.1 KB)

The full source code is displayed above on this page.

Remix Instructions

To remix this game, copy the source code above and modify it. Add a ARCADELAB header at the top with "remix_of: grand-theft-auto-vi-playable-web-demo-glitchpanther20" to link back to the original. Then publish at arcadelab.ai/publish.