← Codeschnipsel

Halloween Falling Effect

JavaScript · von waerp · 25.09.2026

Ein Halloween-Effekt ähnlich wie Schneefall: Kürbisse, Fledermäuse und Partikel fallen über den gesamten Bildschirm. Die Elemente bewegen sich leicht seitlich und drehen sich dabei.

JavaScript

JAVASCRIPT
document.addEventListener("DOMContentLoaded", () => {

    const canvas = document.createElement("canvas");

    canvas.style.position = "fixed";
    canvas.style.top = "0";
    canvas.style.left = "0";
    canvas.style.width = "100%";
    canvas.style.height = "100%";
    canvas.style.pointerEvents = "none";
    canvas.style.zIndex = "9999";

    document.body.appendChild(canvas);

    const ctx = canvas.getContext("2d");

    let width;
    let height;

    const particles = [];

    const symbols = [
        "🎃",
        "🦇",
        "👻",
        "🕷️",
        "🕸️",
        "💀"
    ];

    const particleCount = 40;


    // Bildschirmgröße
    function resize() {
        width = canvas.width = window.innerWidth;
        height = canvas.height = window.innerHeight;
    }

    window.addEventListener("resize", resize);

    resize();


    // Neues Halloween-Partikel
    function createParticle(startAtTop = false) {

        return {
            x: Math.random() * width,

            y: startAtTop
                ? -50
                : Math.random() * height,

            size: Math.random() * 20 + 15,

            speed: Math.random() * 1.5 + 0.5,

            drift: Math.random() * 1.5 - 0.75,

            rotation: Math.random() * Math.PI * 2,

            rotationSpeed:
                (Math.random() - 0.5) * 0.04,

            opacity:
                Math.random() * 0.5 + 0.5,

            symbol:
                symbols[
                    Math.floor(
                        Math.random() * symbols.length
                    )
                ]
        };
    }


    // Partikel erstellen
    for (let i = 0; i < particleCount; i++) {
        particles.push(createParticle());
    }


    // Partikel zeichnen
    function drawParticle(particle) {

        ctx.save();

        ctx.globalAlpha = particle.opacity;

        ctx.translate(
            particle.x,
            particle.y
        );

        ctx.rotate(
            particle.rotation
        );

        ctx.font = `${particle.size}px serif`;

        ctx.textAlign = "center";
        ctx.textBaseline = "middle";

        ctx.fillText(
            particle.symbol,
            0,
            0
        );

        ctx.restore();
    }


    // Animation
    function animate() {

        ctx.clearRect(
            0,
            0,
            width,
            height
        );

        particles.forEach((particle) => {

            // Fallen
            particle.y += particle.speed;

            // Leichte Bewegung nach links/rechts
            particle.x += particle.drift;

            // Drehen
            particle.rotation +=
                particle.rotationSpeed;


            // Wenn unten angekommen
            if (particle.y > height + 50) {

                Object.assign(
                    particle,
                    createParticle(true)
                );
            }


            // Seitenbegrenzung
            if (particle.x < -50) {
                particle.x = width + 50;
            }

            if (particle.x > width + 50) {
                particle.x = -50;
            }


            drawParticle(particle);
        });


        requestAnimationFrame(animate);
    }


    // Animation starten
    animate();

});

Effekt anpassen

Die wichtigsten Einstellungen findest du direkt am Anfang des JavaScripts:

JAVASCRIPT
/*
const symbols = ["🎃", "🦇", "👻", "🕷️", "🕸️"];

const particleCount = 35;
*/

Mehr Halloween-Elemente:

JAVASCRIPT
/*
const symbols = [
    "🎃",
    "🦇",
    "👻",
    "🕷️",
    "🕸️",
    "💀",
    "☠️"
];
*/

Mehr bzw. weniger Partikel:

JAVASCRIPT
// const particleCount = 60;

Schnellerer Fall:

JAVASCRIPT
// speed: Math.random() * 3 + 1,

Der Effekt läuft über requestAnimationFrame() und benötigt keine externe JavaScript-Bibliothek.

Demo

Der Code läuft abgeschottet in deinem Browser – ohne Zugriff auf dein Konto und ohne etwas aus dem Netz nachzuladen.

Eigener Reiter Ausprobieren
Bewertung
5,0 (1 Stimmen)
Gefällt mir
1
Aufrufe
91

Melde dich an, um zu bewerten, zu liken und zu kommentieren.

Im Forum verlinken

Diesen Code in einen Forumbeitrag oder Kommentar einfügen – daraus wird eine hervorgehobene Verlinkung auf diesen Codeschnipsel.

[[snippet:halloween-falling-effect|Halloween Falling Effect]]

Kommentare (1)

waerp 26.09.2026 11:09

Ein kleiner Tipp: Mit dem Smiley-Maker könnt ihr euch natürlich auch eigene Smileys generieren und verwenden.

Smiley

Bearbeitet am 26.09.2026 um 13:32 Uhr