html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!DOCTYPE html>
<html lang="en">
<head>
<html></html>
<html name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Endless Runner</title>
<style>
body { margin: 0; overflow: hidden; background: #70c5ce; }
canvas { display: block; margin: auto; background: #f7f7f7; }
</style>
</head>
<body>
<canvas id="gameCanvas"></canvas>
<script>
const canvas = document.getElementById("gameCanvas");
const ctx = canvas.getContext("2d");
// Adjust canvas size
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
// Game variables
let player = { x: 50, y: canvas.height - 150, width: 50, height: 50, color: "red", dy: 0, jump: false };
let gravity = 0.8;
let obstacles = [];
let score = 0;
let gameOver = false;
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
body {
}
Enter to Rename, Shift+Enter to Preview
js
js
1
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run