Creating a game in Construct 3 with the GameScore plugin
You will find out how to add plugin, banners and leaderboard to your game. You will learn to work with player's saves.
As a basis, we will take an idea to tap the square more than anyone else in a definite time.
As soon as the player loses, he is offered the option to extend the game for 5 seconds by watching ads.
After completion, the player goes into a menu. There displays his best record, rating position and number of attempts. In the menu, you can start a new game and see the leaderboard.
Mechanics are implemented in 4 blocks:
- At the start of the game, we reset all states to default.
- Every second, while the timer is ticking, subtract a second from the timer and check if it is over. If it is so, then we check whether the player took the reward. If he did, then we end the game, otherwise we show the offer to watch the video.
- On click: +1 to taps, we update all the texts and paint the block in a random color. At the same time, we animate the block moving.
- If the offer to receive the bonus is open – either show the bonus or end the game, depending on the choice.
The game menu is also quite simple – we update counters before the start and add events to clicks. At this point this is only a preset.
#Add the plugin to the game
We create a new game on the panel.
Add the plugin to the game.
Turn off the worker mode in the project settings.
In the plugin settings, add the project ID and public token.
You can see them in the panel.
#Add the advertising
By default, the preloader banner is always shown when loading the game. This option can be disabled in the plugin settings. In my case, in order to exclude the overlapping of banners on each other, I will disable preloader, because the fullscreen will still appear immediately when entering the menu.
Add the sticky banner when entering the menu. It will be added only once and will update itself.
As well as, add a fullscreen banner when the entering.
Add a reward for watching a video.
It is important to note, before deciding whether to show the video viewing button, you can check is video available on the platform or not. In our example, if you have already received a reward or the video is not available, then we end the level.
#Save the progress
When completing a level, you need to save the player’progress. By default, the player has variable fields: name, avatar, score. But we need to add number of attempts number of attempts.
Go to the panel and find the Models section, then go to the player setting.
Next, add a new field, and mark it as Stats — now this field is numeric. In the game, we will refer to the field by key. In our example the key is attempts.
Add a translation to it.
Mark this field as important so that the player can orient towards it when choosing which progress to save, if it will be necessary.
Now, go back to the Construct. After completing the level, add +1 attempt (1), compare, if accumulated points beat the previous ones (2), then we will save the scored ones (3) and synchronize with the server (4).
#Display the player
Display the player’s best record in the menu, as well as his number of attempts and rating position.
#Display the rating
It is easiest thing to display the rating. In the plugin, select the Leaderboard: Open. We will sort it by score, from highest to lowest. Display the top-25 players, including the player on the first place, if he did not get into the leaders. Also display the attempts field in the table to see how many attempts the leaders took to achieve this record.
There will be only one action at the end.
The leaderboard is ready.