Pocoyo's Adventure
Nov 18, 2023
v.0
Join Pocoyo and friends on an adventure through iSQUARE mall to reach Hong Kong Rocket Island. Game HTML5 Adventure Pocoyo SideScroller

Versions  

Bugs  
None!

Get This App On Your Website

1. Copy the code above with the iframe and link.
2. Paste the code into your website.
3. Resize the iframe to fit your website.

Javascript, HTML, CSS Code

                
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript"> window.addEventListener('error', function(event) { var message = JSON.parse(JSON.stringify(event.message)); var source = event.filename; var lineno = event.lineno; var colno = event.colno; var error = event.error; window.parent.postMessage({ type: 'iframeError', details: { message: message, source: source, lineno: lineno, colno: colno, error: error ? error.stack : '' } }, '*'); }); window.addEventListener('unhandledrejection', function(event) { window.parent.postMessage({ type: 'iframePromiseRejection', details: { reason: event.reason } }, '*'); }); </script>

<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pocoyo's Adventure</title>
<meta name="description" content="Join Pocoyo and friends on an adventure through iSQUARE mall to reach Hong Kong Rocket Island.">
<meta name="keywords" content="Pocoyo, Adventure, Side-Scroller, Game, HTML5">
<style>
body, html { height: 100%; margin: 0; overflow: hidden; }
canvas { background: #ecf0f1; display: block; }
#credits { display: none; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; }
#credits h1 { font-size: 2em; color: #3498db; }
#credits p { color: #2c3e50; }
</style>

<link rel="canonical" href="https://calculator.tools/app/pocoyos-adventure-757/">
<meta charset="utf-8">

</head>
<body>
<canvas id="gameCanvas"></canvas>
<div id="credits">
<h1>Congratulations!</h1>
<p>Welcome to Hong Kong Rocket Island 🚀</p>
<p>Game Credits: Pocoyo & Friends, SpongeBob, and many others...</p>
</div>

<script>
const canvas = document.getElementById('gameCanvas');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;

let player = {
x: 50,
y: canvas.height - 150,
width: 50,
height: 50,
color: '#3498db',
onRope: false,
onEscalator: false,
speed: 5
};

let keys = {
right: false,
left: false,
up: false,
down: false,
f: false
};

let floors = [
{ x: 0, y: canvas.height - 30, width: canvas.width, height: 30 }, // Ground floor
{ x: 0, y: canvas.height - 300, width: canvas.width, height: 30 }, // 3rd floor
{ x: canvas.width / 2 - 50, y: 0, width: 100, height: canvas.height }, // Drop to 3rd floor
{ x: 0, y: 100, width: canvas.width, height: 30 } // Rooftop
];

let ropes = [
{ x: floors[1].width / 2, y: floors[1].y, width: 5, height: floors[1].y - floors[0].y },
{ x: floors[0].width - 100, y: floors[0].y, width: 5, height: floors[0].y - floors[2].y }
];

let escalator = { x: 50, y: floors[1].y - 150, width: 30, height: 120 };

let portal = { x: floors[0].width - 50, y: floors[0].y - 50, width: 50, height: 50 };

function drawPlayer() {
ctx.fillStyle = player.color;
ctx.fillRect(player.x, player.y, player.width, player.height);
}

function drawFloors() {
floors.forEach(floor => {
ctx.fillStyle = '#34495e';
ctx.fillRect(floor.x, floor.y, floor.width, floor.height);
});
}

function drawRopes() {
ropes.forEach(rope => {
ctx.fillStyle = '#e67e22';
ctx.fillRect(rope.x, rope.y, rope.width, rope.height);
});
}

function drawEscalator() {
ctx.fillStyle = '#95a5a6';
ctx.fillRect(escalator.x, escalator.y, escalator.width, escalator.height);
}

function drawPortal() {
ctx.fillStyle = '#9b59b6';
ctx.fillRect(portal.x, portal.y, portal.width, portal.height);
}

function updatePlayer() {
if (keys.right) player.x += player.speed;
if (keys.left) player.x -= player.speed;
if (keys.up && !player.onRope) player.y -= player.speed * 2;
if (player.onRope) player.y += 1; // Simulate rope descent
if (player.onEscalator) player.x += 2; // Simulate escalator movement

// Collision with floors
floors.forEach(floor => {
if (player.x < floor.x + floor.width && player.x + player.width > floor.x &&
player.y < floor.y + floor.height && player.y + player.height > floor.y) {
player.y = floor.y - player.height;
}
});

// Collision with ropes
ropes.forEach(rope => {
if (player.x < rope.x + rope.width && player.x + player.width > rope.x &&
player.y < rope.y + rope.height && player.y + player.height > rope.y) {
player.onRope = true;
} else {
player.onRope = false;
}
});

// Collision with escalator
if (player.x < escalator.x + escalator.width && player.x + player.width > escalator.x &&
player.y < escalator.y + escalator.height && player.y + player.height > escalator.y) {
player.onEscalator = true;
} else {
player.onEscalator = false;
}

// Collision with portal
if (player.x < portal.x + portal.width && player.x + player.width > portal.x &&
player.y < portal.y + portal.height && player.y + player.height > portal.y) {
document.getElementById('credits').style.display = 'block';
canvas.style.display = 'none';
}

// Boundary checks
if (player.x <= 0) player.x = 0;
if (player.x >= canvas.width - player.width) player.x = canvas.width - player.width;
if (player.y <= 0) player.y = 0;
if (player.y >= canvas.height - player.height) player.y = canvas.height - player.height;
}

function gameLoop() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
drawFloors();
drawRopes();
drawEscalator();
drawPortal();
updatePlayer();
drawPlayer();
requestAnimationFrame(gameLoop);
}

document.addEventListener('keydown', function(e) {
switch (e.code) {
case 'ArrowRight': keys.right = true; break;
case 'ArrowLeft': keys.left = true; break;
case 'ArrowUp': keys.up = true; break;
case 'ArrowDown': keys.down = true; break;
case 'KeyF': keys.f = true; break;
}
});

document.addEventListener('keyup', function(e) {
switch (e.code) {
case 'ArrowRight': keys.right = false; break;
case 'ArrowLeft': keys.left = false; break;
case 'ArrowUp': keys.up = false; break;
case 'ArrowDown': keys.down = false; break;
case 'KeyF': keys.f = false; break;
}
});

gameLoop();
</script>
<script type="text/javascript"> var localStoragePrefix = "ct-757"; var lastSave = 0; function saveLocal(data) { if (Date.now() - lastSave < 1000) { return; } let cookie = localStoragePrefix + "=" + JSON.stringify(data) + "; path=" + window.location.pathname + "'; SameSite=Strict"; cookie += "; expires=" + new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 1000).toUTCString(); document.cookie = cookie; lastSave = Date.now(); } function loadLocal() { var cookiePrefix = localStoragePrefix + "="; var cookieStart = document.cookie.indexOf(cookiePrefix); if (cookieStart > -1) { let cookieEnd = document.cookie.indexOf(";", cookieStart); if (cookieEnd == -1) { cookieEnd = document.cookie.length; } var cookieData = document.cookie.substring(cookieStart + cookiePrefix.length, cookieEnd); return JSON.parse(cookieData); } } </script>
<script type="text/javascript"> window.addEventListener('load', function() { var observer = new MutationObserver(function() { window.parent.postMessage({height: document.documentElement.scrollHeight || document.body.scrollHeight},"*"); }); observer.observe(document.body, {attributes: true, childList: true, subtree: true}); window.parent.postMessage({height: document.documentElement.scrollHeight || document.body.scrollHeight},"*"); }); </script>
</body>
</html>

NEW APPS

These are apps made by the community!

FAQ

What is Calculator Tools?

Calculator Tools allows you to instantly create and generate any simple one page web app for free and immediately have it online to use and share. This means anything! Mini apps, calculators, trackers, tools, games, puzzles, screensavers... anything you can think of that the AI can handle.

The AI uses Javacript, HTML, and CSS programming to code your app up in moments. This currently uses GPT-4 the latest and most powerful version of the OpenAI GPT language model.

What Do You Mean Make An App?

Have you ever just wanted a simple app but didn't want to learn programming or pay someone to make it for you? Calculator Tools is the solution! Just type in your prompt and the AI will generate a simple app for you in seconds. You can then customize it to your liking and share it with your friends.

AI has become so powerful it is that simple these days.

Does This Use ChatGPT?

It uses GPT-4 which is the most powerful model for ChatGPT.

Calculator Tools does not remember things from prompt to prompt, each image is a unique image that does not reference any of the images or prompts previously supplied.