MemeComedyClub_2 / index.html
notaclickbait-memes's picture
Update index.html
8729170 verified
raw
history blame
2.73 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Emoji Gravity Click</title>
<style>
body {
margin: 0;
overflow: hidden;
background-color: #f0f0f0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
canvas {
border: 1px solid #ccc;
}
</style>
</head>
<body>
<canvas id="emojiCanvas"></canvas>
<p>No it is not Empty, Click anywhere and see!</p>
<script>
const canvas = document.getElementById('emojiCanvas');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
const emojis = ['🐸', '🀑', 'πŸ’Έ', '😎', '🀩', 'πŸͺ™'];
const gravity = 0.5;
const friction = 0.97;
let particles = [];
class Particle {
constructor(x, y) {
this.x = x;
this.y = y;
this.size = Math.random() * 20 + 10;
this.speedY = (Math.random() - 0.5) * 5;
this.speedX = (Math.random() - 0.5) * 5;
this.color = '#fff';
this.emoji = emojis[Math.floor(Math.random() * emojis.length)];
}
update() {
this.speedY += gravity;
this.speedX *= friction;
this.x += this.speedX;
this.y += this.speedY;
if (this.y + this.size >= canvas.height) {
this.y = canvas.height - this.size;
this.speedY = -this.speedY * friction;
}
if (this.x + this.size >= canvas.width || this.x - this.size <= 0) {
this.speedX = -this.speedX * friction;
}
}
draw() {
ctx.font = `${this.size}px Arial`;
ctx.fillStyle = this.color;
ctx.fillText(this.emoji, this.x, this.y);
}
}
function handleParticles(event) {
const { clientX, clientY } = event;
const numberOfParticles = Math.random() * 10 + 5;
for (let i = 0; i < numberOfParticles; i++) {
particles.push(new Particle(clientX, clientY));
}
}
function animate() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
for (let i = particles.length - 1; i >= 0; i--) {
particles[i].update();
particles[i].draw();
if (particles[i].size <= 0.3) {
particles.splice(i, 1);
}
}
requestAnimationFrame(animate);
}
canvas.addEventListener('click', handleParticles);
animate();
</script>
</body>
</html>