Professional Documents
Culture Documents
!DOCTYPE HTML
!DOCTYPE HTML
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Subway Surfer Clone</title>
<style>
body {
margin: 0;
overflow: hidden;
}
canvas {
display: block;
}
</style>
</head>
<body>
<canvas id="gameCanvas" width="800" height="400"></canvas>
<script>
// Get the canvas and context
const canvas = document.getElementById('gameCanvas');
const ctx = canvas.getContext('2d');
// Player
const player = {
x: 50,
y: canvas.height / 2,
width: 50,
height: 50,
color: 'blue',
speed: 5
};
// Game loop
function gameLoop() {
// Update
update();
// Draw
draw();
// Update function
function update() {