Skip to content

Instantly share code, notes, and snippets.

@zhuowei
Created June 15, 2021 23:39
Show Gist options
  • Select an option

  • Save zhuowei/cb15ffaf4c44509df5a4221b7277bea4 to your computer and use it in GitHub Desktop.

Select an option

Save zhuowei/cb15ffaf4c44509df5a4221b7277bea4 to your computer and use it in GitHub Desktop.
<style>
.logo {
position: absolute;
background: url("dvdVideo3.png") center / contain no-repeat;
width: 150px;
height: 88px;
}
* {
margin: 0;
padding: 0;
}
body {
width: 640px;
height: 480px;
background-color: black;
overflow: hidden;
}
</style>
<script>
function spawn(xPos, yPos) {
var a = document.createElement("div");
a.classList.add("logo");
a.style.left = xPos | 0;
a.style.top = yPos | 0;
a.style.filter = "hue-rotate(" + hue + "deg) brightness(3)";
document.body.appendChild(a);
}
var thingX = 320;
var thingY = 320;
var thingXVel = 2;
var thingYVel = 2;
var hue = -180;
const thingYAccel = 0.3;
var again = false;
var classicBounce = true;
function step() {
if (classicBounce) {
var cur = document.getElementsByTagName("div");
if (cur.length > 0) cur[0].remove();
spawn(thingX, thingY);
thingX -= 2;
thingY -= 2;
if (thingX == 0 && thingY == 0) {
classicBounce = false;
hue += 60;
}
if (again) setTimeout(step, 50);
return;
}
spawn(thingX, thingY);
thingX += thingXVel;
thingY += thingYVel;
thingYVel += thingYAccel;
thingYVel *= 0.99;
var height = 88;
if (thingY + height > 480) {
thingY = 480 - height;
thingYVel = -thingYVel;
hue += 60;
}
if (thingX > 640) return;
if (again) setTimeout(step, 50);
}
window.onkeyup = function() {step(); again = true;}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment