Warning: technical content!
This project was my first practical introduction to object-oriented programmming. The course - taught by Hack Reactor’s Marcus Phillips - introduces the concepts of scopes and closures, the keyword ‘this’, and prototype delegation.
Object-oriented programming is a way of organising your code so that variables and functions are grouped together in an ‘object’. An ‘object’ is simply a concept or an entity related to whatever your program is intended to do. In the example of Frogger, each sprite (the player character, the ‘enemies’ and the gems) is an object, and the variables for that object (eg. position, displayed image) are grouped together, as are the functions (called ‘methods’ in object-oriented laguage), for example movement and collision detection.
In the above example, an Enemy object is defined, and the variables for coordinates and speed are grouped within that object.
In the example above, all Enemy objects now have access to the render method and sprite property in Enemy.prototype.