Making a Bouncy DVD Screensaver. (With stop button)

Intro

This is a tutorial on how to make a bouncy DVD Screensaver,
You can also use other images such as bouncy balls or very weird bouncy memes.
Hope you enjoy!

Javascript Code

JS Code allows you to open a windows and make it bounce!

var x = 0, y = 0, w=220, h=200;  // Window Size and Position.
var dx = 5, dy = 5;             // Window speed   
var interval = 20;       // Milliseconds timeout to update.

Next we make the page in about:blank!

var win = window.open('javascript:""', "", 
          "width=" + w + ",height=" + h); // Open the window.

win.document.write('<style> body { background-color: black; } </style> <body> <img src="http://d-v-d.rf.gd/dvd.gif" width=200 /> </body>'); // Write the window to a GIF of the Screensaver.

win.moveTo(x,y); // Moves the Window.

var intervalID  = window.setInterval("bounce()", interval); // Uses the bounce thingy.

function bounce() {
    // If the user has closed the window, Stop the animation.
    if (win.closed) {
        clearInterval(intervalID);
        return; // (still moving but very buggy)
    }

    // Bounce on edges.
    if ((x+dx > (screen.availWidth - w)) || (x+dx < 0)) dx = -dx;
    if ((y+dy > (screen.availHeight - h)) || (y+dy < 0)) dy = -dy;

    // Updates the Position of the Window.
    x += dx;
    y += dy;

    win.moveTo(x,y); // Move the updated window!
}

The Stop Button!

Close the Windows to prevent more bouncy bouncy!

<form>
<input type="button" value="Stop" 
       onclick="clearInterval(intervalID); win.close();">
</form>

Rules

Don’t use this code to make a virus simular to YouAreAnIdiot on IF, It’s just kinda weird and gets you bonked with the suspended hammer.
You may use this for alerts and also memes but don’t make it too fast.
You MUST include a Stop Button.

Also don’t use it for anything else bad.

Demo
http://d-v-d.rf.gd

Download the DVD GIF

3 Likes

#community-guides ?

It was first set to community guidelines at first but it got moved to informal.

2 Likes

I also think this is too unrelated to InfinityFree to be considered for a community guide. It’s a cool Javascript trick, but I don’t see this as something that’s useful to many people.

3 Likes

I usually see these sort of stuff in torrent websites as popup ADS (or downloading malware), I don’t see how useful it is in a good way.

2 Likes

It has already happened to me several times that users choose this CG category instead of hosting, etc. so I simply approved (so it doesn’t disappear permanently) and then moved to another category and removed the wiki.

2 Likes

Cool!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.