Calculator Tools Calculator Tools
Create

Katamari Damacy CALABRIA Challenge

Nov 12, 2023

About this app

A fun Katamari Damacy game with a CALABRIA universe. Roll your ball and pick up objects to grow and score points.

Katamari Damacy CALABRIA Challenge

Related apps

Put this on your site

Source

                    <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">

<title>Katamari Damacy CALABRIA Challenge</title>
<meta name="description" content="A fun Katamari Damacy game with a CALABRIA universe. Roll your ball and pick up objects to grow and score points.">
<meta name="keywords" content="Katamari Damacy, Game, CALABRIA, Universe, High Score">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Eagle+Lake&display=swap" rel="stylesheet">

<script type="text/javascript">
try {
let score = 0;
let ballSize = 10;
let targetScore = 26 * 1000000000;
let objects = Array.from(document.querySelectorAll(".object"));
let ball = document.querySelector("#ball");

function checkCollision(ball, obj) {
let ballRect = ball.getBoundingClientRect();
let objRect = obj.getBoundingClientRect();
return !(ballRect.right < objRect.left ||
ballRect.left > objRect.right ||
ballRect.bottom < objRect.top ||
ballRect.top > objRect.bottom);
}

function pickObject(obj) {
obj.classList.add("hidden");
score += 1000000000;
ballSize += 10;
ball.style.width = ballSize + "px";
ball.style.height = ballSize + "px";
updateScore();
}

function updateScore() {
document.querySelector("#score").textContent = "Score: " + score;
}

document.addEventListener("DOMContentLoaded", function() {
document.addEventListener("keydown", function(e) {
let ballPos = ball.getBoundingClientRect();
switch (e.key) {
case "ArrowUp":
ball.style.top = (ballPos.top - 10) + "px";
break;
case "ArrowDown":
ball.style.top = (ballPos.top + 10) + "px";
break;
case "ArrowLeft":
ball.style.left = (ballPos.left - 10) + "px";
break;
case "ArrowRight":
ball.style.left = (ballPos.left + 10) + "px";
break;
}

objects.forEach(obj => {
if (checkCollision(ball, obj)) {
pickObject(obj);
}
});
});

updateScore();
});
} catch (error) {
throw error;
}
</script>

<style>
body {
background: radial-gradient(circle, #eeeeee, #333333);
font-family: 'Eagle Lake', cursive;
color: #ffffff;
}
#ball {
position: absolute;
width: 10px;
height: 10px;
background-color: #ff0000;
border-radius: 50%;
}
.object {
position: absolute;
width: 10px;
height: 10px;
background-color: #00ff00;
}
.hidden {
display: none;
}
#score {
position: absolute;
top: 10px;
right: 10px;
}
</style>
</head>
<body>
<div id="main-container" class="container">
<div id="ball"></div>
<span id="score"></span>
<!-- Objects are randomly placed on the map -->
<!-- For the sake of brevity, only a few are shown -->
<div class="object" style="top: 50px; left: 100px;"></div>
<div class="object" style="top: 150px; left: 200px;"></div>
<div class="object" style="top: 250px; left: 300px;"></div>
<!-- More objects here -->
</div>
</body>
</html>