Skip to content

Instantly share code, notes, and snippets.

@landengut0-cmd
Created February 27, 2026 07:56
Show Gist options
  • Select an option

  • Save landengut0-cmd/9a1f3bff189849a81f77d34bc03d4fac to your computer and use it in GitHub Desktop.

Select an option

Save landengut0-cmd/9a1f3bff189849a81f77d34bc03d4fac to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FNAF 2 Prototype</title>
<style>
body {
margin: 0;
overflow: hidden;
background: black;
font-family: Arial;
}
#game {
background: #111;
display: block;
}
#ui {
position: absolute;
top: 10px;
left: 10px;
color: white;
}
button {
position: absolute;
width: 60px;
height: 60px;
opacity: 0.5;
font-size: 20px;
}
#up { bottom: 140px; left: 80px; }
#down { bottom: 20px; left: 80px; }
#left { bottom: 80px; left: 20px; }
#right { bottom: 80px; left: 140px; }
</style>
</head>
<body>
<canvas id="game"></canvas>
<div id="ui">
<h3>FNAF 2: Prototype</h3>
<p>Objective: Break into Dave Miller's house and find secrets.</p>
<p id="status"></p>
</div>
<button id="up">↑</button>
<button id="down">↓</button>
<button id="left">←</button>
<button id="right">→</button>
<script>
const canvas = document.getElementById("game");
const ctx = canvas.getContext("2d");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
let player = { x: 50, y: 50, size: 20, speed: 3 };
let dave = { x: 300, y: 200, size: 25, speed: 1.5 };
let house = { x: 400, y: 100, width: 150, height: 150 };
let insideHouse = false;
let foundSecret = false;
let keys = {};
function drawPlayer() {
ctx.fillStyle = "cyan";
ctx.fillRect(player.x, player.y, player.size, player.size);
}
function drawDave() {
ctx.fillStyle = "red";
ctx.fillRect(dave.x, dave.y, dave.size, dave.size);
}
function drawHouse() {
ctx.fillStyle = "gray";
ctx.fillRect(house.x, house.y, house.width, house.height);
}
function update() {
if(keys["up"]) player.y -= player.speed;
if(keys["down"]) player.y += player.speed;
if(keys["left"]) player.x -= player.speed;
if(keys["right"]) player.x += player.speed;
// Dave AI - simple follow
let dx = player.x - dave.x;
let dy = player.y - dave.y;
let distance = Math.sqrt(dx*dx + dy*dy);
if(distance < 200) {
dave.x += dx / distance * dave.speed;
dave.y += dy / distance * dave.speed;
}
// If caught
if(distance < 20) {
document.getElementById("status").innerText = "YOU GOT CAUGHT!";
}
// Enter house
if(player.x > house.x &&
player.x < house.x + house.width &&
player.y > house.y &&
player.y < house.y + house.height) {
insideHouse = true;
document.getElementById("status").innerText = "Inside the house... Find the secret!";
}
// Find secret
if(insideHouse && player.x > house.x + 50 && player.y > house.y + 50) {
foundSecret = true;
document.getElementById("status").innerText = "You found the secret files!";
}
}
function draw() {
ctx.clearRect(0,0,canvas.width,canvas.height);
drawHouse();
drawPlayer();
drawDave();
}
function gameLoop() {
update();
draw();
requestAnimationFrame(gameLoop);
}
gameLoop();
// Touch controls
document.getElementById("up").ontouchstart = () => keys["up"] = true;
document.getElementById("up").ontouchend = () => keys["up"] = false;
document.getElementById("down").ontouchstart = () => keys["down"] = true;
document.getElementById("down").ontouchend = () => keys["down"] = false;
document.getElementById("left").ontouchstart = () => keys["left"] = true;
document.getElementById("left").ontouchend = () => keys["left"] = false;
document.getElementById("right").ontouchstart = () => keys["right"] = true;
document.getElementById("right").ontouchend = () => keys["right"] = false;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment