Ok, I promise I’ll stop using the assignments to work on Trumpong soon, but the past few assignments have fit so perfectly into developing the game, that it’s hard to resist.
This week the assignment was to use the constructor function and an array. Last week, I had wanted to give players their choice of candidate to play with, but couldn’t think of a good way to do it. The constructor and array functionality solved the problem.
I created a constructor function called Candidate and I stored each candidate in the array candidates. Because each candidate has a distinct name and image height, I had to initialize each individually, but from there I was able to create most of the functionality through the constructor.
Check out the new functionality here: http://lmj.io/projects/icm/trumpong-again/
See the code on GitHub here: https://github.com/lisajamhoury/trumpong/blob/master/sketch.js