If I had to sum up this evening in one word, it would probably be rather profane, so I’m not going to do that. Instead, I’ll just use a sound. *sigh*.
Today’s goal was to finish the work from yesterday. In this game, each player is supposed to have their own set of 29 balls to push into the maze from above, although up until this point there has just been one set that both players share. The idea was to set up a couple of arrays that would store the top row layout of each players set of balls. Then as needed we could apply the contents of the array to the first row of the maze, showing the appropriate balls.
To this end the MazeContent object now creates such arrays and exposes them as properties for external code to modify. The maze generation code stores Ball entities it gets from the pool into the arrays, creating two complete sets of ball layouts. There are also some simple API methods to work with these.
FIrstly, the MazeContent entity has a field that tells it what players balls it thinks it is currently showing. It also has some hidden methods that allow it to copy the top row of the maze (containing the balls) into the appropriate array and copy the array into the top row of the maze. It also has a swap method, which first saves and then restores from the alternate array.
The Game scene uses these new powers so that when the player switches, the balls do to. At least, in theory.
I’ve spent over an hour trying to debug exactly where this is going wrong. The restore code can correctly restore the player balls or the computer balls right when it first starts up, but any attempt to swap results in an empty set of balls. Sort of. I’ve noticed that the computer player can still determine what move it needs to make and move there, but it can’t push the ball because it’s not there.
I think it actualy IS there, but for reasons I can’t fathom at the moment it is somehow hidden even when it’s not supposed to be, or something. All kinds of debug logs seem to indicate that it’s working with an actual entity and that actual non-null Ball entity pointers are being restored into the array, seemingly to no effect.
I’ve run out of time to bang by head on that today, so I’ll have to return to it tomorrow. I’m sure I’ll find that it’s something completely innocuous or something, but at the moment I’m just not seeing it.
I didn’t bother uploading the new compiled version to my own website due to the fact that it’s currently broken, and that’s no fun to play with. So it looks like tomorrow’s goals will be to fix this dratted bug. Depending on when or if that task gets completed I shall try to finish the rest of what I was going to do today, which involved actually checking to see if a player can take a move before giving them the opportunity to do so and generally fixing up the turn order and end of game state swapping.