Blog: Week 2

Week two was a busy week. I spent Monday and Tuesday designing the object I would be using. I imagined what functions and variables they might have and how they ought to relate to each other. This document is a representation of what the objects are meant to do right now, during week 2. New versions of the document will be included in future blog posts as the project grows. To summarize, the game is made up of a Track who owns a Train and several Sections. Sections own a Path and a Path is just a parent for several waypoints. On Wednesday I began coding the objects. I was able to complete all of the code but unsurprisingly there were bugs. The biggest bug had to do with sections. In the game there were two section objects with different two different paths attached. The track object seemed to be able to find both section objects because it listed the number of sections as two, however, when explicitly listing the paths included in each section the paths were identical. You can see that through the screen shot included below.

On Thursday with the help of Dr. Diederich I was able to finally resolve the error. Originally there was only one path in the game and so the variable to hold the waypoints in the path was static. Unfortunately when I transitioned to having multiple paths I forgot to remove the static variable which meant that all the paths were sharing the same memory for that variable. After fixing this and one very simple to find index out of bounds error the train was back to running like normal but was also locking and unlocking sections as it went around.


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

css.php