Crash Bandicoot: A Time Worth Saving
by ApexHawk57252 lines6.5 KB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Crash Bandicoot: A Time Worth Saving</title>
<style>
* { box-sizing:border-box; }
body {
margin:0; background:#101b29; color:white;
font-family:Arial,sans-serif; text-align:center;
overflow:hidden; touch-action:none;
}
h2 { margin:8px; font-size:19px; }
#game {
display:block; width:100%; max-width:900px;
height:auto; margin:auto; background:#253b43;
border:3px solid #d99b38;
}
#controls {
max-width:900px; margin:8px auto;
display:flex; justify-content:space-around;
gap:8px;
}
button {
font-size:23px; font-weight:bold;
border:2px solid #fff; border-radius:14px;
background:#e58b24; color:white;
padding:15px 20px; touch-action:none;
}
#status { font-size:14px; padding:5px; }
</style>
</head>
<body>
<h2>🍎 CRASH BANDICOOT: A TIME WORTH SAVING</h2>
<div id="status">Level 1: Eely Nice to Meet You | Wumpa: 0</div>
<canvas id="game" width="900" height="480"></canvas>
<div id="controls">
<button id="left">◀</button>
<button id="jump">JUMP</button>
<button id="spin">SPIN</button>
<button id="right">▶</button>
</div>
<script>
const canvas=document.getElementById("game");
const ctx=canvas.getContext("2d");
const status=document.getElementById("status");
let player={
x:100,y:330,vx:0,vy:0,w:38,h:58,
grounded:false,spin:0
};
let keys={left:false,right:false,jump:false,spin:false};
let fruit=0,score=0,level=0,health=3;
let camera=0,frame=0,won=false;
let bossHealth=3,bossWait=0;
let enemies=[
{x:420,y:390,type:"eel",alive:true},
{x:720,y:390,type:"croco",alive:true},
{x:1050,y:390,type:"croco",alive:true},
{x:1450,y:390,type:"eel",alive:true}
];
let crates=[
{x:300,y:390,type:"fruit"},
{x:540,y:390,type:"tnt"},
{x:900,y:390,type:"fruit"},
{x:1180,y:390,type:"nitro"},
{x:1550,y:390,type:"fruit"}
];
const ground=410;
function text(t,x,y,size=22,color="white"){
ctx.fillStyle=color;
ctx.font="bold "+size+"px Arial";
ctx.fillText(t,x,y);
}
function rect(x,y,w,h,color){
ctx.fillStyle=color;ctx.fillRect(x,y,w,h);
}
function circle(x,y,r,color){
ctx.fillStyle=color;ctx.beginPath();
ctx.arc(x,y,r,0,Math.PI*2);ctx.fill();
}
function bind(id,key){
let b=document.getElementById(id);
b.addEventListener("pointerdown",e=>{
e.preventDefault();keys[key]=true;
});
for(let event of ["pointerup","pointercancel","pointerleave"])
b.addEventListener(event,e=>{keys[key]=false;});
}
bind("left","left");
bind("right","right");
bind("jump","jump");
bind("spin","spin");
function resetPlayer(){
player.x=100;player.y=330;
player.vx=0;player.vy=0;
}
function drawBackground(){
let gradient=ctx.createLinearGradient(0,0,0,480);
gradient.addColorStop(0,"#244e60");
gradient.addColorStop(1,"#13242c");
ctx.fillStyle=gradient;ctx.fillRect(0,0,900,480);
for(let i=0;i<12;i++){
let x=((i*130-camera*.25)%1000+1000)%1000;
circle(x,80+(i%3)*60,8,"#7199a0");
}
// Sewer pipes
rect(0,120,900,22,"#788b91");
rect(0,145,900,8,"#c0d1d1");
rect(0,ground,900,70,"#46545a");
for(let x=0;x<900;x+=100){
rect(x,ground,4,70,"#829297");
}
// Water
rect(0,ground+12,900,15,"#168bc0");
}
function drawCrash(){
let x=player.x-camera,y=player.y;
// Shadow
circle(x+19,ground+5,22,"#15242a");
// Feet
rect(x+5,y+45,13,12,"#6e361d");
rect(x+23,y+45,13,12,"#6e361d");
// Body
rect(x+6,y+17,28,31,"#e47c24");
// Head
circle(x+19,y+13,18,"#ed9636");
// Ears
circle(x+4,y+2,7,"#ed9636");
circle(x+34,y+2,7,"#ed9636");
// Eyes
circle(x+13,y+10,4,"white");
circle(x+25,y+10,4,"white");
circle(x+14,y+10,2,"black");
circle(x+25,y+10,2,"black");
// Nose
circle(x+20,y+19,5,"#43251a");
rect(x+7,y+29,26,5,"#ffffff");
if(player.spin>0){
ctx.strokeStyle="#ffe34d";ctx.lineWidth=6;
ctx.beginPath();ctx.arc(x+19,y+28,34,0,Math.PI*2);ctx.stroke();
}
}
function drawEnemy(e){
let x=e.x-camera;
if(x< -80||x>980||!e.alive)return;
if(e.type==="eel"){
circle(x,ground-22,23,"#37d9bd");
circle(x-7,ground-27,4,"white");
circle(x-6,ground-27,2,"black");
text("⚡",x-10,ground-42,20);
}else{
rect(x-28,ground-28,58,28,"#428b43");
circle(x-17,ground-28,5,"white");
circle(x+12,ground-28,5,"white");
text("🐊",x-22,ground-34,28);
}
}
function drawCrate(c){
let x=c.x-camera;
if(x< -60||x>960)return;
let color=c.type==="fruit"?"#dc9d28":
c.type==="tnt"?"#c83d35":"#72c837";
rect(x-18,ground-36,36,36,color);
ctx.strokeStyle="#fff";ctx.lineWidth=3;
ctx.strokeRect(x-18,ground-36,36,36);
text(c.type==="fruit"?"🍎":c.type==="tnt"?"TNT":"!",x-14,ground-12,18);
}
function drawBoss(){
let x=player.x-camera+400;
rect(x-65,ground-110,130,110,"#a65b36");
circle(x,ground-125,49,"#b8784a");
circle(x-20,ground-135,8,"white");
circle(x+20,ground-135,8,"white");
text("MUCHO ROCKY",x-80,ground-195,20,"#ffdf60");
text("❤️ ".repeat(bossHealth),x-45,ground-160,20);
}
function update(){
if(won)return;
frame++;
player.vx=0;
if(keys.left)player.vx=-4;
if(keys.right)player.vx=4;
player.x+=player.vx;
if(keys.jump&&player.grounded){
player.vy=-13;player.grounded=false;
}
if(keys.spin)player.spin=12;
if(player.spin>0)player.spin--;
player.vy+=0.65;
player.y+=player.vy;
if(player.y+player.h>=ground){
player.y=ground-player.h;
player.vy=0;player.grounded=true;
}
player.x=Math.max(0,Math.min(2100,player.x));
camera=Math.max(0,Math.min(1200,player.x-300));
for(let c of crates){
if(Math.abs(player.x-c.x)<38&&Math.abs(player.y+player.h-ground)<55){
if(c.type==="fruit"){fruit++;c.type="gone";}
if(c.type==="tnt"||c.type==="nitro"){
health--;c.type="gone";
if(health<=0){resetPlayer();health=3;}
}
}
}
for(let e of enemies){
if(!e.alive)continue;
if(Math.abs(player.x-e.x)<38&&player.y+player.h>ground-55){
if(player.spin>0)e.alive=false;
else if(player.vy>2){player.vy=-9;}
else {player.x-=35;}
}
}
if(player.x>=1850)level=1;
if(level===1){
bossWait++;
if(player.spin>0&&bossWait>70&&Math.abs(player.x-2050)<150){
bossHealth--;bossWait=0;
if(bossHealth<=0)won=true;
}
}
status.textContent=level===0?
"Level 1: Eely Nice to Meet You | Wumpa: "+fruit+" | Health: "+health:
"BOSS: MUCHO ROCKY | Boss health: "+bossHealth;
}
function draw(){
drawBackground();
for(let e of enemies)drawEnemy(e);
for(let c of crates)if(c.type!=="gone")drawCrate(c);
drawCrash();
if(level===1)drawBoss();
if(won){
rect(0,0,900,480,"rgba(0,0,0,.8)");
text("YOU DEFEATED MUCHO ROCKY!",190,210,34,"#ffdb4b");
text("THE ADVENTURE CONTINUES!",230,260,26);
}
}
function loop(){
update();draw();requestAnimationFrame(loop);
}
loop();
</script>
</body>
</html>
Game Source: Crash Bandicoot: A Time Worth Saving
Creator: ApexHawk57
Libraries: none
Complexity: complex (252 lines, 6.5 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: crash-bandicoot-a-time-worth-saving-apexhawk57" to link back to the original. Then publish at arcadelab.ai/publish.