"
泡泡堂地图生成器可以生成3种地图,分别是工厂、沙滩、海盗,输入1、2、3代表对应的地图,地图的可消障碍随机出现。
泡泡堂地图生成器的C语言源代码如下。
1 #include
2 #include
3 #include
4
5 char chM;
6 int g【13】【15】;
7
8 void initG(void)
9 {
10 int i=0,j=0;
11 for(;i[span style=""color: rgba(128, 0, 128, 1)"">13;i++)
12 for(j=0;j[span style=""color: rgba(128, 0, 128, 1)"">15;j++)
13 g【i】【j】=0xFF;
14 return;
15 }
16
17 void rndSet(int n)
18 {
19 while(n--)
20 {
21 int x=rand()%//代码效果参考:https://v.youku.com/v_show/id_XNjQwMDEzODEzMg==.html
13;22 int y=(x>=3&&x<=9?rand()%15:rand()%9+3);
23 g【x】【y】=rand()%3+3;
24 }
25 return;
26 }
27
28 void printG(void)
29 {
30 int i=0,j=0;
31 for(;i[span style=""color: rgba(128, 0, 128, 1)"">13;i++)
32 for(j=0;j[span style=""color: rgba(128, 0, 128, 1)"">15;j++)
33 printf(""%02X%c"",g【i】【j】,(j[span style=""color: rgba(128, 0, 128, 1)"">14?' ':'\n'));
34 return;
35 }
36
37 void createMap(void)
38 {
39 int i=0,j=0;
40 char s【】=""xy_AAAAAAAA.map"";
41 FILE *fp=NULL;
42 unsigned char a【472】={0x2E,0x4D,0x61,0x70,0x78,0x79};
43 for(;i[span style=""color: rgba(128, 0, 128, 1)"">8;i++)
44 s【i+3】=rand()%26+'A';
45 if((fp=fopen(s,""wb""))==NULL)
46 return;
47 printf(""FileName:\n%s\n"",s);
48 a【0x0C】=0x04,a【0x18】=a【0x28】=0x0E,a【0x24】=a【0x2C】=0x0C;
49 for(i=0;i[span style=""color: rgba(128, 0, 128, 1)"">13;i++)
50 for(j=0;j[span style=""color: rgba(128, 0, 128, 1)"">15;j++)
51 a【0x50+15*i+j】=(g【i】【j】==3||g【i】【j】==4?0x08:0x09);
52 for(i=0;i[span style=""color: rgba(128, 0, 128, 1)"">13;i++)
53 for(j=0;j[span style=""color: rgba(128, 0, 128, 1)"">15;j++)
54 a【0x113+15*i+j】=g【i】【j】;
55 fwrite(a,1,472,fp);
56 fclose(fp);
57 return;
58 }
59
60 int main(void)
61 {
62 system(""title paoptMap"");
63 system(""color f3"");
64 puts(""Please select the map(1~3):"");
65 initG();
66 srand((unsigned)time(NULL));
67 scanf(""%c"",&chM);
68 if(chM[span style=""color: rgba(128, 0, 0, 1)"">'1'||chM>'3')
69 {
70 puts(""Input Error!"");
71 system(""pause >nul"");
72 return 0;
73 }
74 rndSet(100);
75 if(chM!='1')
76 g【6】【7】=6;
77 if(chM=='3')
78 g【6】【6】=g【6】【8】=6,g【1】【1】=0//代码效果参考:https://v.youku.com/v_show/id_XNjQwMDEzOTQ5Mg==.html
,g【1】【13】=g【11】【1】=1,g【11】【13】=2;79 printG();
80 createMap();
81 system(""pause >nul"");
82 return 0;
83 }
"