Sunday, October 19, 2014

Refactoring!



When we first began the capstone project, we didn't really address or plan out the system architecture much, which has now come back to bite us in the dick.

Many sub-systems, like the power-up system and the GUI components are very well organized and implemented. The player movement, racket swinging, and racket tossing however, was just plain awful. It was a twisting nest of crossed wires and poorly architected code.



So I spent today's game dev club work session refacotring all of it. Instead of having a boolean switch and dozens of if statements to decide which player we're talking about, I wrote an abstract base player class, and wrote subclasses for Player 1 and Player 2 that inherited the base class. This very basic object-oriented design was something we should have done from the get-go, but since most of the actual work was already done it wasn't too difficult re-writing everything.

No comments:

Post a Comment