Today’s plan was to tweak the level generation a little bit more to try and make it more appealing. More specifically I wanted to get a more even distribution of how everything is placed into the level; at the moment it’s either very even or very clumpy, and it would be nice to have a “somewhat even” level in there. However, this did not go according to plan.
Basically I spent some time trying out a few ideas, trying to spread the random distribution out better so that at least the position of everything would be just a bit more uniform. I tried various methods but I was not really pleased with any of the results. So I abandoned that before I ended up blowing my entire night futzing with things.
As it stands, the generation of the level is good enough to continue on with the project, so in an effort to not get lost in the minutia of level generation and stall everything out, I moved on to the next step, which is having the ball able to pass through the maze from the top to the bottom.
The first step was to create a Ball entity, which wraps the state and animations needed for this purpose. Since the ball is part of the scoring mechanism of the game, it also has a score property that represents how much it’s worth at scoring time (either when it reaches the goal or at the end of the game if it doesn’t get all the way to the bottom). This is currently unused, but going forward it will be possible to display this value on the ball so it’s easy to see what the scoring is going to be.
In order to facilitate testing of this code, I have added in the ability to click on the stage with the mouse. If the click happens within the maze itself, the click position is forwarded to the Maze entity for handling. Currently this causes arrows to flip and bricks to vanish or appear, depending on what you click on. For the time being it also makes the balls appear to vanish, although that’s just a place holder to verify things are working as expected.
While implementing this I discovered a slight bug in the level generation code; it was pulling the bonus bricks out of the gray brick pool, which means that although it visually looks right (due to it playing the bonus brick appear animation), the underlying type of the brick is wrong. I’ve fixed this now.
For the next step I’ll be adding in the ability for the ball to travel through the maze, being directed by the contents of the maze as appropriate. This is going to require some underlying structural changes, but I’ll try to make those on an as-needed basis.
For example, currently when bonus or gray bricks vanish, they are still technically there, just not visible. They should be removed once their animation is finished playing. Also the black holes are all visually represented by the same entity but their locations are not stored anywhere. That means that in order to jump the ball to another black hole we would have to scan the maze to find one, which seems inefficient.
I hope to get the basis of the ball movement done by the end of the day tomorrow, although this will probably not take all of the little details into account. Something I have to keep in mind is that for the AI to be able to select a move, this process has to be pre-calculated so that we can try and determine what the optimal move is at the current time.