Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Sleipnir

n00b question

This topic is 5655 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i´m doing a text adventure game, but i´m trying to put some thing like leveling up per battles and movement, so i´m wondering if someone can help me with this things, how do i do so the levels go up depending on the exp gaining (something i already did) and how do i create a world so the person can move, is there a way to use a refencen or a map, or a image? thx for the feedback ---------------------------------------------- "Nearly all men can stand adversity, but if you want to test a man´s character give him power" -Abraham Lincoln

Share this post


Link to post
Share on other sites
Advertisement
your best bet for a map would be a simple text file first.

Use notepad, make a 8 x 8 (I tend to love 8 x 8) stuff. Put 0 for walls, and 1 for paths.. then just removes the newlines and put it back on one line.... load the file and draw stuff to screen.

leveling up... something like,

exp += killxp;

if (exp > levelCap)
{
level++;
levelCap = //stuff to figure next level''s cap
}

or am i missing your point..






website coming soon

Share this post


Link to post
Share on other sites
For a simple map I'd use a 2d array with each cell using a reference index to a part of a text file (or just a certain part of a program) that loads in that area description, encounter, etc.

For experience and levels, add integer "XP" and "level" variables to your character, and XP amounts to your enemies "enemyxp". Use an array to hold levels and xp amounts for them. Here's an example:

int levels[6] = {0, 1000, 2000, 4000, 8000, 16000};

After you kill a monster, have this:

XP = XP + enemyxp;
if (XP >= levels[level+1])
{
level++;
... // do level gain stuff, add life, add attack rating, etc.
}

If there's a chance of a character ever gaining more than 1 level from a single enemy, you'll need to replace that if loop with a while loop.

(silencer)

Sleipnir: If you checked out that code I posted for that tiny game in the "Text Adventure.." thread, I added the random number seed code I forgot to include. You'll need to have that in your game if you don't already.

Edit: Here's that if in while loop form.

while (XP >= levels[level+1])
{
level++;
... // do level gain stuff, add life, add attack rating, etc.
}

[edited by - -silencer- on March 30, 2003 12:13:34 AM]

Share this post


Link to post
Share on other sites
quote:

If there's a chance of a character ever gaining more than 1 level from a single enemy, you'll need to replace that if loop with a while loop.


I'd recommend you make it so that that can't possibly happen.

[edited by - ChildOfKordova on October 11, 2017 10:32:23 AM]
weird

[edited by - kordova on March 30, 2003 12:08:03 AM]

Share this post


Link to post
Share on other sites
ok thx for the replies andi´m wondering in the

int level[6] = {0, 1000, 2000, 4000, 8000, 16000};

the first number ( 6 9 is the number of "levels" that a player can get right, and the other numbers are the exp points that a player need to get to level up

----------------------------------------------
"Nearly all men can stand adversity, but if you want to test a man´s character give him power"
-Abraham Lincoln

Share this post


Link to post
Share on other sites
Yeah.. the first number, 6 is the total elements in the array.

levels[0] = 0
levels[1] = 1000
levels[2] = 2000
levels[3] = 4000
levels[4] = 8000
levels[5] = 16000

A character in this format starts with level 0, and when he kills a monster and goes over 999 XP, his level is raised to 1.
Now when he kills a monster it checks to see if his XP has gone over levels[1+1] = 2000 for the next level.

If you want your character to START at level 1, just offset the array by 1 element. Like this:

levels[0] = 0
levels[1] = 0
levels[2] = 1000
levels[3] = 2000
levels[4] = 4000
levels[5] = 8000

Using this double-XP per level idea, you could fill a large array with a loop like this at the beginning of your program:

  
int levels[20];
int i;
levels[0] = 0;
levels[1] = 0;
levels[2] = 1000;
for (i = 3; i <= 20; i++)
{
levels[i] = levels[i-1] * 2;
}

Careful with the number you''re trying to store in an integer - there''s a limit depending on your system and how many bytes it uses to store an integer. You may need to create your own HugeInteger class for very large numbers.

(silencer)

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!