Jump to content


Photo

Exp bar difficulties


  • Please log in to reply
6 replies to this topic

#1 Tolemi959

Tolemi959

    GMC Member

  • New Member
  • 20 posts
  • Version:GM8

Posted 07 August 2012 - 05:26 PM

Hi there, I am having a few difficulties regarding my experience bar. For one, I do not want it to reset the variable ''exp'' to zero every time I gain a level. And second the bar doesn't fill up correctly. It's always filled up 100% whenever you reach 100 exp or more. This is how it currently looks like:

Create:
global.lvl = 1
global.speed = 3
global.power = 0
global.expmax = 100
global.exp = 0
global.life = 100

Step:
if (global.exp>=global.expmax)
{
global.lvl+=1;
global.speed+=1;
global.power+=1;
global.expmax+=50;
global.exp = 0
global.life=100;
}

Draw:
draw_healthbar(view_xview + 190,view_yview + 450,view_xview + 300,view_yview + 465,global.exp,c_gray,c_green,c_yellow,0,1,1)
  • 0

#2 Merlocker

Merlocker

    No Imagination

  • GMC Member
  • 450 posts
  • Version:GM8

Posted 07 August 2012 - 05:34 PM

You do know that exp power speed are built in functions/constants right? Try to use different variables. eg spd=speed xp=exp pwr=power
  • 0

#3 Tolemi959

Tolemi959

    GMC Member

  • New Member
  • 20 posts
  • Version:GM8

Posted 07 August 2012 - 05:38 PM

You do know that exp power speed are built in functions/constants right? Try to use different variables. eg spd=speed xp=exp pwr=power


I figured, but I highly doubt this will resolve my current issue.
  • 0

#4 Merlocker

Merlocker

    No Imagination

  • GMC Member
  • 450 posts
  • Version:GM8

Posted 07 August 2012 - 05:40 PM

http://learnbyluke.com/ has great tutorials for bars and such

Edited by Merlocker, 07 August 2012 - 05:41 PM.

  • 0

#5 Tolemi959

Tolemi959

    GMC Member

  • New Member
  • 20 posts
  • Version:GM8

Posted 07 August 2012 - 07:01 PM

http://learnbyluke.com/ has great tutorials for bars and such


Didn't find any solution.
  • 0

#6 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5417 posts
  • Version:GM:Studio

Posted 07 August 2012 - 07:24 PM

if (global.exp>=global.expmax)
{
...
global.exp -= global.expmax; // lower it with what you need
global.expmax+=50; // then increase the need
...
}

for the healthbar:
... , global.exp / global.expmax * 100 , ...
the max value is 100 .. so if you divide exp/max_exp then multiply it with 100, then you have the percentage of how full the bar is
  • 0

#7 Katuko

Katuko

    GMC Member

  • GMC Member
  • 5014 posts

Posted 07 August 2012 - 09:37 PM

First, to avoid the EXP resetting to 0... simply not reset it to 0. There is a line right there that says "global.exp = 0;" in the level up bracket. Remove it.

The second problem is because draw_healthbar() uses a percentage, so it only ranges from 0 to 100. Convert your value to a percentage to fix this. Since you don't want EXP resetting to 0, you'll need another variable to hold the relation between the current EXP, the max EXP and the amount you needed for the previous level.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users