Commit ea281bf4 authored by Sander Kvenild's avatar Sander Kvenild
Browse files

Moved bubble check to it's own method

parent 27b6ed48
......@@ -23,8 +23,10 @@
flytt() {
this.x = this.x + Math.floor(Math.random() * 10 -5);
this.y = this.y + Math.floor(Math.random() * 10 -5);
}
// Keep bubbles from going outside of canvas
// Keep bubbles from going outside of canvas
sjekk() {
this.x = this.x - this.r > 0 ? this.x : this.r
this.y = this.y - this.r > 0 ? this.y : this.r
this.x = this.x + this.r < canvas.width ? this.x : canvas.width - this.r
......@@ -77,6 +79,7 @@
reset();
for(let i = 0; i < bobler.length; i++) {
bobler[i].flytt();
bobler[i].sjekk();
bobler[i].vis();
}
}
......
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