Similar to the post on variable and random coding, i used the same technique to create a code that would produce a square that when clicked would change into a different colour that i choose from a list of colours. This is done using an array. The array is first programmed where its say ‘color [] colorshape…’. This is the variable that says that the colorshape will be an array of the colour that i write in the bracket. ‘[]’ this is the sign for array. Using the random code that I describe in the previous post I used this so it would randomly chose one of the colours in my list above ‘fill(colorofshape[randomColor]);’ If you use a variable within some braces, it will only be found within the braces. If you want to use it outside the braces you will need to make sure its not in any braces so you can use it throughout.

Screen Shot 2014-10-16 at 16.00.33

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s