Monday, March 17, 2008

Light Box Light Beam Segments

The LightBeamSegments class (lets call it the beam class for short) was created because when I was reviewing the light box code last weekend I realized that if I wanted to visually show the path that the light takes in the modern version of the game I would need to essentially duplicate a lot of code from the core game classes. I prefer not to do that so though of how I could change the shared game classes in such a way that I wouldn't need to duplicate that much code. That is when I realized that I could add a very simple structure class that held light information and actually keep a list of beam segments. The modern version would then be able to grab this list and simply loop through the list and draw all the beams to show the path of the beams. The beam class is a glorified structure in that it just stores information. An exception to this are the getDirection and exitSlot functions. The getDirection function determines the direction based on the end points of the beam. The exit slot function determines if the beam is exiting the box and if so which slot it is exiting from. In hind sight, I probably don't need this function as it really is only used by the core of the game and could have been implemented in the core where it is used.

No comments: