forked from msokalski/ascii-patrol
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
temp.cpp
2302 lines (1929 loc) · 57.4 KB
/
temp.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// temp.cpp : Defines the entry point for the console application.
//
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <memory.h>
#include <string.h>
#include "twister.h"
#include "inter.h"
#include "gameover.h"
#include "game.h"
#include "spec.h"
#include "menu.h"
#include "conf.h"
#include "manual.h"
#include "unmo3.h"
void screen_shot(CON_OUTPUT* s, const char* name=0)
{
const static unsigned char ansi_pal[16*3] =
{
0, 0, 0,
170, 0, 0,
0,170, 0,
170, 85, 0,
0, 0,170,
170, 0,170,
0,170,170,
170,170,170,
85, 85, 85,
255, 85, 85,
85,255, 85,
255,255, 85,
85, 85,255,
255, 85,255,
85,255,255,
255,255,255
};
char path[1024];
if (name)
sprintf_s(path,1024,"%s%s.xp",shot_path(),name);
else
sprintf_s(path,1024,"%s%X.xp",shot_path(),get_time());
FILE* f=0;
fopen_s(&f,path,"wb");
if (f)
{
int ver = -1;
fwrite(&ver,4,1,f);
int layers = 1;
fwrite(&layers,4,1,f);
fwrite(&s->w,4,1,f);
fwrite(&s->h,4,1,f);
const unsigned char* fg = ansi_pal+3*0;
const unsigned char* bg = ansi_pal+3*15;
for (int x=0; x<s->w; x++)
{
for (int y=0; y<s->h; y++)
{
int code = s->buf[x + y*(s->w+1)];
fwrite(&code,4,1,f);
if (s->color)
{
fg = ansi_pal + 3*(s->color[x + y*(s->w+1)] & 0x0F);
bg = ansi_pal + 3*((s->color[x + y*(s->w+1)] >> 4) & 0x0F);
}
fwrite(fg,3,1,f);
fwrite(bg,3,1,f);
}
}
fclose(f);
}
}
#if 0
// +1: always true, higher values makes it harder to get true
// 0: exception!
// -1: always false, lower values makes it easier to get true
#define MOD_RAND(mod) ( mod && ( mod>0 ? twister_rand()%mod==0 : twister_rand()%(-mod)!=0 ) )
void MakeTerrain(const char* path, int len)
{
twister_seed(get_time());
int checkpoints = 5;
// cracks & craters
// and enemies inside and on their boundaries
int hole_dist=80;
int crack_mod = 4;
int hole_creature_mod = 1;
int hole_edge_enemy_mod = 1;
int hole_edge_t=1;
int hole_edge_m=1;
int hole_edge_h1=1;
int hole_edge_h2=1;
int hole_edge_h3=1;
int enemy_dist = 50;
int enemy_t=1;
int enemy_m=1;
int enemy_h1=1;
int enemy_h2=1;
int enemy_h3=1;
int enemy_b1=1;
int enemy_b2=1;
int enemy_b3=1;
int enemy_b4=1;
int enemy_r=1;
int terrain_harmonics=10;
int enemy_U=5;
int enemy_D=5;
int enemy_B=5;
FILE* f=0;
fopen_s(&f,path,"wt");
// desired input:
// -------------------------
// begin_difficulty 1..100
// end_difficult 1..100
// length: 500..10000
// checkpoints: 1..length/500
// modes: [mine_filed / flies / regular] x checkpoints
struct HARMONIC
{
HARMONIC()
{
Init();
age = twister_rand() % ( attack + sustain + decay);
}
void Init()
{
freq = (twister_rand()%1024 + 100)*0.0001f;
ampl = 0.04f/freq;
ampl *= (twister_rand()%1024 + 100)/1124.0f;
attack = twister_rand()%32+16;
sustain = twister_rand()%256+32;
decay = twister_rand()%32+16;
age = 0;
}
float Get()
{
if (age>=attack+sustain+decay)
Init();
float vol = ampl;
if (age<attack)
vol*=(float)(age-attack)/(float)attack;
if (age>attack+sustain)
vol*=(float)(attack+sustain+decay-age)/(float)decay;
float h = sinf(age*freq)*vol;
age++;
return h;
}
float freq;
float ampl;
int attack;
int sustain;
int decay;
int age;
};
// generate basic terrain
HARMONIC gen[10];
char* arr = (char*)malloc(len+1);
char* spr = (char*)malloc(len+1);
arr[len]=0;
spr[len]=0;
memset(spr,' ',len);
spr[1]='@';
int last_r = 0;
for (int n=0; n<checkpoints; n++)
{
int cp = (n+1)*len/checkpoints-1;
spr[cp]='#';
}
for (int i=0; i<len; i++)
{
float h=0.0f;
for (int j=0; j<terrain_harmonics; j++)
h+=gen[j].Get();
arr[i] = 3 + (int)floorf(h+0.5f);
}
// clamp to 0-7
for (int i=0; i<len; i++)
{
arr[i] = MAX(0,arr[i]);
arr[i] = MIN(7,arr[i]);
}
// filter out tiny pops
for (int i=2; i<len; i++)
{
if (arr[i-2] == arr[i])
arr[i-1] = arr[i];
}
int max_slope=7;
for (int i=max_slope; i<len; i++)
{
int ilo=i;
int ihi=i;
int lo=arr[i];
int hi=arr[i];
for (int j=i-max_slope; j<=i; j++)
{
if (arr[j]<lo)
{
lo=arr[j];
ilo=j;
}
if (arr[j]>hi)
{
hi=arr[j];
ihi=j;
}
}
if (hi-lo>1)
{
// make 1:7 slope until convergence with arr
if (ilo<ihi)
{
while (arr[ilo+1]==lo)
ilo++;
int j=ilo+1;
while (j<len)
{
int slope = lo + (j-ilo)/max_slope;
if (arr[j]<=slope)
break;
arr[j]=slope;
j++;
}
}
else
{
while (arr[ihi+1]==hi)
ihi++;
int j=ihi+1;
while (j<len)
{
int slope = hi - (j-ihi)/max_slope;
if (arr[j]>=slope)
break;
arr[j]=slope;
j++;
}
}
}
}
// distribution
int hole_edge_enemy[]={'t','m','h1','h2','h3'};
int hole_edge_width[]={8,4,4,8,13};
int hole_edge_ratio[]={hole_edge_t,hole_edge_m,hole_edge_h1,hole_edge_h2,hole_edge_h3};
int hole_edge_sum=hole_edge_t+hole_edge_m+hole_edge_h1+hole_edge_h2+hole_edge_h3;
if (hole_dist)
for (int i=80; i<len-40-hole_dist; i+=hole_dist)
{
// todo:
// ensure no nearby checkpoints!
bool ok=true;
for (int n=0; n<checkpoints; n++)
{
int cp = (n+1)*len/checkpoints-1;
if (ABS(cp-i)<hole_dist)
{
ok=false;
break;
}
}
if (!ok)
continue;
int pos = i+twister_rand()%hole_dist;
int edge_left = -1;
int edge_right = -1;
if (MOD_RAND(crack_mod))
{
int crack_width=8;
int width = twister_rand()%crack_width+6;
// crack
int l=pos+2;
int r=pos+width-2;
for (int j=pos; j<l; j++)
arr[j]=MIN(arr[j],arr[j-1]-1);
for (int j=pos+width-1; j>=r; j--)
arr[j]=MIN(arr[j],arr[j+1]-1);
arr[l]=MIN(arr[l],arr[l-1]-2);
arr[r-1]=MIN(arr[r-1],arr[r]-2);
l++;
r--;
arr[l]=MIN(arr[l],arr[l-1]-3);
arr[r-1]=MIN(arr[r-1],arr[r]-3);
for (int j=l+1; j<r-1; j++)
arr[j]=-2;
edge_left = pos;
edge_right = pos+width;
}
else
{
int width = 14+2*(twister_rand()%3);
float y = width*0.5f;
float r = sqrtf(2.0f)*y;
float x = pos+y;
int h = MAX(arr[pos],arr[pos+width/*-1*/]);
for (int j=pos; j<pos+width; j++)
arr[j]= MIN(arr[j],h-MAX(0,(int)floorf(0.5f+sqrtf(r*r-(j-x)*(j-x)) - y)));
// if creature, ensure flat base 8
if (MOD_RAND(hole_creature_mod))
{
int h = arr[pos+width/2-4];
for (int j=pos+width/2-4; j<pos+width/2+4; j++)
arr[j]=h;
spr[pos+width/2-4] = 'c';
}
edge_left = pos;
edge_right = pos+width;
}
for (int j=edge_left; j<=edge_right; j++)
{
if (spr[j]==' ')
spr[j]='.';
}
if (hole_edge_sum && MOD_RAND(hole_edge_enemy_mod))
{
// pick random side(s)
int side = twister_rand()%3 - 1;
// if side is 0 or 1 ensure there is enough space to checkpoint
// if not, change side to -1
if (side>=0)
{
int i = side==0 ? edge_right+2 : edge_right+2+30;
for (int n=0; n<checkpoints; n++)
{
int cp = (n+1)*len/checkpoints-1;
if (ABS(cp-i)<enemy_dist)
{
side=-1;
break;
}
}
}
// pick random enemy from repertoire
int enemy = twister_rand()%hole_edge_sum;
int j=0;
for (j=0; enemy>=hole_edge_ratio[j]; j++)
enemy-=hole_edge_ratio[j];
int kind = hole_edge_enemy[j];
if (kind=='h3' && side==0) // no h3 at right side
side=1;
int width = hole_edge_width[j];
int epos;
if (side<0)
epos = edge_left-1 - width;
else
if (side==0)
epos = edge_right+2;
else
{
if (kind=='t')
epos = edge_right+2+30; // bit more space
else
epos = edge_right+2+20; // with landing place
}
int h=(arr[epos-1]+arr[epos+width+1]+1)/2;
for (int j=epos-1; j<epos+width+1; j++)
{
arr[j]=h;
}
if (side!=0)
{
int k=arr[epos-2]-h;
if (k)
for (int j=epos-2; j>=0; j--)
{
int slope = h + (k>0 ? (epos-j)/max_slope : (j-epos)/max_slope);
if (k>0 && arr[j]<slope)
break;
if (k<0 && arr[j]>slope)
break;
arr[j] = slope;
}
}
if (side>0)
{
int k=arr[epos+width+1]-h;
if (k)
for (int j=epos+width+1; j<len; j++)
{
int slope = h + (k>0 ? (j-(epos+width))/max_slope : (epos+width-j)/max_slope);
if (k>0 && arr[j]<slope)
break;
if (k<0 && arr[j]>slope)
break;
arr[j] = slope;
}
}
for (int c=-1; c<=width; c++)
{
if (spr[epos+c]==' ')
spr[epos+c]='.';
}
for (int c=0; c<4; c++)
{
if (kind & (0xFF000000>>(c*8)))
{
spr[epos]=(kind>>(24-c*8))&0xFF;
epos++;
}
}
}
i=pos;
}
int enemy[]={'t','m','h1','h2','h3', 'b1','b2','b3','b4', 'r'};
int enemy_width[]={8,4,4,8,13, 3,4,8,9, 0};
int enemy_ratio[]={enemy_t,enemy_m,enemy_h1,enemy_h2,enemy_h3, enemy_b1,enemy_b2,enemy_b3,enemy_b4, enemy_r};
int enemy_sum=enemy_t+enemy_m+enemy_h1+enemy_h2+enemy_h3 +enemy_b1+enemy_b2+enemy_b3+enemy_b4 + enemy_r;
// place oridinary enemies (where possible)
if (enemy_dist)
for (int i=100; i<len-80; i+=enemy_dist)
{
// pick enemy kind
int renemy = twister_rand()%enemy_sum;
int e=0;
for (e=0; renemy>=enemy_ratio[e]; e++)
renemy-=enemy_ratio[e];
int kind = enemy[e];
if (kind=='r')
{
if (last_r<i-400) // 400 is min-distance between rockets
{
bool ok=true;
for (int k=i-enemy_dist; k<i+enemy_dist; k++)
{
if (spr[k]!=' ')
{
ok=false;
break;
}
}
if (ok)
{
for (int j=i-280; j<=i-280+5; j++) // 280 is actual offset between 'r' and required jump
{
if (spr[j]==' ' || spr[j]=='.' || spr[j]=='-')
{
spr[j]='r';
last_r = i;
break;
}
}
}
}
if (last_r==i)
{
// rocket in place, reserve space for jump
for (int j=i; j<i+20; j++)
{
if (spr[j]==' ')
spr[j]='-';
}
continue;
}
// can't put anything here
if (enemy_sum-enemy_r<=0)
continue;
// pick different kind
renemy = twister_rand()%(enemy_sum-enemy_r);
for (e=0; renemy>=enemy_ratio[e]; e++)
renemy-=enemy_ratio[e];
kind = enemy[e];
}
i+=twister_rand()%enemy_dist;
int width=0;
for (int j=i; j<len-80; j++)
{
if (arr[j]!=arr[i])
{
i=j;
width=0;
}
width++;
if (width>=enemy_width[e]+4)
{
// ensure no other enemies nearby
bool ok=true;
for (int k=i-enemy_dist; k<i+enemy_dist; k++)
{
if (spr[k]!=' ')
{
width-=j-i;
i=j;
ok=false;
break;
}
}
if (ok)
break;
}
}
if (width>=enemy_width[e]+4)
{
for (int c=-1; c<=enemy_width[e]; c++)
{
if (spr[i+2+c]==' ')
spr[i+2+c]='.';
}
// fine, put it @ i
for (int c=0; c<4; c++)
{
if (kind & (0xFF000000>>(c*8)))
{
spr[i+2]=(kind>>(24-c*8))&0xFF;
i++;
}
}
}
}
// add hi-freq texture (keep space from sprites)
int texlen = twister_rand()%1+2;
for (int i=10; i<len-10; i+=twister_rand()%8+8)
{
int h=arr[i];
bool ch=true;
for (int j=i-10; j<=i; j++)
{
if (arr[j]!=h)
{
ch=false;
break;
}
}
for (int j=i-10; j<i+texlen; j++)
if (spr[j]!=' ' || spr[j]=='#')
{
ch=false;
break;
}
if (ch)
{
for (int j=i-5; j<i-5+texlen; j++)
arr[j]--;
texlen = twister_rand()%1+2;
}
}
// flies
int pcp=0;
for (int n=0; n<checkpoints; n++)
{
int fly_sum = enemy_U + enemy_D + enemy_B;
int fly_ratio[] = {enemy_U,enemy_D,enemy_B};
int fly_kind[] = {'U','D','B'};
int cp = (n+1)*len/checkpoints-1;
while (fly_sum)
{
int pos = pcp + twister_rand()%(cp-pcp-10);
for (int k=pos; k<pos+10; k++)
{
if (spr[k]==' ' || spr[k]=='.' || spr[k]=='-')
{
int renemy=twister_rand()%fly_sum;
int e=0;
for (e=0; renemy>=fly_ratio[e]; e++)
renemy-=fly_ratio[e];
int kind = fly_kind[e];
fly_sum--;
fly_ratio[e]--;
spr[k] = kind;
break;
}
}
}
pcp = cp;
}
for (int i=0; i<len; i++)
arr[i]+='0';
fwrite(spr,len,1,f);
fwrite("\n",1,1,f);
fwrite(arr,len,1,f);
fwrite("\n",1,1,f);
fclose(f);
test_area[0].height = arr;
test_area[0].sprite = spr;
//free(arr);
//free(spr);
}
#endif
MODAL* modal = 0;
SCREEN global_screen(90,28,' ',cl_transp);
struct CAMPAIGN_MODAL : MODAL
{
// we can have one of 2 sub-modals active: gamelevel or interscreen
MODAL* level_modal;
MODAL* inter_modal;
int iCourse;
int iLevel;
int iSubLev;
SCREEN* s;
int w;
int h;
int lives;
int score;
const COURSE* current_course;
const LEVEL* current_level;
int level_time;
int startlives; // lives when entering level
char hitbin[1024]; // so max level size is 8192!
virtual ~CAMPAIGN_MODAL()
{
if (level_modal)
delete level_modal;
if (inter_modal)
delete inter_modal;
}
CAMPAIGN_MODAL(SCREEN* scr, int ic, int il)
{
s=scr;
w=scr->w;
h=scr->h;
iCourse = ic;
iLevel = il;
iSubLev = 0;
// iSubLev = 4;
lives = 3;
score = 0;
current_course = campaign + iCourse;
current_level = current_course->level + iLevel;
startlives = lives;
memset(hitbin,0,1024);
level_time = 0;
FILE* record_file = 0;
fopen_s(&record_file,record_path(),"wb");
if (record_file)
{
// write header
unsigned char sign[8]="REC0";
fwrite(sign,4,1,record_file);
fwrite(&iCourse,4,1,record_file);
fwrite(&iLevel,4,1,record_file);
fwrite(&iSubLev,4,1,record_file);
fwrite(&lives,4,1,record_file);
// this part must be written before each (re)spawn!
fwrite(&w,4,1,record_file);
fwrite(&h,4,1,record_file);
twister_write(record_file);
crypt_ini();
int n[4];
memcpy(n,conf_player.name,16);
n[0] ^= score;
n[1] ^= score;
n[2] ^= score;
n[3] ^= score;
crypt_enc(n+0);
crypt_enc(n+1);
crypt_enc(n+2);
crypt_enc(n+3);
fwrite(n,1,16,record_file);
int a =conf_player.avatar;
a ^= score;
crypt_enc(&a);
fwrite(&a,4,1,record_file);
fclose(record_file);
// ready for appending
}
level_modal = new LEVEL_MODAL(
&global_screen,
lives,startlives,
&score,
&level_time,
conf_player.name,
current_course->name,
current_level,
iSubLev, hitbin);
inter_modal = 0;
}
virtual int Run()
{
// RETURN -2 is reserved for temporal exits to menu
// RETURN -3 is permanent end of game exit.
if (level_modal)
{
// in-game
int ret = level_modal->Run();
w=s->w;
h=s->h;
if (ret>=0)
{
// player just died in returned sublevel
lives--;
if (lives)
{
iSubLev = ret;
delete level_modal;
FILE* record_file = 0;
fopen_s(&record_file,record_path(),"ab");
if (record_file)
{
int t;
t=w^score;
crypt_enc(&t);
fwrite(&t,4,1,record_file);
t=h^score;
crypt_enc(&t);
fwrite(&t,4,1,record_file);
twister_write(record_file);
fclose(record_file);
}
level_modal = new LEVEL_MODAL(
&global_screen,
lives,startlives,
&score,
&level_time,
conf_player.name,
current_course->name,
current_level,
iSubLev, hitbin);
}
else
{
// game over
delete level_modal;
level_modal = 0;
FILE* record_file = 0;
fopen_s(&record_file,record_path(),"ab");
if (record_file)
{
unsigned int chk[5] =
{
static_cast<unsigned int>(twister_rand()),
static_cast<unsigned int>(twister_rand()),
crypt_chk(),
static_cast<unsigned int>(twister_rand()),
static_cast<unsigned int>(twister_rand())
};
fwrite(chk,1,15+(rand()%5),record_file);
fclose(record_file);
}
// post recording to the server
// delete recording file?
post_hiscore();
inter_modal = new GAMEOVER_MODAL(
&global_screen,
&score,
current_level);
}
return 0;
}
// quit
if (ret==-2)
{
// quit to menu, pause & show confirmation?
// maybe not necessary as we are going to have continue thing!
// ...
// destroy game
/*
delete level_modal;
level_modal = 0;
*/
return -2;
}
if (ret==-3)
{
// still playing
return -1;
}
///////////////////////////
// so ret is -1
// level finished.
// prepare interscreen
// calc hitacc from hitbin
int hitacc = 0;
for (int i=0; i<1024; i++)
{
unsigned char b = hitbin[i];
while (b)
{
if (b&1)
hitacc++;
b >>= 1;
}
}
// parse level data to find hitmax
int hitmax = 0;
for (int i=0; current_level->sprite[i]; i++)
{
char spr = current_level->sprite[i];
switch (spr)
{
case 'U':
case 'D':
case 'B':
case 'r':
case 't':
case 'c':
case 'h':
case 'b':
hitmax++;
}
}
delete level_modal;
level_modal = 0;
inter_modal = new INTER_MODAL(
&global_screen,
lives, startlives,
&score,
current_course->name,
current_level,
level_time,
hitacc, hitmax);
// increment level
level_time = 0;
hitacc = 0;
startlives = lives;
memset(hitbin,0,1024);
iSubLev=0;
current_level++;
iLevel++;
if (!current_level->height)
{
current_course++;
iCourse++;
// update progress in conf
if (iCourse>conf_campaign.passed)
{
conf_campaign.passed = iCourse;
SaveConf();
}
if (!current_course->level || (current_course->flags&0x1))
{
current_course = campaign + 0;
iCourse=0;
// RANDOM GENERATOR SURVIVAL MDOE ?
}
current_level = current_course->level + 0;
iLevel=0;
}
return -1;
}