As probably most of you already know, or recently found out, at the beginning of this week the GSoC coding period officially ended, and it is time for us, GSoC students, to submit our final evaluations and the results we achieved thus far. This blog post, as you can probably tell from the title, will be a summary of all of the work I put into modernising Five or More throughout the summer months.
My main task was rewriting Five or More in Vala since this simple and fun game did not find its way to the list of those included in the Games Modernisation Initiative. This fun, strategy game consists of aligning, as often as possible, five or more objects of the same shape and color, to make them disappear and score points.
Besides the Vala rewrite, there were also some other tasks included, such as migrating to Meson and dropping autotools, as well as keeping the view and logic separated and updating the UI to make this game more relatable for the public and more fresh-looking. However, after thoroughly discussing the details with my mentor, Robert Roth (IRC: evfool), more emphasis was placed upon rewriting the code to Vala, since the GSoC program is specifically designed for software development. However, slight UI modifications were integrated as to match the visual layout guidelines.
Some of the tasks, namely porting to gettext, porting to Meson and dropping autotools happened earlier on, during the pre-GSoC time frame, in the attempt to familiarise myself with the project and the tasks that would come with it.
Afterward, I started with the easier tasks and advanced towards the more complex ones. At first, I ported the application window and the preferences menu and added callbacks for each of the preferences buttons. I then continued with porting the preview widget displaying the next objects to be rendered on the game board.
Next, it was time to channel my attention towards porting the game board, handling board colour changes and resizing the board alongside the window resize, by using the grid frame functionality inside the libgnome-games-support library.
The following target was implementing the actual gameplay logic, which consisted of a pathfinding algorithm based on A*, erasing all objects of the same shape and colour aligned in a row, column or diagonal from the board, if there were either five or more than five, and adding to the score whenever that happened. I also made the object movement possible with both clicking and keyboard keys, for more ease of use.
Finishing touches included adding the high scores tables via the libgnome-games-support library, displaying an option to change the theme of the game, adding a grid to be able to make out easier the actual cells in which different shaped and coloured objects should reside, as well as updating some information contained by the help pages.
Some features, however, could not be done during the GSoC period. These included handling raster game themes, making significant UI updates, as well as some other extra-features I wanted to add, which were not part of the original project description such as gamepad support or sound effects. The fist feature mentioned in this list, handling raster images was decided upon skipping as a suggestion from my mentor, as the existing raster themes were low-resolution and did not scale well to large size and HiDPI displays.
For easier reading, I decided to also include this list of the tasks successfully done during GSoC:
Ported from autotools to Meson
Ported application window and preferences menu
Added callbacks for all buttons
Ported widget of next objects to be rendered on the game board
Handled the resize and colour change of the game board
Implemented the gameplay logic (pathfinding, matching objects and calculating scores)
Made gameplay accessible for both mouse clicks and keyboard controls
As Google Summer of Code is officially drawing to an end, all of my attention was focused towards making the Five or More Vala version feature-complete. As you probably already know from my previous blog post, the game was somehow playable at that time, but it was missing some of the key features included in the old version.
So what’s new this time? First and foremost, you can surely notice the game board now sports a grid, which wasn’t there until now. On the same note, there are also animations used for clicking a piece on the board, for an improved gaming experience. For further accessibility, some header bar hints are available at different stages in the game: at the start of any new game, at the end of each game, as well as whenever there is no clear path between the initial position and the cell indicated by the user for the current move.
Overall final game look
By using libgnome-games-support, I was able to implement a high scores table, which gets updated each time the player gets a score ranging in the top 10 highest scores for the chosen board size. The high scores for each of all of the three categories can also be viewed as showed in the screencast below. Also, you can see I have done quite my fair share of testing the functionalities and assuring everything worked as planned 😄.
Further changes include theme changing, although this momentarily only works for the vector themes available in Five or More, namely the ball and shape themes, as implementation for raster images is not fully functional as of this moment.
Also, now window size is being saved in between runs, so each time the game starts it will take into consideration the last window size settings, including wether the window was full screened or not.
As for the most exciting change revealed in this blog post, it concerns playing Five or More using keyboard controls. Basically, the user can play the game by navigating with the keyboard arrows, the home, end, page up, page down and space, enter or return keys, as described in the wikipage section for using the keyboard.
Playing Five-or-More usig keyboard controls
If you have been following my journey with GSoC up closely, you probablly remember me mentioning something about extra-features in my first blog post, such as adding gamepad support, sounds, or making some design changes. I need to say I feel optimistic about getting some of these features done in the weeks to come, post GSoC. I feel the ground has been already laid down somehow for gamepad support by adding keyboard controls. Also, Five or More has already undergone some slight design changes, such as widget spacing and alignment.
These past two weeks I have worked on (probably) the most exciting part of modernising the Five or More game. After the new changes, the game is officially playable and fun! But still, there is room for more changes. So let’s jump right to the updates.
First of all, if you remember reading my previous blog post, there were no means to interact with a shape, or otherwise move it to any desired cell. The cells inside the game board were filled up randomly on click, using the queue on the top left corner of the window, which contained the next shapes to be rendered inside the game area.
Now, all of that changed, and the user can interact with each individual shape rendered on the game board. The pathfinding system I came up with uses the A* algorithm with a Manhattan distance heuristic to determine the shortest path from the current cell to the destination cell chosen by the player.
Player interaction with shapes
Next, I continued to work on making five (or more 😄) shapes of the same kind aligned in a row, column or diagonal, disappear from the board…
Matching five or more shapes in a row
… and whenever that happens, the player receives points as a result, which are displayed on the top-right corner of the window.
Once I reviewed the screen recordings, I realised I am actually not as good at playing this game. 🙈
Over the course of the past couple of months, I was able to achieve a promising progress in modernising Five or More, although I would have to say there is a fair share of aspects to tackle yet.
I opted for rewriting the code module by module, without combining C and Vala code. There was was an old attempt to port Five or More to Vala, but I chose not to use it due to the fact that the partial port was 4 years old and it definitely needed an update, which might have taken quite some time, and might have produced some nasty bugs. While doing so, I paid extra attention to keep things nicely separated: all of the currently ported modules separate the game logic from the drawing logic and the UI.
I also managed to port the app menu and the preferences window. However, due to the new design gudelines, which are currently only in the state of a proposal, the app menu might require future alterations.
App Menu access with functional callbacks
The app window is currently resizable and it sports a customisable coloured board. After each click, the next shapes contained inside the next pieces widget are being spawned inside the game board.
Changing the board colour from the Preferences menu
Changing the board size from the Preferences menu and resizing the window (for some reason there is a colour flick when recording the screen for this one)
Clicking inside the game board area
I am currently working on the pathfinding algorithm, which will basically allow the user to move a shape from cell A to cell B inside the game grid.
The short todo list includes adding the game over logic and implementing both the scores and high scores system, by using the libgnome-games-support. There are also some extra-features to be added, such as animations, sounds and gamepad-support, and providing a fresh looking UI.