How do I keep the best score!!!

Get help using Construct 2

Post » Wed Oct 07, 2015 6:53 pm

Ok the title is a bit awkward. I really don't know how to make a title but i can explain what my problem is....

I have a game with many levels. On each finished level you get STARS as your score. 3 STARS is best score.... So lets say I finish a level with 2 STARS and I wanna repeat it.The next time I do worse and end up with one STAR. Score for that level now shows 1 STAR which is a problem... I want it to keep my best score so that everytime I do worse I'd have my best score not the current one I got.
B
10
S
1
Posts: 39
Reputation: 588

Post » Wed Oct 07, 2015 9:40 pm

1st You'll need a bunch of variables here, or a vector. I'll explain how to use the variables, you can check out array tutorials later on if you want to learn to use the tools construct2 offer you.

2nd You can easily figure this out by yourself by studing the construct2 manual and reading tutorials. It's a good thing to understand about construct2 before trying to create your algorithms.

3rd here we go.
You will need a variable to keep track of the maximum amount of stars the player acquired each level, StarLevel1, Starlevel2, StarLevel3 and so on. Or you can create a single array to save all of them but whatever.
You will also need a variable to keep track of the amount of stars, or score that the player manage to reach in that specific level. Lets call it "CurrentScore" for now.

So what you want to do is, every time the player finishes a level, you save his new score at the "CurrentScore" Variable, and then AFTER that, you go and check if the value at the "CurrentScore" is bigger or lesser than the value on the "StarLevelX" that keeps track of the max score, and do the changes accordingly .

The code sheet would go something like this:

add action > system > set value :
Variable : Stars
Value : currentScore > stars? Currentscore : Stars
B
17
S
7
Posts: 277
Reputation: 2,514

Post » Thu Oct 08, 2015 12:03 am

You need a "Island" load out where you go between levels to share data.

In that level have an array that you load from local storeage with the score first on the top of the X axis. On the Y axis under the score have the player name who got that score.

At that point you can do an array "Sort" action on the X axis, this will sort them from highest to lowest.

You might not need the "island level" but it makes it easy to break things up, so you game does not get too cluttered. It also can add some charm to the game like how Super Mario world, and Yoshi island is between levels. This also gives your player a chance to take a break and mull over their scores.
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Thu Oct 08, 2015 10:17 pm

Checked some tutorials and used the array for it... Works like a charm.
Appreciate the help :)
B
10
S
1
Posts: 39
Reputation: 588

Post » Fri Oct 09, 2015 2:48 am

Glad to help :)
B
29
S
8
G
4
Posts: 767
Reputation: 5,985


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 14 guests