Project 3: Homework assignment

by samscaife on Sunday 15 January 2012

At the end of the 3rd lesson we where set another homework assignment. For this one we had to put into practice what we had learnt about arrays and objects by creating some buttons which would be clickable and change colour when pressed.

I wanted to give me self a bit more of a challenge so I decided that I would make the buttons stop on click as well as change colour. For an even bigger challenge I also wanted to have the balls collide with each other!

To get by buttons to stop when clicked I created a method (the name for functions within objects) which would check the current position of the mouse and if it was within a circle reduce the speed of it to 0. When clicked again I wanted them to carry on moving they way they where before I tried to do this by making a variable which would save the speed and direction of the button, however I could not get this method to work as it kept breaking everything else and I could not figure it out!

when it came to trying to make the bubbles to collide with each other I approached it by thinking that I would check for if the area of the button overlapped with another it would reverse its direction giving the illusion of a collision. However I couldn't work out how to check if a circle made from the object was touching another circle also made by the object. After spending a while trying several different approaches I called it a day as I had already done what the homework had asked me to do and I was getting no where with adding in extra collision.



you can fine the live project here.

Leave your comment