106 lines
3.2 KiB
HTML
106 lines
3.2 KiB
HTML
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<style>
|
|
body {
|
|
background-color: white; /* Ensure the iframe has a white background */
|
|
}
|
|
|
|
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Emoji Gravity and Collision</title>
|
|
<script defer src="https://stats.ponywave.de/script" data-website-id="9ef713d2-adb9-4906-9df5-708d8a8b9131" data-tag="emoji"></script>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
overflow: hidden;
|
|
background-color: #f0f0f0;
|
|
}
|
|
.emoji {
|
|
position: absolute;
|
|
font-size: 24px;
|
|
user-select: none;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<script>
|
|
const emojis = ['😀', '😂', '😊', '😉', '😎', '😍', '🤔', '😜', '🥳', '🤩'];
|
|
|
|
function getRandomEmoji() {
|
|
return emojis[Math.floor(Math.random() * emojis.length)];
|
|
}
|
|
|
|
function getRandomInt(min, max) {
|
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
}
|
|
|
|
class Emoji {
|
|
constructor(x, y) {
|
|
this.element = document.createElement('div');
|
|
this.element.className = 'emoji';
|
|
this.element.textContent = getRandomEmoji();
|
|
document.body.appendChild(this.element);
|
|
|
|
this.x = x;
|
|
this.y = y;
|
|
this.vx = (Math.random() - 0.5) * 2; // Random horizontal velocity
|
|
this.vy = (Math.random() - 0.5) * 2; // Random vertical velocity
|
|
this.ax = 0;
|
|
this.ay = 0.1; // Gravity acceleration
|
|
|
|
this.updatePosition();
|
|
}
|
|
|
|
updatePosition() {
|
|
this.vx += this.ax;
|
|
this.vy += this.ay;
|
|
|
|
this.x += this.vx;
|
|
this.y += this.vy;
|
|
|
|
if (this.y + this.element.offsetHeight > window.innerHeight) {
|
|
this.y = window.innerHeight - this.element.offsetHeight;
|
|
this.vy *= -0.7; // Bounce effect
|
|
}
|
|
|
|
if (this.x + this.element.offsetWidth > window.innerWidth || this.x < 0) {
|
|
this.vx *= -0.7; // Bounce effect
|
|
}
|
|
|
|
this.element.style.left = `${this.x}px`;
|
|
this.element.style.top = `${this.y}px`;
|
|
|
|
requestAnimationFrame(() => this.updatePosition());
|
|
}
|
|
}
|
|
|
|
document.addEventListener('click', (event) => {
|
|
const count = getRandomInt(3, 7);
|
|
for (let i = 0; i < count; i++) {
|
|
new Emoji(event.clientX, event.clientY);
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|