Posts: 6,236
Threads: 310
Joined: Jan 2011
Reputation:
0
But if I do that I'm going to get a lot of recursion, which I don't want. I need a way to do this without recursion.
Posts: 6,236
Threads: 310
Joined: Jan 2011
Reputation:
0
There is no maximum level though. It's infinite. Well, up to the 32-bit Integer limit I guess... I also don't want to store it in memory anyway.
Posts: 613
Threads: 11
Joined: Aug 2010
Reputation:
0
Slight confusion, since you edited your first post.
Your description, example and image contains different values.
For level 4, 70 points are needed in total or additional 70 points after reaching level 3?
Posts: 6,236
Threads: 310
Joined: Jan 2011
Reputation:
0
You start with 0 points. When you get 10 points (total of 10 points), you become level 2. When you get another 20 points (now a total of 30 points), you level up again, when you get another 30 points (now 60 in total), you level up again, and so forth. The recursive function you provided works fine, but I'd rather not use recursion if possible. Any way to do that?
Posts: 1,208
Threads: 36
Joined: Apr 2015
PHP код:
//top
#define MAX_LEVELS 101 //0 - 100
new LevelExp[MAX_LEVELS],
NextLevelExp[MAX_LEVELS];
public OnGameModeInit(){
//load levels
for(new i = 0; i < MAX_LEVELS; i++){
NextLevelExp[i] = (i*10);
if(i == 0){
LevelExp[i] = 0;
} else {
LevelExp[i] = LevelExp[i-1] + (i*10);
}
//printf("Level %d need %d total exp %d",i,NextLevelExp[i],LevelExp[i]);
}
return 1;
}
Код:
Level 0 need 0 total exp 0
Level 1 need 10 total exp 10
Level 2 need 20 total exp 30
Level 3 need 30 total exp 60
Level 4 need 40 total exp 100
Level 5 need 50 total exp 150
Level 6 need 60 total exp 210
Level 7 need 70 total exp 280
Level 8 need 80 total exp 360
Level 9 need 90 total exp 450
Level 10 need 100 total exp 550
Level 11 need 110 total exp 660
Level 12 need 120 total exp 780
Level 13 need 130 total exp 910
Level 14 need 140 total exp 1050
Level 15 need 150 total exp 1200
Level 16 need 160 total exp 1360
Level 17 need 170 total exp 1530
Level 18 need 180 total exp 1710
Level 19 need 190 total exp 1900
Level 20 need 200 total exp 2100
Level 21 need 210 total exp 2310
Level 22 need 220 total exp 2530
Level 23 need 230 total exp 2760
Level 24 need 240 total exp 3000
Level 25 need 250 total exp 3250
Level 26 need 260 total exp 3510
Level 27 need 270 total exp 3780
Level 28 need 280 total exp 4060
Level 29 need 290 total exp 4350
Level 30 need 300 total exp 4650
Level 31 need 310 total exp 4960
Level 32 need 320 total exp 5280
Level 33 need 330 total exp 5610
Level 34 need 340 total exp 5950
Level 35 need 350 total exp 6300
Level 36 need 360 total exp 6660
Level 37 need 370 total exp 7030
Level 38 need 380 total exp 7410
Level 39 need 390 total exp 7800
Level 40 need 400 total exp 8200
Level 41 need 410 total exp 8610
Level 42 need 420 total exp 9030
Level 43 need 430 total exp 9460
Level 44 need 440 total exp 9900
Level 45 need 450 total exp 10350
Level 46 need 460 total exp 10810
Level 47 need 470 total exp 11280
Level 48 need 480 total exp 11760
Level 49 need 490 total exp 12250
Level 50 need 500 total exp 12750
Level 51 need 510 total exp 13260
Level 52 need 520 total exp 13780
Level 53 need 530 total exp 14310
Level 54 need 540 total exp 14850
Level 55 need 550 total exp 15400
Level 56 need 560 total exp 15960
Level 57 need 570 total exp 16530
Level 58 need 580 total exp 17110
Level 59 need 590 total exp 17700
Level 60 need 600 total exp 18300
Level 61 need 610 total exp 18910
Level 62 need 620 total exp 19530
Level 63 need 630 total exp 20160
Level 64 need 640 total exp 20800
Level 65 need 650 total exp 21450
Level 66 need 660 total exp 22110
Level 67 need 670 total exp 22780
Level 68 need 680 total exp 23460
Level 69 need 690 total exp 24150
Level 70 need 700 total exp 24850
Level 71 need 710 total exp 25560
Level 72 need 720 total exp 26280
Level 73 need 730 total exp 27010
Level 74 need 740 total exp 27750
Level 75 need 750 total exp 28500
Level 76 need 760 total exp 29260
Level 77 need 770 total exp 30030
Level 78 need 780 total exp 30810
Level 79 need 790 total exp 31600
Level 80 need 800 total exp 32400
Level 81 need 810 total exp 33210
Level 82 need 820 total exp 34030
Level 83 need 830 total exp 34860
Level 84 need 840 total exp 35700
Level 85 need 850 total exp 36550
Level 86 need 860 total exp 37410
Level 87 need 870 total exp 38280
Level 88 need 880 total exp 39160
Level 89 need 890 total exp 40050
Level 90 need 900 total exp 40950
Level 91 need 910 total exp 41860
Level 92 need 920 total exp 42780
Level 93 need 930 total exp 43710
Level 94 need 940 total exp 44650
Level 95 need 950 total exp 45600
Level 96 need 960 total exp 46560
Level 97 need 970 total exp 47530
Level 98 need 980 total exp 48510
Level 99 need 990 total exp 49500
Level 100 need 1000 total exp 50500