Skip to content

Commit

Permalink
Moar rubbish imgs
Browse files Browse the repository at this point in the history
  • Loading branch information
C1200 committed Nov 13, 2021
1 parent 9116ff9 commit 842040d
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 5 deletions.
Binary file added images/rubbish3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/rubbish4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
const rubbishImgs = [
"images/rubbish1.png",
"images/rubbish2.png",
"images/rubbish3.png",
"images/rubbish4.png",
];

var counter = parseInt(localStorage.getItem("highscore") ?? "0");
var totalCPS = parseInt(localStorage.getItem("cps") ?? "0");
localStorage.setItem("highscore", counter);
Expand All @@ -17,10 +24,16 @@ function newRubbish(enableDelay) {
if (document.getElementsByClassName("rubbish").length > 50) return;
var r = new Image();
r.className = "rubbish";

r.style.top = Math.floor(Math.random() * 100) + "%";
r.style.animationName = `rubbishAnimation${
Math.floor(Math.random() * 4) + 1
}`;
if (enableDelay) r.style.animationDelay = Math.random() * 6 + "s";
r.src = Math.random() > 0.5 ? "images/rubbish1.png" : "images/rubbish2.png";

r.src = rubbishImgs[Math.floor(Math.random() * rubbishImgs.length)];
r.onanimationend = () => r.remove();

document.getElementsByClassName("clicker")[0].append(r);
}

Expand Down
31 changes: 29 additions & 2 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ a {
font-weight: bold;
}

@keyframes rubbishAnimation {
@keyframes rubbishAnimation1 {
0% {
transform: translate(0, 0) rotate(0deg);
}
Expand All @@ -140,8 +140,35 @@ a {
}
}

@keyframes rubbishAnimation2 {
0% {
transform: translate(0, 0) rotate(90deg);
}
100% {
transform: translate(640px, 0) rotate(360deg);
}
}

@keyframes rubbishAnimation3 {
0% {
transform: translate(0, 0) rotate(180deg);
}
100% {
transform: translate(650px, 0) rotate(360deg);
}
}

@keyframes rubbishAnimation4 {
0% {
transform: translate(0, 0) rotate(360deg);
}
100% {
transform: translate(660px, 0) rotate(0deg);
}
}

.rubbish {
animation: rubbishAnimation 4s;
animation-duration: 4s;
position: absolute;
left: -25px;
height: 20px;
Expand Down
5 changes: 3 additions & 2 deletions thanks.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
images/rubbish1.png made by https://www.freepik.com from https://www.flaticon.com/
images/rubbish2.png made by https://www.flaticon.com/authors/smashicons from https://www.flaticon.com/
images/rubbish1.png and images/rubbish3.png made by https://www.freepik.com from https://www.flaticon.com/
images/rubbish2.png made by https://www.flaticon.com/authors/smashicons from https://www.flaticon.com/
images/rubbish4.png made by https://www.flaticon.com/authors/aranagraphics from https://www.flaticon.com/

0 comments on commit 842040d

Please sign in to comment.