🎮ArcadeLab

Course Infinie

by AstroDolphin32
365 lines9.0 KB
▶ Play
<!DOCTYPE html>
<html lang="fr">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <title>Course Infinie</title>
  <style>
    @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@500;700;900&family=Rajdhani:wght@500;600;700&display=swap');

    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      -webkit-tap-highlight-color: transparent;
      user-select: none;
    }

    body {
      background: linear-gradient(160deg, #0a0a12 0%, #12121f 50%, #0d0d18 100%);
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      font-family: 'Rajdhani', system-ui, sans-serif;
      color: #fff;
      overflow: hidden;
      padding: 12px;
    }

    .header {
      text-align: center;
      margin-bottom: 14px;
    }

    .header h1 {
      font-family: 'Orbitron', sans-serif;
      font-weight: 900;
      font-size: clamp(1.6rem, 5vw, 2.2rem);
      letter-spacing: 4px;
      background: linear-gradient(90deg, #ffcc00, #ff9500, #ffcc00);
      background-size: 200% auto;
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      animation: shine 3s linear infinite;
      text-shadow: 0 0 30px rgba(255, 204, 0, 0.3);
    }

    @keyframes shine {
      to { background-position: 200% center; }
    }

    .header p {
      font-size: 0.95rem;
      color: #8a8aa3;
      margin-top: 4px;
      letter-spacing: 1px;
    }

    .game-wrapper {
      position: relative;
      border-radius: 16px;
      overflow: hidden;
      box-shadow:
        0 0 0 3px #2a2a3d,
        0 0 40px rgba(255, 180, 0, 0.15),
        0 25px 50px rgba(0, 0, 0, 0.6);
    }

    canvas {
      display: block;
      background: #1a1a28;
      max-width: 100%;
      height: auto;
    }

    .hud {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      padding: 14px 18px;
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      pointer-events: none;
      z-index: 10;
    }

    .hud-box {
      background: rgba(10, 10, 20, 0.7);
      backdrop-filter: blur(8px);
      border: 1px solid rgba(255, 204, 0, 0.25);
      border-radius: 10px;
      padding: 8px 14px;
      min-width: 90px;
      text-align: center;
    }

    .hud-label {
      font-size: 0.7rem;
      color: #8a8aa3;
      text-transform: uppercase;
      letter-spacing: 1.5px;
      margin-bottom: 2px;
    }

    .hud-value {
      font-family: 'Orbitron', sans-serif;
      font-weight: 700;
      font-size: 1.25rem;
      color: #ffcc00;
    }

    .overlay {
      position: absolute;
      inset: 0;
      background: rgba(8, 8, 16, 0.88);
      backdrop-filter: blur(6px);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      text-align: center;
      z-index: 20;
      padding: 24px;
      transition: opacity 0.3s;
    }

    .overlay.hidden {
      opacity: 0;
      pointer-events: none;
    }

    .overlay h2 {
      font-family: 'Orbitron', sans-serif;
      font-weight: 900;
      font-size: 2rem;
      color: #ffcc00;
      margin-bottom: 12px;
      letter-spacing: 2px;
    }

    .overlay p {
      font-size: 1.05rem;
      color: #b0b0c8;
      line-height: 1.5;
      max-width: 260px;
      margin-bottom: 8px;
    }

    .overlay .final-score {
      font-family: 'Orbitron', sans-serif;
      font-size: 1.6rem;
      color: #fff;
      margin: 12px 0 20px;
    }

    .btn {
      font-family: 'Orbitron', sans-serif;
      font-weight: 700;
      font-size: 1rem;
      letter-spacing: 2px;
      padding: 14px 40px;
      border: none;
      border-radius: 50px;
      cursor: pointer;
      background: linear-gradient(135deg, #ffcc00, #ff9500);
      color: #111;
      box-shadow: 0 6px 20px rgba(255, 150, 0, 0.4);
      transition: transform 0.15s, box-shadow 0.15s;
      text-transform: uppercase;
    }

    .btn:hover, .btn:active {
      transform: scale(1.06);
      box-shadow: 0 8px 28px rgba(255, 150, 0, 0.55);
    }

    .btn:active {
      transform: scale(0.97);
    }

    .controls {
      display: flex;
      gap: 20px;
      margin-top: 18px;
      width: 100%;
      max-width: 360px;
      justify-content: center;
    }

    .ctrl-btn {
      flex: 1;
      max-width: 140px;
      height: 70px;
      border: none;
      border-radius: 18px;
      font-family: 'Orbitron', sans-serif;
      font-weight: 700;
      font-size: 1.6rem;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: transform 0.1s, box-shadow 0.1s, background 0.1s;
      box-shadow: 0 6px 0 #1a1a28, 0 8px 20px rgba(0,0,0,0.4);
      position: relative;
      overflow: hidden;
    }

    .ctrl-btn::before {
      content: '';
      position: absolute;
      inset: 0;
      background: linear-gradient(180deg, rgba(255,255,255,0.15), transparent 50%);
      pointer-events: none;
    }

    .ctrl-left {
      background: linear-gradient(180deg, #3a3a55, #252538);
      color: #ffcc00;
      border: 2px solid #4a4a6a;
    }

    .ctrl-right {
      background: linear-gradient(180deg, #3a3a55, #252538);
      color: #ffcc00;
      border: 2px solid #4a4a6a;
    }

    .ctrl-btn:active,
    .ctrl-btn.active {
      transform: translateY(4px);
      box-shadow: 0 2px 0 #1a1a28, 0 4px 12px rgba(0,0,0,0.3);
      background: linear-gradient(180deg, #ffcc00, #e6a800);
      color: #111;
      border-color: #ffcc00;
    }

    .footer {
      margin-top: 14px;
      font-size: 0.8rem;
      color: #5a5a75;
      letter-spacing: 0.5px;
      text-align: center;
    }

    @media (max-width: 400px) {
      .controls { gap: 12px; }
      .ctrl-btn { height: 64px; font-size: 1.4rem; }
    }
  </style>
</head>
<body>

  <div class="header">
    <h1>COURSE INFINIE</h1>
    <p>Évite les voitures • Survives le plus longtemps</p>
  </div>

  <div class="game-wrapper">
    <canvas id="game" width="360" height="580"></canvas>

    <div class="hud">
      <div class="hud-box">
        <div class="hud-label">Score</div>
        <div class="hud-value" id="score">0</div>
      </div>
      <div class="hud-box">
        <div class="hud-label">Vitesse</div>
        <div class="hud-value" id="speed">1</div>
      </div>
    </div>

    <div class="overlay" id="overlay">
      <h2 id="overlay-title">COURSE INFINIE</h2>
      <p id="overlay-text">Utilise les flèches ou les boutons<br>pour changer de voie</p>
      <div class="final-score" id="final-score" style="display:none;"></div>
      <button class="btn" id="startBtn">JOUER</button>
    </div>
  </div>

  <div class="controls">
    <button class="ctrl-btn ctrl-left" id="btnLeft">◀</button>
    <button class="ctrl-btn ctrl-right" id="btnRight">▶</button>
  </div>

  <div class="footer">
    Flèches ← → ou A / D • Boutons ci-dessous
  </div>

  <script>
    const canvas = document.getElementById('game');
    const ctx = canvas.getContext('2d');
    const overlay = document.getElementById('overlay');
    const startBtn = document.getElementById('startBtn');
    const scoreEl = document.getElementById('score');
    const speedEl = document.getElementById('speed');
    const overlayTitle = document.getElementById('overlay-title');
    const overlayText = document.getElementById('overlay-text');
    const finalScoreEl = document.getElementById('final-score');
    const btnLeft = document.getElementById('btnLeft');
    const btnRight = document.getElementById('btnRight');

    const W = canvas.width;
    const H = canvas.height;
    const LANE_COUNT = 3;
    const LANE_WIDTH = (W - 40) / LANE_COUNT;
    const ROAD_MARGIN = 20;

    let running = false;
    let score = 0;
    let speed = 4;
    let roadOffset = 0;
    let player, enemies;
    let keys = {};

    function createPlayer() {
      return {
        x: W / 2,
        y: H - 100,
        w: 44,
        h: 72,
        color: '#ffcc00',
        targetLane: 1
      };
    }

    function createEnemy() {
      const lane = Math.floor(Math.random() * LANE_COUNT);
      const colors = ['#e74c3c', '#3498db', '#9b59b6', '#2ecc71', '#e67e22', '#1abc9c'];
      return {
        x: ROAD_MARGIN + lane * LANE_WIDTH + LANE_WIDTH / 2,
        y: -90 - Math.random() * 180,
        w: 44,
        h: 72,
        color: colors[Math.floor(Math.random() * colors.length)],
        lane
      };
    }

    function reset() {
      player = createPlayer();
      enemies = [];
      score = 0;
      speed = 4;
      roadOffset = 0;
      running = true;
      overlay.classList.add('hidden');
      scoreEl.textContent = '0';
      speedEl.textContent = '1';
      finalScoreEl.style.display = 'none';
    }

    function gameOver() {
      running = false;
      overlayTitle.textContent = 'CRASH !';
      overlayText.textContent = '';
      finalScoreEl.style.display = 'block';
      finalScoreEl.textContent = 'Score : ' + score;
      startBtn.textContent = 'REJOUER';
      overlay.classList.remove('hidden');
    }

Game Source: Course Infinie

Creator: AstroDolphin32

Libraries: none

Complexity: complex (365 lines, 9.0 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: course-infinie-astrodolphin32" to link back to the original. Then publish at arcadelab.ai/publish.