Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Lee Stevens
19
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Deep in code...
Posted: 9th Sep 2010 22:22 Edited at: 9th Sep 2010 22:23
okay i have a formula in my head (for a level up system in my game)
Let me break it down for you
-Start off at 10XP (until next level 2)
-Then you +5 XP for Level 3
-Then for the next level you add 10 to the previous Levels XP
Then the level after that is 15

Level 1 = 10
Level 2 = 15
Level 3 = 25
Level 4 = 40
Level 5 = 60
Etc..

I hope everyone understands what i mean?

How would i implement this into my game code??
The code i have soo far is



If There Is A Problem, Find The Question.
Lee Stevens 1st September 2007
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 9th Sep 2010 22:27


that should do it, each level is in that array.

Not tested.

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 9th Sep 2010 23:30 Edited at: 9th Sep 2010 23:33
Or...


EDIT: That wasn't quite right... should be now though!

Lee Stevens
19
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Deep in code...
Posted: 9th Sep 2010 23:40
Hi Baxslash, Ive applied that to my code and it sorta working but when i get more than 5 XP nothing happens? what code do i need for when i get 5XP for the program to say look lee you have leveled up now you need say 10 XP to level up?

If There Is A Problem, Find The Question.
Lee Stevens 1st September 2007
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 10th Sep 2010 00:06
Oh dear, have you actually looked at any tutorials that teach you the very basics of programming?

Lee Stevens
19
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Deep in code...
Posted: 10th Sep 2010 00:10
@Mad Nightmare, you can't exact say I can't program, your code didn't even work.

If There Is A Problem, Find The Question.
Lee Stevens 1st September 2007
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 10th Sep 2010 00:15 Edited at: 10th Sep 2010 00:16
I never said you can't program, I said you clearly haven't learnt the basics of programming as you don't know a loop is required in this situation. I see no reason why my code wouldn't work if properly implemented.

EDIT: Fair play, it doesn't work at all. I apologize.

Lee Stevens
19
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Deep in code...
Posted: 10th Sep 2010 00:24 Edited at: 10th Sep 2010 00:25
I'm new to programming with DBPro thats why i'm asking for help and I do know the basics, I wouldn't really call this basic though :/.
I apologise if what I said was offensive or you took offense to it

If There Is A Problem, Find The Question.
Lee Stevens 1st September 2007
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 10th Sep 2010 17:58 Edited at: 10th Sep 2010 17:59
You don't even need a loop for this. You can also calculate it by the formula:

exp = 10 + 5 * lvl * (lvl - 1) / 2

lvl 1: 10 + 0 = 10
lvl 2: 10 + 5 * 2 * 1 / 2 = 15
lvl 3: 10 + 5 * 3 * 2 / 2 = 25
lvl 4: 10 + 5 * 4 * 3 / 2 = 40
etc.

[edit] It's called the sum of an arithmetic progression

Cheers!
Sven B

Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 10th Sep 2010 18:12
Quote: "You don't even need a loop for this"


I meant he needed a loop for the game to progress.

Lee Stevens
19
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Deep in code...
Posted: 10th Sep 2010 21:29 Edited at: 10th Sep 2010 22:25
@Mad Nightmare - I do have a loop in my main program there is no point posting all my code on here when its 107 lines of code, So I thought I might aswell just post the bit I need help with not everything else

@Sven B - I've tried the formula, it works but my system isn't updating :s the code if below if you want to look and see if you can see a problem



If There Is A Problem, Find The Question.
Lee Stevens 1st September 2007
=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 10th Sep 2010 22:19 Edited at: 10th Sep 2010 22:25
Dude, don't be rude to ppl. They won't want to help you.

I'm sure Mad Nightmare was just pointing out that the code provided needed to be INSIDE the loop.

Try out this snippet, which does what you want. Altho I simplified the variable naming a little, your's was all over the place, often mixing floats and integers (unless I missunderstood what it all did)



Hope that helps a little.

>Edit<
I noticed (too late) that your usage of SvenB's formula was incorrect. Changed now for a working version

Lee Stevens
19
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Deep in code...
Posted: 10th Sep 2010 23:17
@=Prof=, Thank you for that it works and its just what I was looking for, I'm working on a way to stop the XP and LEVEL to stop when it gets to 50 (for example)

If There Is A Problem, Find The Question.
Lee Stevens 1st September 2007
=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 10th Sep 2010 23:29
change this bit...



to



and it should do the trick

Lee Stevens
19
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Deep in code...
Posted: 10th Sep 2010 23:33
Thank you Prof, how comes your so good at DBPro?

If There Is A Problem, Find The Question.
Lee Stevens 1st September 2007
=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 10th Sep 2010 23:36
Years of practice dude

Lee Stevens
19
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Deep in code...
Posted: 10th Sep 2010 23:41
I've had DBPro for about 5 years now lol only just started using it properly though I thinking about getting 'Hands on dbpro 1 & 2' do you know if there any good?

If There Is A Problem, Find The Question.
Lee Stevens 1st September 2007
=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 10th Sep 2010 23:53
I taught myself to program in Basic when I was about 9 or so (Some 25 years ago now); I didn't even have a computer, just a book from the library and a pad and pen! lol

Been doing it as a hobby ever since, 1st on a Spectrum, then on an Amiga (Anyone else remember AMOS?), and finally in '97, a PC.

I had Dark Basic Classic 1st, and then I got DBP pretty much the month after it came out.

Wish I could model/draw tho... lol

And I can't say I have ever read those books, but a few people around here have said they are very worthwhile to a beginner.

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 11th Sep 2010 01:38 Edited at: 11th Sep 2010 01:48
just saying, I think if you really understood what that formula did, you would know exactly how to implement it... so let me explain a bit more in-depth in case you haven't been in algebra 1 (according to the education system here in california).

An arithmetic progression is a sequence in which the difference between one term and the next is the same. That means a simple sequence, like <1,2,3,4,5,...> or <3,6,9,12,...> or in this case <5,10,15,20,...>. The odd thing here is that that sequence represents the amount by which the needed experience increases each level. We want to find the value of needed experience. So, to do that, we find the sum of the function
change in needed exp = 5*lvl
So, if you're in
If the needed exp of level 1 is 10, then the needed exp will be this:
10+5=15
If you're going from lv 2 to 3:
10+5+10=25
if you're going from lv 3 to 4:
10+5+10+15=40

so, you can see that the sequence is the sum of all the terms of 5*lvl. In "sigma" notation, we would say this:

total experience needed at level L to advance to the next level = [img]http://www.neurofuzzydev.com/cgi-bin/mimetex.cgi?10%2B%20%5Csum_%7B%7Bn%7D%3D%7BL%7D%7D^%7BL%7D5%20%5Ccdot%20n-5.gif[/img]

which, through math (!!!), we can determine is equal to:
[img]http://www.neurofuzzydev.com/cgi-bin/mimetex.cgi?L \cdot \left(L-1\right) \cdot \frac{5}{2} +10[/img]

You get that by simplifying that sigma notation doohickey.

I'm just saying this, because its not totally obvious, and you should know *why* you're doing something. Even if you don't know the notation or math behind it (I just barely do), you should realize that you're dealing with the sum of a bunch of numbers, and realize that what you're doing in the program solves for that sum.

errm, if you already know all this, then whatever. At least I got to try out embedding math statements xD

Lee Stevens
19
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Deep in code...
Posted: 11th Sep 2010 01:46
I live in England not america I done maths at school and got nearly full marks on the exam I know how the formula works, I just don't know how to get it working in DBPro Thanks for the advice tho

If There Is A Problem, Find The Question.
Lee Stevens 1st September 2007
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 11th Sep 2010 01:49
K nm then!
I also learned that apollo forum software dislikes my urls for the cool cgi-generated math images I used

Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 11th Sep 2010 12:24
Quote: "I meant he needed a loop for the game to progress."


Lol, I meant you didn't have to use a for-next loop...

Cheers!
Sven B

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 11th Sep 2010 12:43
I'm just going to throw this out there but what kind of game requires so little experience per level?!?! Add a zero at least.

Level 1 = 100
Level 2 = 150
Level 3 = 250
Level 4 = 400
Level 5 = 600

Lost in Thought
22
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 11th Sep 2010 13:32 Edited at: 11th Sep 2010 13:34
You don't need to multiply or divide at all. You can do it with simple adding and a storage container if the levels will be incremental.



[edit] You can remove the if upkeypress stuff if you want. Code was just running to fast on my machine for me to be sure it was working right without it.

Lee Stevens
19
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Deep in code...
Posted: 11th Sep 2010 16:14
@Grog - I thought of that already the level up goes
LEVEL 1 = 100
LEVEL 2 = 300
LEVEL 3 = 600
LEVEL 4 = 1000
LEVEL 5 = 1500

@Lost In Thought - I'll give that a try thanks

If There Is A Problem, Find The Question.
Lee Stevens 1st September 2007
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 11th Sep 2010 18:11
Quote: "Lol, I meant you didn't have to use a for-next loop..."


Oh! It's just the way I like to do things xD

Igglepud
15
Years of Service
User Offline
Joined: 14th Aug 2010
Location:
Posted: 12th Sep 2010 21:28
Search for Nicky Dude's DBPro Guide. very helpful.

Login to post a reply

Server time is: 2026-07-22 12:41:13
Your offset time is: 2026-07-22 12:41:13