Already I’ve improved the movement of the Player and the Ball.
Essentially, what I am supposed to do is make any moves, then walk through the Kyra Tree, then check for collisions and respond accordingly; however, my hardcoded movement code moved the Player, then walked the Tree, then moved the Ball and checked for collisions. The Player worked out just fine, but the Ball would get stuck in the Wall.
Then I changed it so that the actual movements wouldn’t happen until the update code ran. When you push the arrow keys, the Player’s Direction changes accordingly. It will only change positions during the update, and it does so at the same time as the Ball. Then I walk the Tree, and so collision detection is a bit more accurate.
Also, the Player only moves in four directions now, so it isn’t possible to move twice as fast on a diagonal. For this game, not being able to move diagonally shouldn’t be a problem, but an adventure or action game might require such movement in the future.
The Ball currently changes Direction when it hits a Wall. It’s actually kind of cool to watch the Ball bounce back and forth between the Walls. If I start adding more Walls throughout the middle of the level, it could actually be fun.
It’s amazing what can be done when you don’t have to worry about ruining the code base. I’ve been using Subversion all this time, but psychologically I’ve been concerned about doing the wrong thing. I basically convinced myself that I’m going to be writing code that needs debugging anyway, so the “wrong thing” will most likely be a bug that needs to be fixed to make the right thing. So far, I haven’t had to rewrite whole sections of code, or if I had, I haven’t noticed it as hard work.
Thanksgiving is here, and I’ll be out of town for the rest of the week/weekend. I’ll probably have a bunch of spam comments to delete, and I won’t likely have time this weekend to approve any. Still, keep the comments coming. I love the feedback. B-)