School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,395 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,597 people online right now. Registration is fast and FREE... Join Now!




Coding help needed. Level Restrictions

 

Coding help needed. Level Restrictions, Leveling issue with my game

pendingkill

17 Jun, 2009 - 10:28 AM
Post #1

New D.I.C Head
*

Joined: 17 Jun, 2009
Posts: 2

CODE
//level 2 - 500

//level 3 - 1500

//level 4 - 3500

//level 5 - 6000






function experience($L) {

  $a=0;

  $end=0;

  for($x=1; $x<$L; $x++) {

    $a += floor($x+1500*pow(4, ($x/7)));

  }

  return floor($a/4);

}



function Get_The_Level($exp) {

  $a=0;

  $end =0;

  for($x=1; ($end==0 && $x<100); $x++) {

    $a += floor($x+1500*pow(4, ($x/7)));

    if ($exp >= floor($a/4)){

    } else {
    
      return $x;

      $end=1;

    }

  }

}



function Get_Max_Exp($L){

$end=0;

if ($exp == 0){

    return 457;

    $end =1;

  }

    for($L=1;($L<100 && $end==0);$L++) {

      $exp = experience($L);

      //echo $exp;

      if ($exp >= $user_class->exp){

        return $exp;

        $end=1;

      }

    }

}



Now for the questions... I have been beta testing this game to make sure all the kinks are out of the game however noticed it is impossible to change the exp needed to level. I have tried to change some the the code to get it to work and it did not.. What am I doing wrong here?

I have been trying to get help from my college professor as well and quite frankly im up shits creek I think..

Thanks in advance.

pK


Attached File(s)
Attached File  EXP.txt ( 774bytes ) Number of downloads: 12

User is offlineProfile CardPM
+Quote Post


bsaunders

RE: Coding Help Needed. Level Restrictions

17 Jun, 2009 - 05:06 PM
Post #2

D.I.C Addict
****

Joined: 18 Jan, 2009
Posts: 554



Thanked: 42 times
My Contributions
What do you mean by change the experience points?
User is offlineProfile CardPM
+Quote Post

SixOfEleven

RE: Coding Help Needed. Level Restrictions

17 Jun, 2009 - 06:46 PM
Post #3

Code Guru
Group Icon

Joined: 18 Oct, 2008
Posts: 2,910



Thanked: 165 times
Dream Kudos: 725
Expert In: C, C#, XNA, Game Programming, Programming Concepts

My Contributions
QUOTE(pendingkill @ 17 Jun, 2009 - 12:28 PM) *

CODE
//level 2 - 500

//level 3 - 1500

//level 4 - 3500

//level 5 - 6000






function experience($L) {

  $a=0;

  $end=0;

  for($x=1; $x<$L; $x++) {

    $a += floor($x+1500*pow(4, ($x/7)));

  }

  return floor($a/4);

}



function Get_The_Level($exp) {

  $a=0;

  $end =0;

  for($x=1; ($end==0 && $x<100); $x++) {

    $a += floor($x+1500*pow(4, ($x/7)));

    if ($exp >= floor($a/4)){

    } else {
    
      return $x;

      $end=1;

    }

  }

}



function Get_Max_Exp($L){

$end=0;

if ($exp == 0){

    return 457;

    $end =1;

  }

    for($L=1;($L<100 && $end==0);$L++) {

      $exp = experience($L);

      //echo $exp;

      if ($exp >= $user_class->exp){

        return $exp;

        $end=1;

      }

    }

}



Now for the questions... I have been beta testing this game to make sure all the kinks are out of the game however noticed it is impossible to change the exp needed to level. I have tried to change some the the code to get it to work and it did not.. What am I doing wrong here?

I have been trying to get help from my college professor as well and quite frankly im up shits creek I think..

Thanks in advance.

pK


Did you create this formula, or did you find it somewhere else? You could try changing the 1500 in both functions to a different value. The problem is you might not get nice numbers like those above. You could try and write a new formula. I'll look into one that might help you.
User is offlineProfile CardPM
+Quote Post

frostyraver

RE: Coding Help Needed. Level Restrictions

24 Jun, 2009 - 06:44 PM
Post #4

D.I.C Head
Group Icon

Joined: 21 Apr, 2009
Posts: 73



Thanked: 2 times
Dream Kudos: 50
My Contributions
Why not put varibles on max level exp:

CODE

Level1MaxExp = 1500
Level2MaxExp = 3000
Level3MaxExp = 4500
Level4MaxExp = 6000

if currentexp = Level1MaxExp then do
current level++;
if current level > maxcharlevel then
currentlevel--;


Or why not just *2 the exp when you level

CODE


MaxLevelExp = 1500;

//do code here

// if the current exp is larger than maxlevelexp
if current exp > MaxLevelExp then
// increase the level by 1
Currentlevel++;
// timers the max level exp by 2
MaxLevelExp * 2;
// if the current level is above max level; max level being what you want your level cap to be
if Currentlevel > MaxLevel then
// then make the current exp 0 and max level exp 0
current exp = 0;
MaxLevelExp = 0;
else
current exp = 0;
// run the level up code if the current exp is 0 but not if max exp is 0
if CurrentExp = 0 && MaxExp != 0 then
run the level up code
else
don't run the level up code


Something like this, I imagine is what your after, feel free to recorrect my approach.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 09:58PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month