-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGirl.cpp
3272 lines (2965 loc) · 88.6 KB
/
Girl.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
#include <math.h>
#include <stdio.h>
#include "Girl.h"
#include "assist.h"
#ifdef PSP
// #include "input.h"
#include <pspctrl.h>
#endif
#ifdef PSP
typedef struct PSPInput
{
SceCtrlData Input;
unsigned long Pressed;
unsigned long Held;
} PSPInput;
static PSPInput Input;
static void AddInput (const unsigned long Button)
{
if ((Input.Input.Buttons & Button) != 0) // Button is down
{
if ((Input.Held & Button) == 0) // Held is not TRUE
{
Input.Pressed |= Button; // so set both Pressed
Input.Held |= Button; // and Held to TRUE
}
}
else // Button is up
{
Input.Pressed &= ~Button; // so set Presses
Input.Held &= ~Button; // and Held to FALSE
}
}
bool PSPInputInit(void)
{
memset (&Input, 0, sizeof(PSPInput));
sceCtrlSetSamplingCycle (0);
sceCtrlSetSamplingMode (PSP_CTRL_MODE_ANALOG);
return true;
}
void PSPInputShutdown (void)
{
}
void PSPInputUpdate (void)
{
sceCtrlPeekBufferPositive (&Input.Input, 1);
AddInput (PSP_CTRL_SELECT);
AddInput (PSP_CTRL_START);
AddInput (PSP_CTRL_UP);
AddInput (PSP_CTRL_RIGHT);
AddInput (PSP_CTRL_DOWN);
AddInput (PSP_CTRL_LEFT);
AddInput (PSP_CTRL_LTRIGGER);
AddInput (PSP_CTRL_RTRIGGER);
AddInput (PSP_CTRL_TRIANGLE);
AddInput (PSP_CTRL_CIRCLE);
AddInput (PSP_CTRL_CROSS);
AddInput (PSP_CTRL_SQUARE);
}
// bool PSPInputAny (void);
bool PSPInputPressed (const unsigned long Button)
{
if (((Input.Pressed & Button) != 0)) // Pressed is TRUE
{
Input.Pressed &= ~Button; // so set it to FALSE
return true; // and return TRUE
}
return false;
}
bool PSPInputHeld (const unsigned long Button)
{
return ((Input.Held & Button) != 0);
}
#endif
#ifdef PSP
class Gamekeys
{
public:
void GetKeyState(void){}
bool operator[](const unsigned long Button)
{
return PSPInputHeld(Button);
}
};
#else
class Gamekeys
{
private:
Uint8 * keys;
public:
void GetKeyState(void)
{
keys=SDL_GetKeyState(NULL);
}
bool operator[](const unsigned long Button)
{
return keys[Button];
}
};
#endif
static Gamekeys keys;
#ifdef PSP
#define SDLK_ESCAPE PSP_CTRL_CIRCLE
#define SDLK_SPACE PSP_CTRL_CROSS
#define SDLK_RETURN PSP_CTRL_TRIANGLE
#define SDLK_UP PSP_CTRL_UP
#define SDLK_DOWN PSP_CTRL_DOWN
#define SDLK_RIGHT PSP_CTRL_RIGHT
#define SDLK_LEFT PSP_CTRL_LEFT
#endif
//************************初始化地图数据****************************************
short Tile_aqing[10][15] = {//阿青家地图数据
{ 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8},
{ 5,65,12,12,12,12,12,12,12,12,12,12,12,63, 9},
{ 5,64,14,14,14,14,14,14,14,14,14,14,14,62, 9},
{ 5,10,10,10,10,10,10,14,14,10,10,10,10,10, 9},
{ 4,11,11,11,11,11,11, 0, 0,11,11,11,11,11, 4},
{ 4,15,15,15,15,15,15, 0, 0,15,15,15,15,15, 4},
{ 4,15,15,15,15,15,15, 0, 0,15,15,15,15,15, 4},
{ 4,15,15,15,15,15,15, 0, 0,15,15,15,15,15, 4},
{ 2, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 3},
{15,15,15,15,15,15,15, 0, 0,15,15,15,15,15,15}
};
short Trap_aqing[10][15] = {//阿青家地图上的陷阱
{0},//1
{0},//2
{0},//3
{0},//4
{0},//5
{0},//6
{0},//7
{0},//8
{0},//9
{ 0, 0, 0, 0, 0, 0, 0,11}
};
short Block_aqing[10][15] = { //阿青家的阻挡布局
{1,1,1,1,1,1, 1,1,1,1,1, 1,1,1,1},
{1,1,1,1,1,1, 1,1,1,1,1, 1,1,1,1},
{1,1,0,0,0,0, 0,0,0,0,0, 0,0,1,1},
{1,1,1,1,1,1, 1,0,0,1,1, 1,1,1,1},
{1,1,1,1,1,1, 1,0,0,1,1, 1,1,1,1},
{1,0,0,0,0,0, 0,0,0,0,0, 0,0,0,1},
{1,0,0,0,0,0, 0,0,0,0,0, 0,0,0,1},
{1,0,0,0,0,0, 0,0,0,0,0, 0,0,0,1},
{1,1,1,1,1,1, 1,0,0,1,1, 1,1,1,1},
{0,0,0,0,0,0, 0,0,0,0,0, 0,0,0,0}
};
short Tile_shaoxing[10][15] = { //越国都城地图
{17,17,18,24,20,20,20,20,25,17,17,17,18,19,19},
{17,18,19,30,37,22,22,38,27,17,17,18,24,20,20},
{21,21,28,20,20,20,20,20,20,29,21,21,21,14,14},
{35,34,36,26,40,26,26,39,26,33,33,32,33,14,14},
{14,14,14,26,37,22,22,38,26,33,33,31,33,11,11},
{10,10,10,26,37,23,23,38,26,12,12,31,12,11,11},
{16,16,16,16,16,16,16,16,16,16,16,16,16,16,16},
{16,16,16,16,16,16,16,16,16,16,16,16,16,16,16},
{16,16,16,16,16,16,16,16,16,16,16,16,16,16,16},
{16,16,16,16,16,16,16,16,16,16,16,16,16,16,16}
};
short Trap_shaoxing[10][15] = { //越国都城地图陷阱
{0},//1
{0},//2
{0},//3
{0},//4
{0},//5
{0},//6
{12,102,0, 0, 0, 100, 100, 0, 0, 203, 0, 101, 0, 0,0},//7
{0, 0, 0, 0, 0, 0, 0, 0, 0, 203, 0, 0, 202, 0,0},//8
{0, 0, 0, 0, 0, 0, 0, 0, 0, 203, 0, 0, 202, 0,10},//9
{0, 0, 0, 0, 0, 0, 0, 0, 0, 203, 0, 0, 202, 0,0}//10
};
short Block_shaoxing[10][15] = { //越国都城阻挡布局
{1,1,1,1, 1,1,1,1,1, 1,1,1,1,1,1},
{1,1,1,1, 1,1,1,1,1, 1,1,1,1,1,1},
{1,1,1,1, 1,1,1,1,1, 1,1,1,1,1,1},
{1,1,1,1, 1,1,1,1,1, 1,1,1,1,1,1},
{1,1,1,1, 1,1,1,1,1, 1,1,1,1,1,1},
{1,1,1,1, 1,1,1,1,1, 1,1,1,1,1,1},
{0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0},
{0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0},
{0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0},
{0,0,0,0, 0,0,0,0,0, 0,0,0,0,0,0}
};
short Tile_citydoor[10][15] = { //越国城门地图
{11,11,26,26,41,43,47,44,42,26,26,11,11,11,11},//1
{11,11,26,26,15,45,47,46,15,26,26,11,11,11,11},//2
{11,11,26,26,43,47,47,47,44,26,26,11,11,11,11},//3
{11,11,26,26,45,47,47,47,46,26,26,11,11,11,11},//4*
{15,48,49,15,54,16,16,16,55,15,15,15,15,15,15},//5
{48,50,50,49,54,16,16,16,16,16,16,16,16,16,16},//6*
{50,53,50,51,54,16,16,16,16,16,16,16,16,16,16},//7*
{50,50,52,49,54,16,16,16,16,16,16,16,16,16,16},//8*
{50,50,50,51,54,16,16,16,55,15,15,15,15,15,15},//9
{50,50,50,49,54,16,16,16,15,15,15,15,15,15,15}//10*
};
short Trap_citydoor[10][15] = { //越国城门陷阱
{0},//1
{0},//2
{ 0, 0, 0, 0, 0,0,14,0},//3
{0},//4
{0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0},//6
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,11},//7
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0},//8
{0},
{ 0, 0, 0, 0, 0,0,13,0, 0, 0, 0, 0, 0, 0, 0}
};
short Block_citydoor[10][15] = { //越国城门阻挡布局
{1,1,1,1, 1,1,0, 1,1,1,1, 1,1,1,1},
{1,1,1,1, 1,0,0, 0,1,1,1, 1,1,1,1},
{1,1,1,1, 1,0,0, 0,1,1,1, 1,1,1,1},
{1,1,1,1, 0,0,0, 0,0,1,1, 1,1,1,1},
{0,1,1,0, 0,0,0, 0,0,0,0, 0,0,0,0},
{1,1,1,1, 0,0,0, 0,0,0,0, 0,0,0,0},
{1,1,1,1, 0,0,0, 0,0,0,0, 0,0,0,0},
{1,1,1,1, 0,0,0, 0,0,0,0, 0,0,0,0},
{1,1,1,1, 0,0,0, 0,0,0,0, 0,0,0,0},
{1,1,1,1, 0,0,0, 0,0,0,0, 0,0,0,0}
};
short Tile_fanli[10][15] = { //范蠡家地图
{ 6, 7, 7, 7, 7, 7,15,15,15,15,56,20,20,20,57},//1
{ 5,65,60,60,60,60,16,16,16,16,15,33,32,33,15},//2
{ 5,64,14,14,14,14,16,16,16,16,15,33,31,33,15},//3
{ 5,14,14,14,14, 9,58,58,58,16,15,12,31,12,15},//4
{ 5,10,10,10,10, 9,58,58,58,16,15,15,15,15,15},//5
{ 5,63,12,12,12, 9,58,58,58,16,16,16,16,16,16},//6*
{ 5,62,14,14,14,61,58,58,58,16,16,16,16,16,16},//7*
{ 5,14,14,14,14,14,16,16,16,16,15,15,15,15,15},//8
{ 5,10,10,10,10,10,15,15,15,15,15,15,15,15,15},//9
{59,11,11,11,11,11,15,15,15,15,15,15,15,15,15}
};
short Trap_fanli[10][15] = { //范蠡家地图陷阱
{0},//1
{0},//2
{0},//3
{0},//4
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 103, 0, 0},//5
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,12},
{0},
{0},
{0}
};
short Block_fanli[10][15] = { //范蠡家阻挡布局
{1,1,1,1,1,1, 0,0,0,0, 1,1,1,1,1},
{1,1,1,1,1,1, 0,0,0,0, 0,1,1,1,0},
{1,1,0,0,0,0, 0,0,0,0, 0,1,1,1,0},
{1,0,0,0,0,1, 1,1,1,0, 0,1,1,1,0},
{1,1,1,1,1,1, 1,1,1,0, 0,0,0,0,0},
{1,1,1,1,1,1, 1,1,1,0, 0,0,0,0,0},
{1,1,0,0,0,1, 1,1,1,0, 0,0,0,0,0},
{1,0,0,0,0,0, 0,0,0,0, 0,0,0,0,0},
{1,1,1,1,1,1, 0,0,0,0, 0,0,0,0,0},
{1,1,1,1,1,1, 0,0,0,0, 0,0,0,0,0}
};
short Tile_outside[10][15] = { //郊外地图数据
{50,50,50,51,67,47,47,69,76,50,50,50,50,50,50},
{50,50,50,15,66,47,47,47,69,78,79,79,79,79,79},
{50,50,50,49,15,67,47,47,47,47,47,47,47,47,47},
{52,50,50,50,72,68,47,47,47,47,47,47,47,47,47},
{50,50,50,50,71,68,47,47,47,73,74,74,74,74,74},
{50,52,50,50,71,45,47,47,47,44,75,50,50,50,50},
{53,50,53,50,70,67,47,47,47,46,76,50,50,50,50},
{50,50,50,50,49,66,47,47,47,47,44,77,53,50,50},
{50,52,50,50,50,49,47,47,47,47,46,77,50,50,50},
{50,50,50,53,50,51,47,47,47,47,47,50,50,52,50}
};
short Trap_outside[10][15] = { //郊外地图陷阱
{0},
{ 0, 0, 0, 0, 0,0,0,0},
{ 0, 0, 0, 0, 0, 200,200,200, 0, 0, 0, 0, 0, 0,0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,15},
{0,0,0,0, 205,205,205,205,205,205},
{0},
{0},
{0},
{0},
{ 0, 0, 0, 0, 0, 0,0,12,0,0,0, 0, 0, 0, 0}
};
short Block_outside[10][15] = { //郊外地图阻挡布局
{1,1,1,1, 0,0,0,0,1, 1,1,1,1,1,1},
{1,1,1,0, 0,0,0,0,0, 1,1,1,1,1,1},
{1,1,1,1, 0,0,0,0,0, 0,0,0,0,0,0},
{1,1,1,1, 1,0,0,0,0, 0,0,0,0,0,0},
{1,1,1,1, 1,0,0,0,0, 0,0,0,0,0,0},
{1,1,1,1, 1,0,0,0,0, 0,1,1,1,1,1},
{1,1,1,1, 1,0,0,0,0, 0,1,1,1,1,1},
{1,1,1,1, 1,0,0,0,0, 0,0,1,1,1,1},
{1,1,1,1, 1,1,0,0,0, 0,0,1,1,1,1},
{1,1,1,1, 1,1,0,0,0, 0,0,1,1,1,1}
};
short Tile_wuguo[10][15] = { //吴国城门地图数据
{17,17,17,17,17,13,20,20,20,20,25,17,17,17,17},
{17,17,17,17,17,17,23,22,22,23,17,17,17,17,17},
{17,17,17,13,20,20,20,20,20,20,20,20,25,17,17},
{11,17,11,17,11,22,11,22,11,22,11,23,11,17,11},
{11,11,11,11,11,11,26,41,42,26,11,11,11,11,11},
{11,11,11,11,11,11,26,45,46,26,11,11,11,11,11},
{11,11,11,11,11,11,26,47,47,26,11,11,11,11,11},
{72,15,15,15,15,15,43,47,47,44,15,15,15,15,15},
{71,15,15,15,15,15,45,47,47,46,15,15,15,15,15},
{70,15,15,15,15,43,47,47,47,47,44,15,48,49,15}
};
short Trap_wuguo[10][15] = { //吴国城门地图陷阱
{0},
{0},
{0},
{0},
{0},
{0},
{0,0,0,0,0, 0,0,207,17},
{0,0,0,0,0, 0,0,207,207},
{0},
{0,0,0,0,0, 0,0,201,201,201, 0,0,0,0,0}
};
short Block_wuguo[10][15] = { //吴国地图阻挡布局
{1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1},
{1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1},
{1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1},
{1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1},
{1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1},
{1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1},
{1,1,1,1,1, 1,1,0,0,1, 1,1,1,1,1},
{1,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{1,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{1,0,0,0,0, 0,0,0,0,0, 0,0,1,1,0}
};
short Tile_caoyuan[10][15] = { //草原和宫殿的地图数据
{ 0, 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 }
};
short Trap_caoyuan[10][15] = { //草原的地图陷阱
{0},
{0},
{0},
{0},
{0},
{0},
{206,206,206,206,206,206,206,206,206,206,206,206,206,206,206},
{0},
{0},
{0,0,0,0,0, 0,0,14,0,0, 0,0,0,0,0}
};
short Block_caoyuan[10][15] = { //草原地图阻挡布局
{1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1},
{1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1},
{1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1},
{1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1},
{1},
{0},
{0},
{0},
{0},
{0}
};
short Trap_gongdian[10][15] = { //宫殿的地图陷阱
{0},
{0},
{0},
{0},
{0},
{0},
{0},
{0},
{300,300,300,300,300,300,300,300,300,300,300,300,300,300,300},
{0,0,0,0,0, 0,0,16,0,0, 0,0,0,0,0}
};
short Block_gongdian[10][15] = { //宫殿地图阻挡布局
{1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1},
{1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1},
{1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1},
{1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1},
{1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1},
{1,1,1,1,1, 1,0,0,1,1, 0,0,1,1,1},
{0,0,1},
{0},
{0},
{0}
};
short Tile_xiangfang[10][15] = { //范蠡府厢房的地图数据
{ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7},
{65,65,11,11,11,11,65,65,65,11,11,11,11,11,65},
{64,64,14,14,14,14,64,64,64,14,14,14,14,14,64},
{14,14,14,14,14,14,14,14,14,14,14,14,14,14,14},
{14,14,14,14,14,14,14,14,14,14,14,14,14,14,63},
{14,14,14,14,14,14,14,14,14,14,14,14,14,14,62},
{14,14,14,14,14,14,14,14,14,14,14,14,14,14,14},
{10,10,10,10,10,10,14,14,10,10,10,10,10,10,10},
{33,33,33,33,33,33,14,14,33,33,33,33,33,33,33},
{60,60,60,60,60,60,14,14,60,60,60,60,60,60,60}
};
short Block_xiangfang[10][15] = { //范蠡府厢房的阻挡布局
{1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1},
{1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1},
{1,1,0,0,0, 0,1,1,1,0, 0,0,0,0,1},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,1},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,1},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{1,1,1,1,1, 1,0,0,1,1, 1,1,1,1,1},
{1,1,1,1,1, 1,0,0,1,1, 1,1,1,1,1},
{1,1,1,1,1, 1,0,0,1,1, 1,1,1,1,1}
};
short Trap_xiangfang[10][15] = { //范蠡府厢房的陷阱分布
{0},
{0},
{0},
{0},
{0},
{0},
{0},
{0},
{0},
{0,0,0,0,0,0,0,13}
};
//*********************************************************************
//****************************应用程序函数*******************************
extern "C" {
int main (int argc, char *argv[]);
}
//程序入口函数
int main(int argc, char ** argv)
{
int windowed = 0;
if(argc >1){
if( strcmp(argv[1], "-h") == 0){
printf("This is a chinese RPG for Linux. Version: 0.9\n");
printf("The program runs in fullscreen by default;\n");
printf("You can run it in a window by adding an option: -w\n");
printf("Have Fun!!!\n");
return 0;
}
if( strcmp(argv[1], "-w") == 0)
windowed = 1;
}
SDL_Event event;
//SCR_X = 100; //定义绘图窗口在屏幕中位置
//SCR_Y = 100;
InitSDL( windowed );
OpenFonts();
//bActive = TRUE;
Flag = GAME_LOAD_; //设置游戏进度
InitGame(); //游戏初始化
#ifdef PSP
PSPInputInit();
#endif
while(game_running){
#ifdef PSP
PSPInputUpdate();
#endif
if(SDL_PollEvent(&event)){
if(event.type == SDL_QUIT)
game_running = 0;
}
MainLoop();
SDL_Flip(screen);
SDL_Delay(60);
}
CloseFonts();
FreeSDL();
return 0;
}
/*
case WM_MOVE: //窗口移动时更新SCR_X和SCR_Y的值
RECT r;
GetWindowRect(hWnd,&r);
SCR_X += r.left - OldWindow.left;
SCR_Y += r.top - OldWindow.top;
OldWindow = r;
break;
*/
//初始化directdraw函数
void InitSDL( int win )
{
Uint32 colorkey;
if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_JOYSTICK) != 0) {
printf("Unable to initialize SDL: %s\n", SDL_GetError());
exit(1);
}
atexit(SDL_Quit);
if (win == 0)
screen = SDL_SetVideoMode(SCR_W, SCR_H, 16, SDL_SWSURFACE|SDL_FULLSCREEN);
else
screen = SDL_SetVideoMode(SCR_W, SCR_H, 16, SDL_SWSURFACE);
if (screen == NULL) {
printf("Unable to set video mode: %s\n", SDL_GetError());
exit(1);
}
// How to set the icon
SDL_WM_SetCaption("越女剑Linux版", "sword");
SDL_ShowCursor(0); //hide mouse pointer
SDL_EnableKeyRepeat(0, 30); //disable key repeat
//3 创建菜单页面
CreateBmpSurface(&menu, "pic/menu.bmp");
//create dialog background
CreateBmpSurface(&dlg, "pic/dlg.bmp");
CreateBmpSurface(&info, "pic/info.bmp");
//4 创建状态页面
CreateBmpSurface(&state, "pic/state.bmp");
colorkey = SDL_MapRGB(state->format, 0, 0, 0);
SDL_SetColorKey(state, SDL_SRCCOLORKEY, colorkey);
//5 创建精灵页面
CreateBmpSurface(&hero, "pic/aqing.bmp");
colorkey = SDL_MapRGB(hero->format, 0, 0, 0);
SDL_SetColorKey(hero, SDL_SRCCOLORKEY, colorkey);
//6 范蠡
CreateBmpSurface(&FanLi, "pic/fanli.bmp");
colorkey = SDL_MapRGB(FanLi->format, 0, 0, 0);
SDL_SetColorKey(FanLi, SDL_SRCCOLORKEY, colorkey);
//7 西施
CreateBmpSurface(&XiShi, "pic/xishi.bmp");
colorkey = SDL_MapRGB(XiShi->format, 0, 0, 0);
SDL_SetColorKey(XiShi, SDL_SRCCOLORKEY, colorkey);
//8 创建绵羊页面
CreateBmpSurface(&sheep, "pic/sheep.bmp");
colorkey = SDL_MapRGB(sheep->format, 0, 0, 0);
SDL_SetColorKey(sheep, SDL_SRCCOLORKEY, colorkey);
//9 创建越国杂项页面
CreateBmpSurface(&other_yue, "pic/other.bmp");
colorkey = SDL_MapRGB(other_yue->format, 0, 0, 0);
SDL_SetColorKey(other_yue, SDL_SRCCOLORKEY, colorkey);
//10 创建物体页面
CreateBmpSurface(&item, "pic/item.bmp");
colorkey = SDL_MapRGB(item->format, 0, 0, 0);
SDL_SetColorKey(item, SDL_SRCCOLORKEY, colorkey);
//11 创建战斗页面
CreateBmpSurface(&fight, "pic/fight.bmp");
colorkey = SDL_MapRGB(fight->format, 0, 0, 0);
SDL_SetColorKey(fight, SDL_SRCCOLORKEY, colorkey);
//12 创建地图元素页面1
CreateBmpSurface(&map_tile1, "pic/maptile.bmp");
//13 创建地图元素页面2
CreateBmpSurface(&map_tile2, "pic/grass.bmp");
//14 创建地图元素页面2
CreateBmpSurface(&map_tile3, "pic/palace.bmp");
}
//释放页面和directdraw对象
void FreeSDL()
{
SDL_FreeSurface(hero);
SDL_FreeSurface(XiShi);
SDL_FreeSurface(FanLi);
SDL_FreeSurface(sheep);
SDL_FreeSurface(other_yue);
SDL_FreeSurface(item);
SDL_FreeSurface(fight);
SDL_FreeSurface(menu);
SDL_FreeSurface(dlg);
SDL_FreeSurface(info);
SDL_FreeSurface(state);
SDL_FreeSurface(map_tile1);
SDL_FreeSurface(map_tile2);
SDL_FreeSurface(map_tile3);
}
void OpenFonts()
{
if (-1 == TTF_Init()){
printf("TTF engine init failed!\n");
exit(1);
}
menu_font = TTF_OpenFont("font.ttf", 16);
if (!menu_font){
printf("Unable open font.ttf!\n");
exit(1);
}
menu_color.r = 220;
menu_color.g = 220;
menu_color.b = 255;
about_font = TTF_OpenFont("font.ttf", 12);
if (!about_font){
printf("Unable open font.ttf!\n");
exit(1);
}
about_color.r = 0;
about_color.g = 255;
about_color.b = 255;
message_font = TTF_OpenFont("font.ttf", 20);
if (!message_font){
printf("Unable open font.ttf!\n");
exit(1);
}
message_color.r = 255;
message_color.g = 0;
message_color.b = 0;
dlg_font = TTF_OpenFont("font.ttf", 15);
if (!dlg_font){
printf("Unable open font.ttf!\n");
exit(1);
}
dlg_color.r = 255;
dlg_color.g = 255;
dlg_color.b = 0;
}
void CloseFonts()
{
TTF_CloseFont(menu_font);
menu_font = NULL;
TTF_CloseFont(about_font);
about_font = NULL;
TTF_CloseFont(message_font);
message_font = NULL;
TTF_CloseFont(dlg_font);
dlg_font = NULL;
TTF_Quit();
}
//****************************************************************************
//***********************和游戏状态绑定的函数******************************
//游戏主循环
void MainLoop()
{
//如果不到一帧的时间,则不进行绘图操作
// new_time = GetTickCount();
// if (new_time - old_time < FRAME_TIME)
// return;
// old_time = new_time;
switch(Flag)
{
case GAME_TITLE_: //1
GameTitle();
break;
case MAIN_MOVE_: //2
MainMove();
break;
case SYSTEM_MENU_: //3
System_Menu();
break;
case READ_RECORD_: //4
Load();
break;
case WRITE_RECORD_: //5
Store();
break;
case GAME_MESSAGE_: //6
GameMessage();
break;
case FIGHT_START_: //7
StartFight();
break;
case FIGHTING_: //8
Fighting();
break;
case FIGHT_END_: //9
FightEnd();
break;
case AUTO_PLAY_: //10
AutoPlay();
break;
case TREAT_NPC_: //11
TreatNpc();
break;
case BEFORE_SELECT_://12
BeforeSelect();
break;
case WAIT_SELECT_: //13
WaitSelect();
break;
case SELECT_YES_: //14
SelectYes();
break;
case SELECT_NO_: //15
SelectNo();
break;
case CHECK_STATE_: //16
CheckState();
break;
case CHECK_ABOUT_: //17
CheckAbout();
break;
default:
GameExit();
}
}
//游戏初始化
void InitGame()
{
//显示初始化界面
SDL_BlitText("游戏正在初始化。。。", screen, 100, SCR_H/2,
message_font, message_color);
InitData(); //初始化游戏数据
DrawTitle();
game_running = 1;
Flag = GAME_TITLE_; //推进游戏进度
}
//主角在地图走动的函数
void MainMove()
{
RefreshCanvas();//先显示后计算
// Uint8 *keys = SDL_GetKeyState(NULL);
keys.GetKeyState();
if (keys[SDLK_ESCAPE]) {
DrawSystemMenu();
Flag = SYSTEM_MENU_;
return;
}
if (keys[SDLK_SPACE]) {
current_npc_id = FindNpc();
if(current_npc_id) {
Flag = TREAT_NPC_;
}
else {
TrapNum = current_map->check_trap(Aqing.X, Aqing.Y);
if (TrapNum>=100 && TrapNum < 200)
QueryMessage(TrapNum);
}
return;
}
//计算玩家所在的格子
int grid_x, grid_y;
#ifdef PSP
grid_x = Aqing.X/32;
grid_y = Aqing.Y/27;
#else
grid_x = Aqing.X>>5;
grid_y = Aqing.Y>>5;
#endif
if (keys[SDLK_DOWN]) {
Aqing.Dir = 0;
Aqing.Step = Aqing.Step +1;
if(Aqing.Step > 2)
Aqing.Step = 1;
Aqing.Y += speed;
if(CrushCheck()) {
Aqing.Y -= speed;
}
if(current_map->if_block(Aqing.X, Aqing.Y))
#ifdef PSP
Aqing.Y = (grid_y+1)*27-10;
#else
Aqing.Y = (grid_y+1)*32-10;
#endif
}
else if(keys[SDLK_RIGHT]) //按下方向键右
{
Aqing.Dir = 2;
Aqing.Step = Aqing.Step +1;
if(Aqing.Step > 2)
Aqing.Step = 1;
Aqing.X += speed;
if(CrushCheck())
Aqing.X -= speed;
if(current_map->if_block (Aqing.X, Aqing.Y))
Aqing.X = (grid_x+1)*32-Aqing.Width/2;
}
else if(keys[SDLK_LEFT]) //按下方向键左
{
Aqing.Dir = 1;
Aqing.Step = Aqing.Step +1;
if(Aqing.Step > 2)
Aqing.Step = 1;
Aqing.X -= speed;
if(CrushCheck())
Aqing.X += speed;
if(current_map->if_block (Aqing.X, Aqing.Y))
Aqing.X = grid_x*32+Aqing.Width/2;
}
else if(keys[SDLK_UP]) //按下方向键上
{
Aqing.Dir = 3;
Aqing.Step = Aqing.Step +1;
if(Aqing.Step > 2)
Aqing.Step = 1;
Aqing.Y -= speed;
if(CrushCheck())
Aqing.Y += speed;
if(current_map->if_block (Aqing.X, Aqing.Y))
#ifdef PSP
Aqing.Y = grid_y*27;
#else
Aqing.Y = grid_y*32;
#endif
}
else {
if(Aqing.Step)
Aqing.Step = 0;
}
BorderCheck(&Aqing.X ,&Aqing.Y );
TrapNum = current_map->check_trap(Aqing.X, Aqing.Y);
if (TrapNum>= 10 &&TrapNum < 100)
{
SceneChange();
}
else if (TrapNum >=200 && TrapNum <400)
{
Flag = AUTO_PLAY_;
}
}
//开始战斗函数
void StartFight()
{
keys.GetKeyState();
if(keys[SDLK_SPACE]||keys[SDLK_RETURN]) {
if (common_diag.is_over()) {
fAqing.Y = current_enemy->Y;
if(fAqing.bAttack == current_enemy->bAttack )
fAqing.bAttack = !current_enemy->bAttack;
frame_fight =0;
fight_frame_num = 0;
round_num = 1;
Flag = FIGHTING_;
}
else {
common_diag.show(screen);
}
}
}
//战斗中
void Fighting()
{
char temp[300];
UpdateFight();
fight_frame_num++;//总的战斗帧数增加
frame_fight++;
//更新回合数
if(fight_frame_num%12 == 0)
{
round_num++;
}
//处理神秘剑客的特殊事件
if ((!defeat_jianke) && (current_enemy == &fJianke)&& (round_num >= 11))
{
common_diag.set_text("神秘剑客:停!@神秘剑客:已经十个回合了!恭喜你!你赢了!@阿青:外面那个女孩一直说你帅,我觉得今天你才真的帅!");
common_diag.show(screen);
Flag = FIGHT_END_;
return;
}
if (frame_fight >= 6) {
if(fAqing.bAttack) {
if (!(current_enemy->can_defend(fAqing.Attack ))) {
play_sound("voc\\Victory.wav");
if (current_enemy->Attack <= fAqing.Defend)
{
fAqing.HP += 1;
fAqing.Attack += 1;
fAqing.Defend += 1;
sprintf( temp, "你战胜了%s!@最大战斗力提升1 ,攻击力提升1 ,防御力提升1 !", current_enemy->Name);
}
else {
fAqing.HP += current_enemy->HP /10;
fAqing.Attack += current_enemy->Attack /10;
fAqing.Defend += current_enemy->Defend /10;
sprintf( temp, "你战胜了%s!@最大战斗力提升 %d ,攻击力提升 %d ,防御力提升 %d !",
current_enemy->Name, current_enemy->HP /10, current_enemy->Attack /10, current_enemy->Defend /10);
}
common_diag.set_text(temp);
common_diag.show(screen);
Flag = FIGHT_END_;
}
}
else {
if(!(fAqing.can_defend(current_enemy->Attack))) {
play_sound("voc\\Fail.wav");
sprintf(temp, "你输给了%s!", current_enemy->Name );
common_diag.set_text(temp);
common_diag.show(screen);
////FlipPage();
Flag = FIGHT_END_;
}
}
frame_fight =0;
fAqing.bAttack = ! fAqing.bAttack;
current_enemy->bAttack = !current_enemy->bAttack;
}
}
//战斗结束
void FightEnd()
{
current_enemy->cHP = current_enemy->HP;
keys.GetKeyState();
if(keys[SDLK_SPACE]||keys[SDLK_RETURN]) {
if (common_diag.is_over()) {
if (fAqing.cHP == 0) //如果阿青失败
{
if(current_enemy == &fJianke)