Calculator Tools Calculator Tools
Create

Ozzy Bubbles Game

Nov 12, 2023

About this app

A fun Ozzy Bubbles game with a level shaped as 'DEHIIILLS' in Old English font.

Ozzy Bubbles Game Score: 0 🐢

Related apps

Put this on your site

Source

                    <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>Ozzy Bubbles Game</title>
<meta name="description" content="A fun Ozzy Bubbles game with a level shaped as 'DEHIIILLS' in Old English font.">
<meta name="keywords" content="Ozzy, Bubbles, Game, DEHIIILLS, Old English, Fun">

<style>
@import url('https://fonts.googleapis.com/css2?family=Eczar&display=swap');
#canvas { background: #000; }
#ozzy { font-family: 'Eczar', serif; color: #fff; font-size: 50px; }
#score { position: absolute; color: #fff; top: 20px; right: 20px; }
</style>

<script>
let ozzy, score, scene, speed = 2;

function setup() {
createCanvas(windowWidth, windowHeight);
textSize(50); textAlign(CENTER, CENTER);
ozzy = createSprite(width/2, height/2, 50, 50);
ozzy.shapeColor = color(255, 0, 0);
score = 0;
scene = createSprite(width/2, height/2, width, height);
scene.shapeColor = color(0, 0, 255);
scene.setDefaultCollider();
}

function draw() {
background(0);
ozzy.velocity.x = (keyIsDown(RIGHT_ARROW) - keyIsDown(LEFT_ARROW)) * speed;
ozzy.velocity.y += 0.5; // gravity
if (keyIsDown(UP_ARROW) && ozzy.touching.bottom) ozzy.velocity.y = -10; // jump
ozzy.collide(scene);
if (ozzy.position.x > width - 30) {
ozzy.position.x = 30; score += 1;
if (score === 9) { endGame(); }
}
drawSprites();
}

function endGame() {
fill(255, 0, 0); noLoop(); text("Game Over", width/2, height/2);
}

function keyPressed() {
if (keyCode === DOWN_ARROW) return false; // disable down movement
}
</script>
</head>
<body>
<div id="main-container">
<div id="canvas"></div>
<div id="score">Score: <span id="scoreValue">0</span></div>
<div id="ozzy">🐢</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.14/p5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.14/addons/p5.dom.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.14/addons/p5.sound.js"></script>
</body>
</html>