Project 3: Objects & Arrays

by samscaife on Sunday 15 January 2012

In the second lesson after the christmas break we started off by learning about functions. functions allow you to record a set of actions will will happen each time you call the function in your code. using functions you can do things like calculate positions with varying numbers or draw elements.

From functions we moved onto objects which are an important part of programming. a good description of what an object is that it is a cookie cutter which will allow you to make as may cookies as you want fitting the description of the cutter. With an object however you can pass in multiple values which means that you can changes the values of the variables it contains and by doing so affects the look and properties of the item created by the object.

In class we created a simple bouncing circles object which allowed to to draw as circles just by calling the object. Using objects allows you reduce the amount of code that you need as you do not have to write the same things over and over.

We then started to learn about arrays which also allow you to reduce the amount of code you need to write. Arrays as like variables but instead of storing a single piece of information they store multiple. We combined arrays,  objects and forloops to allow us to draw any amount of the same object just by changing the length of the array. Doing this I was able to make 50,000 tiny circles that would all bounce around the screen at once!

Leave your comment