🎮ArcadeLab

小兔快跑

by FrostViper30
28 lines991 bytes
▶ Play
<!DOCTYPE html>
 <html lang="zh-CN">
 <head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <title>小兔快跑</title>
 <style>
 *{margin:0;padding:0;box-sizing:border-box}
 body{background:#eef7ff;display:flex;flex-direction:column;align-items:center;padding:15px;font-family:Arial}
 #gameCanvas{border:2px solid #348ede;background:white}
 .score-text{font-size:20px;margin-bottom:8px;color:#222}
 </style>
 </head>
 <body>
 <div class="score-text">分数:<span id="scoreNum">0</span></div>
 <canvas id="gameCanvas" width="380" height="220"></canvas>
 <script>
 const canvas=document.getElementById('gameCanvas');
 const ctx=canvas.getContext('2d');
 const scoreDom=document.getElementById('scoreNum');
 const rabbit={x:40,y:150,w:30,h:30,vy:0,jumpPower:-9,onGround:true}
 let gravity=0.45;
 let obstacles=[];
 let speed=4;
 let score=0;
 let gameOver=false;
 function spawnObstacle(){
   obstacles.push({x:canvas.width,y:174,w:24,h:24})

Game Source: 小兔快跑

Creator: FrostViper30

Libraries: none

Complexity: simple (28 lines, 991 bytes)

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: game-frostviper30" to link back to the original. Then publish at arcadelab.ai/publish.