I had planned several months ago to take vacation around the Thanksgiving holiday. It was a bit of luck that by doing so, I would have several days to concentrate on Project 3 - and right at the time that I needed to be able to dive deep into adding to the project.
Just like I did with the start of the project, I found that adding code in iterations - one feature at a time - I was able to make a lot of progress in very short amounts of time. I also noticed that using git version control helped immensely, as I could branch off a feature, and if it worked like I wanted, I could simply merge that branch back into master. There was only one case where I tried to do something, and had to completely scrap that idea. Being able to delete that branch and pick up where the master branch had left off, saved me a lot of backtracking or trying to undo the work I had done for the previous few hours.
After a day and a half of coding, I had finished the main game play as I wanted it to be. I started into adding an intro, and tried to think of a way to make the game feel more like a real video game. My thought was to keep as much going on in the canvas object as I could, instead of moving this information into the index.html file, or splitting it out into other files.
I was at a point, where the intro worked, but the game would not start. If I changed a few function calls and a variable, I could play the game, but there was no intro. I went over the code again and again, but could not see where I was having issues. So, off to Piazza I went, posting about my issue and hoping someone would spot the logic flaw I was missing.
I woke up this morning to several emails, advising that my post had been answered. Between Kevin Mayo and Matthew Prather, they had come to the same conclusion, and revealed something I had missed. Basically, I had assumed that since I had established a local variable and its value, and then tried to turn it global, I was essentially not seeing the same variable in the other JS file.
From Matthew's response:
Reassigning the variable outside of Engine got things working immediately, and I learned something in the process.
It's been great to be a part of this cohort, just from the interaction and willingness to help others that I have seen in Piazza and HipChat. I've done my best to help where I can as well, and give back to this same community.
As for this project, I have a little bit of styling to do on the main HTML page to make it look "better", and then cleanup of the commenting in the JS files. Hopefully by the end of the week, this project will be ready for submission.
I can't wait to see what comments I get on the final product.
Just like I did with the start of the project, I found that adding code in iterations - one feature at a time - I was able to make a lot of progress in very short amounts of time. I also noticed that using git version control helped immensely, as I could branch off a feature, and if it worked like I wanted, I could simply merge that branch back into master. There was only one case where I tried to do something, and had to completely scrap that idea. Being able to delete that branch and pick up where the master branch had left off, saved me a lot of backtracking or trying to undo the work I had done for the previous few hours.
After a day and a half of coding, I had finished the main game play as I wanted it to be. I started into adding an intro, and tried to think of a way to make the game feel more like a real video game. My thought was to keep as much going on in the canvas object as I could, instead of moving this information into the index.html file, or splitting it out into other files.
I was at a point, where the intro worked, but the game would not start. If I changed a few function calls and a variable, I could play the game, but there was no intro. I went over the code again and again, but could not see where I was having issues. So, off to Piazza I went, posting about my issue and hoping someone would spot the logic flaw I was missing.
I woke up this morning to several emails, advising that my post had been answered. Between Kevin Mayo and Matthew Prather, they had come to the same conclusion, and revealed something I had missed. Basically, I had assumed that since I had established a local variable and its value, and then tried to turn it global, I was essentially not seeing the same variable in the other JS file.
From Matthew's response:
Maybe the problem is the variable "intro" inside of Engine always being true.That hit the nail on the head. I assumed that since I was redefining the variable as a global variable, that it would always take the global value. However, I had initially defined the variable inside the Engine object, and JavaScript reads variables from inside outward. Since the variable was defined inside Engine locally, it never went far enough out to see the value in the global version of that variable.
So when you set "intro" false elsewhere, it's setting a global variable "intro" false, but Engine sees the intro in its own scope first.
Reassigning the variable outside of Engine got things working immediately, and I learned something in the process.
It's been great to be a part of this cohort, just from the interaction and willingness to help others that I have seen in Piazza and HipChat. I've done my best to help where I can as well, and give back to this same community.
As for this project, I have a little bit of styling to do on the main HTML page to make it look "better", and then cleanup of the commenting in the JS files. Hopefully by the end of the week, this project will be ready for submission.
I can't wait to see what comments I get on the final product.