implemented updateAllSheep and refactored sheep updating
This commit is contained in:
parent
ae8dff9e00
commit
e807e0fe7e
@ -87,9 +87,13 @@ public class DiscoParty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set a random colour for all sheep in array
|
// Set a random colour for all sheep in array
|
||||||
void randomizeSheepColours() {
|
void randomizeSheepColour(Sheep sheep) {
|
||||||
for (Sheep sheep : getSheep()) {
|
|
||||||
sheep.setColor(discoColours[(int) Math.round(Math.random() * (discoColours.length - 1))]);
|
sheep.setColor(discoColours[(int) Math.round(Math.random() * (discoColours.length - 1))]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateAllSheep() {
|
||||||
|
for (Sheep sheep: getSheep()) {
|
||||||
|
randomizeSheepColour(sheep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +110,7 @@ public class DiscoParty {
|
|||||||
|
|
||||||
void update() {
|
void update() {
|
||||||
if (duration > 0) {
|
if (duration > 0) {
|
||||||
randomizeSheepColours();
|
updateAllSheep();
|
||||||
playSounds();
|
playSounds();
|
||||||
duration -= frequency;
|
duration -= frequency;
|
||||||
this.scheduleUpdate();
|
this.scheduleUpdate();
|
||||||
|
Loading…
Reference in New Issue
Block a user