How do I fix EXP bar and level up

Get help using Construct 2

Post » Tue Oct 27, 2015 2:32 am

I have posted screenshots + GIF below. But basically, I have countEXP global variable, and it is set to 0 when the player levels up.
I have got when exp=>100, it'll level up to 2. I have done it all the way to level 3, and when at level 3, the countEXP starts from 0 and increases past 100, at which point it goes back to level 2.

Is there a way around this?

The events for the making of the exp bar:
gyazo.com/8b843efecc858b8164f19db7177a2acf

The events for the leveling up:
gyazo.com/b18c6700b73b8dee6d353c20fa726e1c

And the GIF of the problem:
gyazo.com/08f06b3b372c528797b691d4fb991035

(As you can see, level 2 to level 3 works fine. But of course because the countEXP gets set to 0 at start of new level(level3), it counts in 15 from 0, until it becomes =>100, which turns level 3 back to level 2.

Thanks in advance.
B
6
Posts: 40
Reputation: 336

Post » Tue Oct 27, 2015 4:54 am

try adding a condition level number variable = 2

and for level 3 level number variable = 3

If you read your code out loud if your exp reaches to the number 200 then go to level 2. But you have no condition that says I am in level 3 when the exp reach to 200.

A friendly tip a machine is dumber then a rock. We have to input exact logic for construct to behave the way we want to.
B
52
S
24
G
6
Posts: 391
Reputation: 7,845

Post » Tue Oct 27, 2015 1:09 pm

The easier thing to do would be make a simple function that sets a level variable base on experience level and let the experience variable go as high as it wants...

Ie. countEXP goes up as experience goes up and has no cap. The function compares countEXP and sets level variable based on countEXP value using a case type set up: countEXP <100 level=1; countEXP >100 but <200 level=2: countEXP >200 but <300 level=3: etc.

Then your main events can call this function anytime they need current level.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
69
S
18
G
8
Posts: 639
Reputation: 9,549

Post » Tue Oct 27, 2015 3:56 pm

chrisinfinger wrote:The easier thing to do would be make a simple function that sets a level variable base on experience level and let the experience variable go as high as it wants...

Ie. countEXP goes up as experience goes up and has no cap. The function compares countEXP and sets level variable based on countEXP value using a case type set up: countEXP <100 level=1; countEXP >100 but <200 level=2: countEXP >200 but <300 level=3: etc.

Then your main events can call this function anytime they need current level.


I've got 2 questions.
First, how do you compare global variables with functions? I can only add/subtract/set variables. Unless you meant I add the compare as a condition, but then I would need to make tons of those functions for each level.

Second, wouldn't the compare "countEXP <100 level=1; countEXP >100 but <200 level=2: countEXP >200 but <300 level=3: etc" give me the same problem?
I mean each time the character levels up, the countEXP is set back to 0. So when they are level 3, and countEXP gets set back to 0, and they keep earning exp, they'll go eventually reach to the point where countEXP >100 but <200 is true, thus set back the level from 3 back to 2.
B
6
Posts: 40
Reputation: 336

Post » Tue Oct 27, 2015 4:03 pm

Gearworkdragon wrote:try adding a condition level number variable = 2

and for level 3 level number variable = 3

If you read your code out loud if your exp reaches to the number 200 then go to level 2. But you have no condition that says I am in level 3 when the exp reach to 200.

A friendly tip a machine is dumber then a rock. We have to input exact logic for construct to behave the way we want to.

Wow that was simple XD Thanks so much!

Future reference for anyone:
gyazo.com/41c6009fbfa576dd24aae8b306d0790c
B
6
Posts: 40
Reputation: 336

Post » Tue Oct 27, 2015 10:09 pm

Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
69
S
18
G
8
Posts: 639
Reputation: 9,549


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests