Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sander Kvenild
DCST1007 - OOP
Commits
26e493b8
Commit
26e493b8
authored
Feb 03, 2022
by
Sander Kvenild
Browse files
Made each bubble have a random color
parent
2f994583
Changes
1
Hide whitespace changes
Inline
Side-by-side
js-ov13-oop3-sander-kvenild/minebobler.html
View file @
26e493b8
...
...
@@ -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>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment