Skip to main content
I added a few code examples
Source Link

You could reduce a some of your code by declaring your Rectangles and colors (kleur) as arrays. Then you could initialize (or reset) the kleur array elements within a loop.

For example: Instead of

var rectangle1: Rectangle;
var rectangle2: Rectangle;
var rectangle3: Rectangle;
var rectangle4: Rectangle;
//...

try

var rectangle[16]: Rectangle;

and instead of

var kleur1 = "red";
var kleur2 = "red";
var kleur3 = "red";
//...

try

var kleur[16];
var x;
for (x=0; x<16; x++)
    kleur[x] = "red";

Then, wherever you say

kleur1

you can say

kleur[1]

You could reduce a some of your code by declaring your Rectangles and colors (kleur) as arrays. Then you could initialize (or reset) the kleur array elements within a loop.

You could reduce a some of your code by declaring your Rectangles and colors (kleur) as arrays. Then you could initialize (or reset) the kleur array elements within a loop.

For example: Instead of

var rectangle1: Rectangle;
var rectangle2: Rectangle;
var rectangle3: Rectangle;
var rectangle4: Rectangle;
//...

try

var rectangle[16]: Rectangle;

and instead of

var kleur1 = "red";
var kleur2 = "red";
var kleur3 = "red";
//...

try

var kleur[16];
var x;
for (x=0; x<16; x++)
    kleur[x] = "red";

Then, wherever you say

kleur1

you can say

kleur[1]
Source Link

You could reduce a some of your code by declaring your Rectangles and colors (kleur) as arrays. Then you could initialize (or reset) the kleur array elements within a loop.