Get different shape colours
This commit is contained in:
parent
3b198279d8
commit
c6aebd1166
@ -149,6 +149,8 @@ class GeneratedShape {
|
|||||||
|
|
||||||
this.points = [];
|
this.points = [];
|
||||||
this.calculatePoints();
|
this.calculatePoints();
|
||||||
|
|
||||||
|
this.colour = this.colour();
|
||||||
}
|
}
|
||||||
|
|
||||||
collide(shapes) {
|
collide(shapes) {
|
||||||
@ -181,6 +183,15 @@ class GeneratedShape {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
colour() {
|
||||||
|
/**
|
||||||
|
* Choose a colour for the shape.
|
||||||
|
**/
|
||||||
|
var colours = ["red", "blue", "green", "black", "white"];
|
||||||
|
var index = floor(random(0, colours.length));
|
||||||
|
return colours[index];
|
||||||
|
}
|
||||||
|
|
||||||
sound() {
|
sound() {
|
||||||
/**
|
/**
|
||||||
* Play a sound after a collision is detected.
|
* Play a sound after a collision is detected.
|
||||||
@ -231,6 +242,7 @@ class GeneratedShape {
|
|||||||
* Show the shape on the canvas.
|
* Show the shape on the canvas.
|
||||||
**/
|
**/
|
||||||
// TODO: use getSoundInfo function to influence how shape is drawn
|
// TODO: use getSoundInfo function to influence how shape is drawn
|
||||||
|
fill(this.colour);
|
||||||
this.createShape();
|
this.createShape();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +298,6 @@ function draw() {
|
|||||||
background("#69D2E7");
|
background("#69D2E7");
|
||||||
translate(centerX, centerX);
|
translate(centerX, centerX);
|
||||||
blendMode(BLEND);
|
blendMode(BLEND);
|
||||||
fill("#F38630");
|
|
||||||
smooth();
|
smooth();
|
||||||
noStroke();
|
noStroke();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user