Meta Description" name="description" />
<html>
<head>
<meta charset="UTF-8">
<title>Sky Drop Mini Game</title>
<style>
body { margin: 0; background: #87ceeb; overflow: hidden; }
canvas { display: block; margin: 0 auto; background: #87ceeb; }
</style>
</head>
<body>
<canvas id="game" width="800" height="450"></canvas>
<script>
const canvas = document.getElementById("game");
const ctx = canvas.getContext("2d");
// Player
const player = {
x: 380,
y: 80,
w: 30,
h: 40,
vx: 0,
vy: 0,
onGround: false,
jumped: false
};
// Plane
let planeX = -100;
// Physics
const gravity = 0.6;
const groundY = 380;
// Input
const keys = {};
document.addEventListener("keydown", e => keys[e.code] = true);
document.addEventListener("keyup", e => keys[e.code] = false);
function update() {
// Move plane
planeX += 2;
if (planeX > canvas.width + 100) planeX = -100;
// Jump from plane
if (keys["Space"] && !player.jumped) {
player.vy = 0;
player.jumped = true;
}
// Left / Right
if (keys["ArrowLeft"]) player.vx = -3;
else if (keys["ArrowRight"]) player.vx = 3;
else player.vx = 0;
// Gravity
if (player.jumped) {
player.vy += gravity;
player.y += player.vy;
player.x += player.vx;
}
// Ground collision
if (player.y + player.h >= groundY) {
player.y = groundY - player.h;
player.vy = 0;
player.onGround = true;
} else {
player.onGround = false;
}
}
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Ground
ctx.fillStyle = "#4caf50";
ctx.fillRect(0, groundY, canvas.width, canvas.height - groundY);
// Plane
ctx.fillStyle = "#555";
ctx.fillRect(planeX, 60, 120, 30);
ctx.fillRect(planeX + 90, 40, 20, 20);
// Player (simple character)
ctx.fillStyle = "#ff5722";
ctx.fillRect(player.x, player.y, player.w, player.h);
// Text
ctx.fillStyle = "#000";
ctx.font = "16px Arial";
ctx.fillText("Press SPACE to jump from the plane", 20, 30);
ctx.fillText("Use ← → to move", 20, 50);
}
function loop() {
update();
draw();
requestAnimationFrame(loop);
}
loop();
</script>
</body>
</html>1
1
2KB
2KB
398.0ms
492.0ms
399.0ms