ELEC2645 (2016/17) / Mbed 2 deprecated 2645_Project_el15as

Dependencies:   mbed

Revision:
10:95842278bd66
Parent:
8:c3cf8d1057bb
--- a/Animation/Animation.cpp	Wed May 03 15:25:13 2017 +0000
+++ b/Animation/Animation.cpp	Wed May 03 16:16:33 2017 +0000
@@ -1,17 +1,27 @@
 #include "Animation.h"
 
+//////////// constructor ////////////
 Animation::Animation()
 {
 
 }
 
+//////////// destructor ////////////
 Animation::~Animation()
 {
 
 }
 
+/////////////////// public methods ///////////////////
+
 void Animation::spawn(N5110 &lcd, intVector2D starting_position)
 {
+    // This animates the tube at the ceiling opening and the player falling out
+    // of it, after which the tube closes.
+    // The first animation cycle shows the player falling out of the tube
+    // however we want the player to have control right after he appears,
+    // rather than waiting for the tube opening to close. Hence the rest
+    // of the animation will happen one frame at a time as the game goes on.
     if (spawnCycle == 0)
     {
         lcd.setPixel(starting_position.x + 1, starting_position.y - 1, false);
@@ -64,6 +74,9 @@
 
 void Animation::death(N5110 &lcd, intVector2D position, int frame)
 {
+    // Animates the explosion of the player due to hitting the spikes
+    // The animation frame number is fed into the function
+    // and the appropriate pixels are set or cleared.
     if (frame == 0)
     {
         lcd.setPixel(position.x + 1, position.y, false);
@@ -128,6 +141,8 @@
 
 void Animation::finish(N5110 &lcd, intVector2D finish_position, Gamepad &pad, bool soundOn)
 {
+    // Animates the player going into the level exit tube. First 4 frames
+    // also trigger a tone if the sound is turned on. 
     lcd.setPixel(finish_position.x + 3, finish_position.y + 2, false);
     lcd.refresh();
     if (soundOn) pad.tone(523.25f,0.1f);