Experience Bar Question

EricTippettEricTippett Member Posts: 45
edited July 2012 in Working with GS (Mac)
Hey Everyone,
I am currently trying to create an experience bar. I looked at the health bar tutorial, but the experience isnt a set number every level.
They way I have experience set up right now is in an attribute called Player1Experience. Then I made an rule on the Player1Actor that as an Attribute game.Player1Experience is greater/equal to 100 * game.Player1Level^3
So the experience is saved after each level towards the next requirement.

I was trying to think of some way to have the old experience goal = 0 width and then have the new experience goal = the full width of the exp bar (currently 600)

So how would I make an experience bar for this, since both the starting number and level up number change every level?

Best Answers

  • HC_DKHC_DK Posts: 92
    Accepted Answer
    I have made an example-file on how I would do it. Take a look at it and hopefully you will be able to make your own code work.

    This is made as an iPhone project, therefore the "Full Exp Bar"-attribute is set to 400. You can change it to whatever you like and the "Player Level" and "Exp Bar" is calculated automatic.

    Get the file here: http://dl.dropbox.com/u/12878764/Exp Bar.zip

    HC
  • HC_DKHC_DK Posts: 92
    Accepted Answer
  • HC_DKHC_DK Posts: 92
    Accepted Answer
    Great :-)

    Do you want another BAR or combine HP and XP into one BAR?
  • HC_DKHC_DK Posts: 92
    Accepted Answer
    First, I would NOT combine those two :-) But that is your call....

    Try to solve the HP bar yourselves and if you run into trouble, let me know. I wanna help BUT helping is not the same as making the code :-) And you will learn a lot more by doing it yourselves.

    You can use a lot of the "code" in the Exp Bar-example or else have a look at:




    HC

Answers

  • EricTippettEricTippett Member Posts: 45
    Oh and I got it to restart every level with this
    Constrain Attribute: self.size.Width = game.Player1Experience - (100*(game.Player1Level-1)^3)

    However, I need it to fill up to 600 pixels wide and 600 would be the bar at 100% experience. So how could I tell it to fill up according to that?
  • EricTippettEricTippett Member Posts: 45
    Thanks, I downloaded it and saw how you created it. I noticed it is always 400 exp needed, but in mined the needed exp changes every level.

    So for mine the width of the bar is 0 - 600 pixels.
    The start point of the bar at 0 px would be the last levels exp goal so 100 * (game.Player1Level - 1) ^3.
    The end point of the bar at 600 pixels would be 100 * (game.Player1Level)^3.

    Do you know how I would create that since the start and end is always changing and isnt a set number?
  • EricTippettEricTippett Member Posts: 45
    Hey Thanks! Yeah its working perfect now!
    Do you think this would work for when I get to HP bars that will also have a max value that will change every level gained?
  • EricTippettEricTippett Member Posts: 45
    I was going to have another bar as an HP bar. But every time the player upgrades the HP (using currency found in the game), the HP would have a new max HP and the bar would have to notice that.

    But just wondering since you mentioned it.. how would you combine a HP bar into a XP bar lol? Wouldnt that be a weird mechanic, so instead of losing life when hit you lose XP?

    Thanks for helping me out by the way!
  • EricTippettEricTippett Member Posts: 45
    Oh lol yeah I watched those a couple days ago. I made a basic health bar but I was just trying to apply this upgradable hp aspect to it.
    But yeah I was able to create a HP and Energy bar with your method, so thanks!
  • HC_DKHC_DK Member Posts: 92
    @EricTippett: Great you got it working :-)
  • raze_struckraze_struck Member, PRO Posts: 141

    @EricTippett said:
    Hey Everyone,
    I am currently trying to create an experience bar. I looked at the health bar tutorial, but the experience isnt a set number every level.
    They way I have experience set up right now is in an attribute called Player1Experience. Then I made an rule on the Player1Actor that as an Attribute game.Player1Experience is greater/equal to 100 * game.Player1Level^3
    So the experience is saved after each level towards the next requirement.

    I was trying to think of some way to have the old experience goal = 0 width and then have the new experience goal = the full width of the exp bar (currently 600)

    So how would I make an experience bar for this, since both the starting number and level up number change every level?

    Im curious, could you be more specific regarding the attributes you're using in your game, I wanted to implement the same method, I'm not looking for an experience bar at the moment, just the logic behind tracking experience and leveling up.

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
  • raze_struckraze_struck Member, PRO Posts: 141

    :( ..ok

  • raze_struckraze_struck Member, PRO Posts: 141

    you don't have to be mean..... ;)

Sign In or Register to comment.