THE FORBIDDEN CHEESE
by BoldPenguin14341 lines5.7 KB
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>THE FORBIDDEN CHEESE</title>
<style>
* { box-sizing:border-box; }
body {
margin:0;
background:#191225;
color:white;
font-family:Arial;
text-align:center;
overflow-x:hidden;
overflow-y:auto;
}
h1 { color:#ff8bd6; font-size:25px; }
#game {
position:relative;
height:65vh;
min-height:380px;
margin:10px;
border:4px solid #ff8bd6;
border-radius:15px;
overflow:hidden;
background:linear-gradient(#a8d7ff 0%,#d7b5ff 65%,#c18d69 65%);
touch-action:none;
}
#world {
position:absolute;
inset:0;
transform:translateX(0);
}
#sun {
position:absolute;
top:15px;
right:20px;
font-size:40px;
}
#enemy {
position:absolute;
top:35%;
left:60%;
font-size:65px;
transition:transform .15s;
}
#cheese {
position:absolute;
top:62%;
left:75%;
font-size:40px;
}
#floor {
position:absolute;
bottom:0;
height:35%;
width:100%;
background:repeating-linear-gradient(
90deg,#d4a16e 0 70px,#e8b984 70px 140px
);
}
#player {
position:absolute;
bottom:10px;
left:50%;
transform:translateX(-50%);
font-size:45px;
z-index:5;
}
#joystick {
position:absolute;
bottom:15px;
left:15px;
width:125px;
height:125px;
border-radius:50%;
background:#ffffff44;
border:3px solid #fff9;
z-index:10;
touch-action:none;
}
#stick {
position:absolute;
width:55px;
height:55px;
border-radius:50%;
background:#ff8bd6;
border:3px solid white;
left:32px;
top:32px;
pointer-events:none;
}
#look {
position:absolute;
bottom:15px;
right:15px;
color:#fff;
background:#30213eaa;
padding:12px;
border-radius:12px;
font-size:12px;
}
.section {
background:#30213e;
margin:15px;
padding:20px;
border-radius:15px;
}
button {
border:0;
padding:12px 20px;
border-radius:12px;
background:#ff8bd6;
font-size:18px;
}
#message { color:#ffe18a; }
</style>
</head>
<body>
<h1>💀 THE FORBIDDEN CHEESE</h1>
<p>Find the cheese. Don't trust the potato.</p>
<div id="game">
<div id="world">
<div id="sun">☀️</div>
<div id="floor"></div>
<div id="enemy">🥔</div>
<div id="cheese">🧀</div>
<div id="player">🧍</div>
</div>
<div id="joystick">
<div id="stick"></div>
</div>
<div id="look">🕹️ MOVE</div>
</div>
<h2>🧀 Cheese: <span id="score">0</span>/5</h2>
<h3 id="message">The potato is watching you.</h3>
<div class="section">
<h2>HOW TO PLAY</h2>
<p>🕹️ Drag the joystick to move.</p>
<p>🧀 Find the cheese.</p>
<p>🥔 Avoid the potato.</p>
</div>
<div class="section">
<h2>ENEMIES</h2>
<h1>🥔</h1>
<p>EVIL POTATO: Has no brain cells.</p>
<h1>🦆</h1>
<p>THE DUCK: Screams at walls.</p>
<h1>👵</h1>
<p>GRANDMA: Armed with a slipper.</p>
</div>
<div class="section">
<button onclick="restart()">🔄 RESTART GAME</button>
</div>
<script>
const joystick = document.getElementById("joystick");
const stick = document.getElementById("stick");
const player = document.getElementById("player");
const enemy = document.getElementById("enemy");
const cheese = document.getElementById("cheese");
const world = document.getElementById("world");
const message = document.getElementById("message");
let score = 0;
let px = 50;
let py = 50;
let ex = 75;
let ey = 35;
let dx = 0;
let dy = 0;
let active = false;
let playing = true;
let last = 0;
function joystickMove(e) {
const rect = joystick.getBoundingClientRect();
let cx = rect.left + rect.width/2;
let cy = rect.top + rect.height/2;
let x = e.clientX - cx;
let y = e.clientY - cy;
const max = 35;
const distance = Math.hypot(x,y);
if(distance > max) {
x = x/distance*max;
y = y/distance*max;
}
stick.style.left = (35+x)+"px";
stick.style.top = (35+y)+"px";
dx = x/max;
dy = y/max;
}
joystick.addEventListener("pointerdown",e=>{
active=true;
joystick.setPointerCapture(e.pointerId);
joystickMove(e);
});
joystick.addEventListener("pointermove",e=>{
if(active) joystickMove(e);
});
function stopJoystick(){
active=false;
dx=0;
dy=0;
stick.style.left="32px";
stick.style.top="32px";
}
joystick.addEventListener("pointerup",stopJoystick);
joystick.addEventListener("pointercancel",stopJoystick);
function randomCheese(){
cheese.style.left=(10+Math.random()*75)+"%";
cheese.style.top=(35+Math.random()*40)+"%";
}
function update(time){
if(!playing){
requestAnimationFrame(update);
return;
}
let dt = Math.min((time-last)/16.67 || 1,2);
last=time;
// Player movement
px += dx*0.65*dt;
py += dy*0.65*dt;
px=Math.max(5,Math.min(95,px));
py=Math.max(15,Math.min(90,py));
player.style.left=px+"%";
player.style.bottom=(10+(90-py)*1.5)+"px";
// Potato movement
let distanceX=px-ex;
let distanceY=py-ey;
let distance=Math.hypot(distanceX,distanceY);
if(distance>0.1){
ex += distanceX/distance*0.10*dt;
ey += distanceY/distance*0.10*dt;
}
enemy.style.left=ex+"%";
enemy.style.top=ey+"%";
// Collect cheese
let cheeseX=parseFloat(cheese.style.left);
let cheeseY=parseFloat(cheese.style.top);
if(Math.abs(px-cheeseX)<7 &&
Math.abs(py-cheeseY)<12){
score++;
document.getElementById("score").textContent=score;
randomCheese();
message.textContent="🧀 CHEESE ACQUIRED. LEGENDARY.";
}
// Potato catches player
if(distance<7){
message.textContent="🥔 THE POTATO BONKED YOU!";
ex=85;
ey=20;
}
if(score>=5){
playing=false;
message.textContent="🏆 YOU SAVED THE CHEESE! GRANDMA IS PROUD.";
enemy.textContent="👵";
}
requestAnimationFrame(update);
}
function restart(){
score=0;
px=50;
py=50;
ex=75;
ey=35;
playing=true;
last=0;
document.getElementById("score").textContent=0;
enemy.textContent="🥔";
message.textContent="The potato is watching you.";
randomCheese();
}
randomCheese();
requestAnimationFrame(update);
</script>
</body>
</html>
Game Source: THE FORBIDDEN CHEESE
Creator: BoldPenguin14
Libraries: none
Complexity: complex (341 lines, 5.7 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: the-forbidden-cheese-boldpenguin14" to link back to the original. Then publish at arcadelab.ai/publish.