I’ve managed to refactor my Godzilla simulator taking advantage of the sample code and structure provided to us in our last lab. I’d be lying if I said I understood everything going on in the code that was provided, but I’ve got a decent grasp on the way things are structured both in the code and in the directory hierarchy provided. My biggest improvement is using the provided GameUnit class and having all of my other classes, both animates and inanimates, subclassing it. I was also able to finally get crude graphics implemented so that I can start to get some visual feedback on the things that are happening. Right now I just have various animate and inanimate objects being displayed on the canvas, but most actions are still being outputted as text. My enemy animates are currently using the random movement code provided while my main character Godzilla can be moved around the screen using the arrow keys. I plan on also mapping his attack ability to a key press but I’m not completely sure how to achieve that at the moment.
I’ve starting planning out how to utilize the state pattern and I’ve hashed out a bit of code in a separate project to test it out. So far, so good but there are still some details I need to work out. I didn’t go overboard with this refactoring, as far as behaviors and interactions are concerned, because I already know I’m going to change a number of things with my use of the state pattern. I wasn’t far enough along with some of those ideas to implement them in time for this assignment though, so I opted to do some things in the refactoring that I know will change. The main thing is the way I’m currently making use of the strategy pattern to set/change behaviors will likely be completely overhauled when the state pattern is implemented. I’m also not currently making use of the decorator pattern and struggling a bit to make good use of it in my program. I was considering using it to maybe change the images dynamically (say change Godzilla to Godzilla with fireball when attacking, for example), but I’m not sure if it makes more sense or not to have images change using the state pattern (if Godzilla switched to an attackState).
Another thing that I’d like to have happen is for my destructible objects (both animate and inanimate) to appear randomly throughout the game world rather than having to create and place them in the driver. I really have no clue how this is achieved though, or if it’s reasonable for this project.
Overall I feel like I’m making some positive progress and maintaining a grasp on the program even though it keeps growing in complexity.