🎮ArcadeLab

F NAP

by BoldPenguin14
171 lines3.0 KB
▶ Play

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>F NAP</title>
<style>
body {
  margin:0;
  background:#090912;
  color:white;
  font-family:Arial;
  text-align:center;
}
h1 { color:#ff3333; }
#game {
  max-width:700px;
  margin:auto;
  padding:15px;
}
#room {
  background:linear-gradient(#15152b,#050508);
  height:300px;
  border:3px solid #555;
  position:relative;
  overflow:hidden;
}
#enemy {
  font-size:75px;
  position:absolute;
  top:100px;
  left:40%;
}
#message {
  color:#ff5555;
  font-size:20px;
  margin:15px;
}
button {
  background:#29294a;
  color:white;
  border:2px solid #777;
  padding:15px;
  margin:5px;
  border-radius:10px;
  font-size:16px;
}
button:active { background:#ff3333; }
#stats { font-size:20px; }
</style>
</head>
<body>
<div id="game">
<h1>F NAP 💤</h1>
<h3>FIVE NIGHTS AT PILLOW'S</h3>

<div id="stats">
  Time: <span id="time">12 AM</span>
  <br>
  Power: <span id="power">100</span>%
</div>

<div id="room">
  <div id="enemy">🐻</div>
</div>

<div id="message">Survive until 6 AM...</div>

<button onclick="door()">🚪 DOOR</button>
<button onclick="light()">🔦 LIGHT</button>
<button onclick="camera()">📹 CAMERA</button>
<br>
<button onclick="start()">▶ START GAME</button>
</div>

<script>
let hour=0;
let power=100;
let danger=0;
let running=false;
let doorClosed=false;
let lightOn=false;
let interval;

const enemy=document.getElementById("enemy");
const message=document.getElementById("message");

function start(){
  clearInterval(interval);
  hour=0;
  power=100;
  danger=0;
  running=true;
  doorClosed=false;
  update();

  message.textContent="It's midnight... good luck.";
  interval=setInterval(tick,3000);
}

function tick(){
  if(!running)return;

  hour++;
  power-=doorClosed?4:2;
  danger+=Math.random()*2;

  if(danger>5 && !doorClosed){
    message.textContent="SOMETHING IS GETTING CLOSER...";
  }

  if(danger>9 && !doorClosed){
    lose("FREDDY GOT YOU! 🐻");
    return;
  }

  if(power<=0){
    power=0;
    lose("POWER OUT! 😱");
    return;
  }

  if(hour>=6){
    running=false;
    clearInterval(interval);
    message.textContent="6 AM! YOU SURVIVED! 🎉";
  }
  update();
}

function door(){
  if(!running)return;
  doorClosed=!doorClosed;
  message.textContent=doorClosed?
    "DOOR CLOSED 🔒":"DOOR OPEN";
}

function light(){
  if(!running)return;
  lightOn=!lightOn;
  enemy.style.opacity=lightOn?1:0.2;
  message.textContent=lightOn?
    "YOU SEE SOMETHING... 👀":"LIGHT OFF";
}

function camera(){
  if(!running)return;
  message.textContent="CAMERA: Bonnie is in the hallway! 🐰";
}

function update(){
  document.getElementById("time").textContent=
    hour===0?"12 AM":hour+" AM";
  document.getElementById("power").textContent=power;
}

function lose(text){
  running=false;
  clearInterval(interval);
  message.textContent=text+" GAME OVER 💀";
}

document.addEventListener("keydown",e=>{
  if(e.key===" " ) door();
  if(e.key.toLowerCase()==="f") light();
  if(e.key.toLowerCase()==="c") camera();
});
</script>
</body>
</html>

Game Source: F NAP

Creator: BoldPenguin14

Libraries: none

Complexity: moderate (171 lines, 3.0 KB)

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