🎮ArcadeLab

NEON RUNNER

by ChromeFlame24
185 lines3.5 KB
▶ Play

<!DOCTYPE html>
<html lang="ar">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>NEON RUNNER</title>
<style>
* { box-sizing:border-box; }
body {
  margin:0;
  background:#080817;
  color:white;
  font-family:Arial;
  text-align:center;
}
h1 { color:#00eaff; text-shadow:0 0 15px #00eaff; }
canvas {
  background:linear-gradient(#111133,#080817);
  border:2px solid #00eaff;
  border-radius:12px;
  max-width:95%;
}
button {
  background:#00d9ff;
  color:#050515;
  border:0;
  border-radius:10px;
  padding:14px 28px;
  margin:12px;
  font-size:18px;
  font-weight:bold;
}
</style>
</head>
<body>

<h1>⚡ NEON RUNNER</h1>
<p>النقاط: <span id="score">0</span></p>
<canvas id="game" width="800" height="400"></canvas>
<br>
<button onclick="jump()">اقفز 🚀</button>
<button onclick="restart()">إعادة اللعب</button>
<p>اضغط على الشاشة أو زر المسافة للقفز</p>

<script>
const canvas = document.getElementById("game");
const ctx = canvas.getContext("2d");

let player, obstacles, score, speed, gameOver, frame;

function restart() {
  player = {x:90,y:300,w:35,h:45,vy:0};
  obstacles = [];
  score = 0;
  speed = 6;
  gameOver = false;
  frame = 0;
}

function jump() {
  if (gameOver) {
    restart();
    return;
  }
  if (player.y >= 300) {
    player.vy = -13;
  }
}

document.addEventListener("keydown", e => {
  if (e.code === "Space" || e.code === "ArrowUp") {
    e.preventDefault();
    jump();
  }
});
canvas.addEventListener("touchstart", e => {
  e.preventDefault();
  jump();
});

function drawPlayer() {
  ctx.shadowBlur = 20;
  ctx.shadowColor = "#00eaff";
  ctx.fillStyle = "#00eaff";
  ctx.fillRect(player.x,player.y,player.w,player.h);
  ctx.fillStyle = "white";
  ctx.fillRect(player.x+22,player.y+9,7,7);
  ctx.shadowBlur = 0;
}

function update() {
  if (!gameOver) {
    frame++;
    player.vy += 0.7;
    player.y += player.vy;

    if (player.y > 300) {
      player.y = 300;
      player.vy = 0;
    }

    if (frame % 85 === 0) {
      obstacles.push({
        x:800,
        y:310,
        w:25,
        h:35 + Math.random()*30
      });
    }

    obstacles.forEach(o => {
      o.x -= speed;

      if (
        player.x < o.x+o.w &&
        player.x+player.w > o.x &&
        player.y < o.y+o.h &&
        player.y+player.h > o.y
      ) gameOver = true;
    });

    obstacles = obstacles.filter(o => o.x > -50);
    score++;
    speed = 6 + score/1000;
    document.getElementById("score").textContent =
      Math.floor(score/10);
  }
}

function draw() {
  ctx.clearRect(0,0,800,400);

  // الأرض
  ctx.fillStyle = "#25255a";
  ctx.fillRect(0,345,800,55);

  ctx.strokeStyle = "#00eaff";
  ctx.lineWidth = 3;
  ctx.beginPath();
  ctx.moveTo(0,345);
  ctx.lineTo(800,345);
  ctx.stroke();

  // النجوم
  ctx.fillStyle = "white";
  for(let i=0;i<35;i++){
    let x=(i*137-frame*0.3)%800;
    if(x<0)x+=800;
    let y=(i*67)%300;
    ctx.fillRect(x,y,2,2);
  }

  drawPlayer();

  // العقبات
  ctx.shadowBlur = 15;
  ctx.shadowColor = "#ff00bb";
  ctx.fillStyle = "#ff00bb";
  obstacles.forEach(o => {
    ctx.fillRect(o.x,o.y,o.w,o.h);
  });
  ctx.shadowBlur = 0;

  if(gameOver){
    ctx.fillStyle = "white";
    ctx.font = "bold 42px Arial";
    ctx.textAlign = "center";
    ctx.fillText("GAME OVER",400,170);
    ctx.font = "22px Arial";
    ctx.fillText("اضغط إعادة اللعب",400,215);
  }
}

function loop(){
  update();
  draw();
  requestAnimationFrame(loop);
}

restart();
loop();
</script>
</body>
</html>

Game Source: NEON RUNNER

Creator: ChromeFlame24

Libraries: none

Complexity: moderate (185 lines, 3.5 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: loom-chromeflame24-mwmg13wx" to link back to the original. Then publish at arcadelab.ai/publish.