Day 42 - life, the universe, and everything
Last week Ned offered to do individual code reviews with anyone that was interested. I took him up on that offer today, getting into class an hour early to go over my game center project, Hierarchy. I caught him up to on the state of things and then we went over the best way to lay the project out - what I was doing well and what could be better. The biggest takeaway was that my view controller was handling too much of the logic that should rightly belong to model classes. Specifically he suggested a game state class as well as a player class. All good advice. I'll try to implement that during my free time this week.
Class began without a lecture but instead with instructions to research core motion on our own, and use it to create a labyrinth game. Â Core motion is the framework that controls motion detection such as tilting the device in any direction (as well as a number of other things). Our task for today was to create a ball that could roll around the screen without going off, a goal that would indicate winning the game, and walls that would block the ball from moving in that direction. Our task for tomorrow is to use Game Kit to turn the regular labyrinth game into a multiplayer version where one player chases and attempts to catch another player's ball. Apparently that's the version that Ned remembers playing as a kid. Â Somehow he was deprived of any knowledge of the original where there's only 1 ball, and the goal is to avoid falling in the pits on your way to the goal. Â His version sounds better though because it means you get to play with others, instead of all alone, in a corner, whimpering softly.
In any case, it's a fun project. Getting the ball to move and stay on screen was fairly easy as was creating a 'goal' with a win scenario, but getting the ball to move smoothly when encountering walls has proved a lot trickier. Our ball currently bounces whenever it is up against a wall and doesn't stop bouncing until you move it away. At least it knows where the walls are. Tomorrow we'll get the walls working in a less epileptic manner and then work on integrating the game with game center's peer to peer network.Â
After class I spent time refactoring Hierarchy, trying to follow some of Ned's suggestions. Â I've created a player class and I'm currently moving all of the player logic into that class. Â It's slow going as I test frequently to make sure I'm not breaking anything.