Commit 26e493b8 authored by Sander Kvenild's avatar Sander Kvenild
Browse files

Made each bubble have a random color

parent 2f994583
......@@ -15,7 +15,9 @@
this.x = x;
this.y = y;
this.r = r;
this.farge = "green";
this.farge = randomColor();
this.orginalFarge = this.farge;
}
flytt() {
this.x = this.x + Math.floor(Math.random() * 10 -5);
......@@ -94,11 +96,18 @@
if(bobler[i].inneholder(event.x,event.y)) {
bobler[i].farge = "red";
} else {
bobler[i].farge = "green";
bobler[i].farge = bobler[i].orginalFarge;
}
}
}
function randomColor() {
let r = Math.floor(Math.random()*255).toString(16)
let g = Math.floor(Math.random()*255).toString(16)
let b = Math.floor(Math.random()*255).toString(16)
return `#${r}${g}${b}`
}
</script>
</body>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment