Have you ever wondered how to make an effective scoring system? Well, don’t be worried, just follow this tutorial step by step and you are going to get the best scoring system ever. If you felt stuck or confused just download the (.capx) file and see it. Note that following the tutorial and applying it will help you understand the idea and the tutorial rather just seeing the (.capx) file.
Before We Start
Before we start to make the scoring system we need to make a game first of course. The game is too simple that it can be made in 15 minutes. It has a simple concept; just click on screen so the player won’t fall down or fly up away. First, open Construct2 and name the project “Don’t fall” then go make three layout with size of (640, 480), (or you could just duplicate it). Then name the three layouts the following:
1- “Menu” 2- “Leader board” 3- “Game”
Now after we have made those three layouts we can now design each one of them and add the necessary components for it.
Layouts Design & Components
Let’s start with the first layout “menu”. To begin with add a text plug-in and name it “Title”, choose any font type but set font size to 28. Then position it to (320, 32). Add 2 buttons plug-in, 1- “Play” 2-“Leaderboard”. Set “play” button position to (285, 173), and “Leaderboard” button’s position to (272, 232).
Let’s work on the second layout “leaderboard”. Copy the “title” text and add it to the layout with the same position. Next, Add five Texts plug-ins: “HS1”, “HS2”, “HS3”, “HS4”, and “HS5”. Position “HS1” to (362, 125) then for the next text add 100 to height and so on. Add button plug-in and name it “Goback” at position (15, 442).
Third, it’s time for the last layout “Game”. Add Sprite with name “Player” and edit the image, resize to (50, 50) then fill it with any color (I chose red). Now it looks like a box. Add for it a behavior “Physics”. Add a new text called “Text” at position (5, 5), then add for it an instance variable; name it “Score” with value of (0).
The building blocks
Now it’s time for some action in the events panel. We will work now on the basic or (main) logic and events that will make the game work. Add global variables: “FirstH1”, “FirstH2”, “FirstH3”, and “FirstH4”. Then add more global variables: “HS1”, “HS2”, “HS3”, “HS4”, and “HS5”.
Now add two groups: “Main Logic” and “Scoring System”, we will start with the first group.
- Add condition: “play” on clicked Action: “System” Go to layout “Game”
- Add condition: “Leaderboard” on clicked Action: “System” Go to layout “Leaderboard”
- Add condition: “Goback” on clicked Action: “System” Go to layout “Menu”
- Add condition: “Mouse” on left button clicked Action: “Player” apply physics force (100) at angle (270) at image point (0)
- Add condition: Every tick Action: “Text” Set text to (“Score: “&Text.Score)
For the condition every tick, we are going to add 10 sub-events, so follow up step by step:
- Add condition: “System” “HS1” (as global variable) = (0) Action: “HS1” (as a text) set text to (“1.”)
- Add condition: “System” “HS2” (as global variable) = (0) Action: “HS2” (as a text) set text to (“2.”)
- Add condition: “System” “HS3” (as global variable) = (0) Action: “HS3” (as a text) set text to (“3.”)
- Add condition: “System” “HS4” (as global variable) = (0) Action: “HS4” (as a text) set text to (“4.”)
- Add condition: “System” “HS5” (as global variable) = (0) Action: “HS5” (as a text) set text to (“5.”)
- Add condition: “System” “HS1” (as global variable) > (0) Action: “HS1” (as a text) set text to (“1. Score:”&HS1)
- Add condition: “System” “HS2” (as global variable) > (0) Action: “HS2” (as a text) set text to (“2. Score:”&HS2)
- Add condition: “System” “HS3” (as global variable) > (0) Action: “HS3” (as a text) set text to (“3. Score:”&HS3)
- Add condition: “System” “HS4” (as global variable) > (0) Action: “HS4” (as a text) set text to (“4. Score:”&HS4)
- Add condition: “System” “HS5” (as global variable) > (0) Action: “HS5” (as a text) set text to (“5. Score:”&HS5)
The second group will be in the next heading. The following events in this group is just simple buttons and readings, it has nothing with the scoring system.
The Scoring System
Hooray! We have finally reached our destination and our main purpose with is the scoring system. Now add events on the group “Scoring System”, we have 4 “FirstH” global variables, why? That is because it differ if the high score is at the first time or the high score is higher than other high score. While the global variables “HS” are for saving the high score of course.
To not mix between first time high-score or a new high-score is higher than an old high-core, the following settings are necessary:
- Add condition: “System” “FirstH1” = (3). Other condition: “Title” is visible. Other condition: “System” trigger once. Action: “System” set “FirstH1” to (2)
- Add condition: “System” “FirstH2” = (3). Other condition: “Title” is visible. Other condition: “System” trigger once. Action: “System” set “FirstH2” to (2)
- Add condition: “System” “FirstH2” = (3). Other condition: “Title” is visible. Other condition: “System” trigger once. Action: “System” set “FirstH2” to (2)
- Add condition: “System” “FirstH4” = (3). Other condition: “Title” is visible. Other condition: “System” trigger once. Action: “System” set “FirstH4” to (2)
Now we need to set that when the player is outside layout, the scoring system starts to work and then go back to the “Leaderboard” layout.
- Add condition: “Player” is outside layout Action: “System” Go to “Leaderboard”
For the player outside layout condition we need to add 9 sub-events:
- Add condition: “System” “Text.Score” > (HS1). Other condition: “FirstH1” = (1) Action: “System” set “HS1” to (Text.score). Other action: “System” set “FirstH1” to (3)
- Add condition: “System” “Text.Score” > (HS2). Other condition: “FirstH2” = (1). Other condition: “Text.score” < (HS1) Action: “System” set “HS2” to (Text.score). Other action: “System” set “FirstH2” to (3)
- Add condition: “System” “Text.Score” > (HS3). Other condition: “FirstH3” = (1). Other condition: “Text.score” < (HS2) Action: “System” set “HS3” to (Text.score). Other action: “System” set “FirstH3” to (3)
- Add condition: “System” “Text.Score” > (HS4). Other condition: “FirstH4” = (1). Other condition: “Text.score” < (HS3) Action: “System” set “HS4” to (Text.score). Other action: “System” set “FirstH4” to (3)
- Add condition: “System” “Text.Score” > (HS5). Other condition: “FirstH5” = (1). Other condition: “Text.score” < (HS4) Action: “System” set “HS5” to (Text.score)
Now we have finished 5 out of 9 sub-events and they are used to determine high-score for the first time. Now it’s time for the “new High-score higher than old high-score” events, continue doing sub-events of the last ones:
- Add condition: “System” “Text.Score” > (HS1). Other condition: “HS1” > (0). Other condition: “FirstH1” = (2) Action: “System” set “HS5” to (HS4). Other action: “System” set “HS4” to (HS3). Other action: “System” set “HS3” to (HS2). Other action: “System” set “HS2” to (HS1). Other action: “System” set “HS1” to (text.score)
- Add condition: “System” “Text.Score” > (HS2). Other condition: “text.score” < (HS1). Other condition: “HS2” > (0). Other condition: “FirstH2” = (2) Action: “System” set “HS5” to (HS4). Other action: “System” set “HS4” to (HS3). Other action: “System” set “HS3” to (HS2). Other action: “System” set “HS2” to (text.score).
- Add condition: “System” “Text.Score” > (HS3). Other condition: “text.score” < (HS2). Other condition: “HS3” > (0). Other condition: “FirstH3” = (2) Action: “System” set “HS5” to (HS4). Other action: “System” set “HS4” to (HS3). Other action: “System” set “HS3” to (Text.score).
- Add condition: “System” “Text.Score” > (HS4). Other condition: “text.score” < (HS3). Other condition: “HS4” > (0). Other condition: “FirstH4” = (2) Action: “System” set “HS5” to (HS4). Other action: “System” set “HS4” to (Text.Score).
Finally Finished
Congratulations for finishing the whole tutorial! We have just learned now how to make an effective and really awesome scoring system. Stuck or confused on this tutorial? Like what I say you can always download the (.capx) file!