Newbie: Using an Array
in
Programming Questions
•
2 years ago
I'm new to Processing and OOP (and lots of other development stuff in general), but I was hoping someone could help me simplify this working code. The code works as-is, but I'm trying my hand at arrays.
I started a two-dimensional array, but I don't know how to correctly implement it. What would you guys do? Thanks!
Cir myCircle1;
Cir myCircle2;
Cir myCircle3;
Cir myCircle4;
Cir myCircle5;
Cir myCircle6;
Cir myCircle7;
Cir myCircle8; // Use array to replace all these?
int[][] cirArray = { {20, 60, 20, 20, 0, 255, 10},
{20, 60, 7, 7, 0, 255, 75},
{40, 40, 20, 20, 0, 255, 10},
{40, 40, 7, 7, 0, 255, 75},
{60, 20, 20, 20, 0, 255, 10},
{60, 20, 7, 7, 0, 255, 75},
{80, 0, 20, 20, 0, 255, 10},
{80, 0, 7, 7, 0, 255, 75} };
void setup() {
smooth();
size(100, 80);
myCircle1 = new Cir(20, 60, 20, 20, 0, 255, 10); // Use array to replace all these?
myCircle2 = new Cir(20, 60, 7, 7, 0, 255, 75);
myCircle3 = new Cir(40, 40, 20, 20, 0, 255, 10);
myCircle4 = new Cir(40, 40, 7, 7, 0, 255, 75);
myCircle5 = new Cir(60, 20, 20, 20, 0, 255, 10);
myCircle6 = new Cir(60, 20, 7, 7, 0, 255, 75);
myCircle7 = new Cir(80, 0, 20, 20, 0, 255, 10);
myCircle8 = new Cir(80, 0, 7, 7, 0, 255, 75);
}
(code continues...)
1