working with classes

I tried to do 3 simple balls affected by gravity…and then through the internet I inevitably got introduced to using classes. I like them because they seem to organize and simplify things (especially repeated actions and objects), but it was harder for me to understand because its not as linear as what we did on thursday (instead of making objects and applying actions, you sort of make your actions and apply them to objects).

It was confusing, but I found a really nice youtube demo that walked through it and I left a ton of little notes in my code.

Class_July28

youtube tutorial : Jose Sanchez, Tutorial 7 Classes, https://www.youtube.com/watch?v=PP4_96YzBnM&list=PL19223D55BA16ECDF&index=7

Thanks!

*could not figure out how to randomize xPos and yPos, I replaced all the x/y with xPos/yPos and inserted our code from Thursday under void move but it made the ball frantically shake.  Also, I am curious about where in the class I would insert a keypress to add some interaction. Thanks!

code:

 

One response to “working with classes

  1. We’ll look at classes today, but you could have eliminated the x/y arguments in your constructor, and simply use random() when the instance is created.