Import The Mad Bomber by Neil James Brown
[bomber.git] / bomber.inf
1 ! The Mad Bomber - a Z-Machine version of the classic Bomber game
2 !
3 ! by Neil James Brown. Release 3 / 971123. This game is Public Domain.
4 !
5 ! Needs an interpreter that supports timed input. Colour recommended!
6
7 Switches s;
8 Release 3;
9 Serial "971123";
10
11 Array buildings -> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
12 Global hi_score = 50;
13 Array hi_scorer -> "The Mad Bomber         ";
14 Global score = 0;
15 Global skill_level = 0;
16 Global height = 0;
17 Global width = 0;
18 Global win_flag = 0;
19 Global dead_flag = 0;
20 Global use_colour = 1;
21
22 [ Main;
23   Bomber();
24   quit;
25 ];
26
27 [ Bomber i j option temp1;
28   i=$1->0;
29   if (i&1==0) use_colour=0; ! can't use colour - darn it!
30   width=0->33;
31   height=$20->0;
32   if (height>18) height=18;
33   if (i&128==0 || height<15 || width<60)
34   { print "~The Mad Bomber~ has detected one or more problems with your
35      interpreter:^^";
36     if (height<15) print "- The screen height is less than 15 characters
37      high.^";
38     if (width<60) print "- The screen width is less than 60 characters
39      wide.^";
40     if (i&128==0) print "- This interpreter cannot handle timed events.^";
41     print "^Unfortunately, this means that the game is unable to run. Please
42      reconfigure your interpreter, or change for one that fully supports the
43      Z-machine.^^[Please press any key to exit.]^^";
44     @read_char 1 0 0 j;
45     rtrue;
46   }
47   @erase_window $ffff;
48   do
49   { style bold;
50     print "^^^^THE MAD BOMBER^";
51     style roman;
52     print "(3.971123 / Inform 6.13)^^";
53     print "by NJB 1997^^^High score is ", hi_score, " by ";
54     for (temp1=0: temp1<23: temp1++)
55     { print (char) hi_scorer->temp1;
56     }
57     skill_level=0;
58     print "^^^Press <SPACE> to play, I for information or Q to quit.^";
59     do
60     { @read_char 1 0 0 option;
61     } until (option==32 or 73 or 105 or 81 or 113);
62     if (option==32)
63     { score=0;
64       do
65       { BomberGame();
66       } until (dead_flag==1);
67       if (score>hi_score)
68       { hi_score=score;
69         for (temp1=0: temp1<=22: temp1++)
70         { hi_scorer->temp1=32;
71         }
72         @erase_window $ffff;
73         @split_window height;
74         @set_window 1;
75         @set_cursor 2 1;
76         print "Enter your name:";
77         temp1=0;
78         @set_cursor 4 1;
79         do
80         { @read_char 1 0 0 option;
81           if (option>31 && option<127)
82           { if (temp1<22)
83             { hi_scorer->temp1=option;
84               temp1++;
85               @set_cursor 4 temp1;
86               print (char) option;
87             }
88           }
89           if (option==127 or 8)
90           { if (temp1>0)
91             { @set_cursor 4 temp1;
92               print " ";
93               @set_cursor 4 temp1;
94               temp1--;
95               hi_scorer->temp1=32;
96             }
97           }
98         } until (option==13);
99       }
100       @split_window 1;
101       @set_window 0;
102       @erase_window $ffff;
103     }
104     if (option==73 or 105)
105     { @erase_window $ffff;
106       print "^^^^It is examination day at ~The Mad Bomber School of Flying~,
107        but a miscalculation has resulted in the planes not having enough
108        fuel to return to their airstrip. Fortunately, all Mad Bomber planes
109        have an infinite supply of bombs on board. An idea is hatched - the
110        trainee pilots must completely level the cities they are over in order
111        to land safely. The authorities may not be too impressed with this
112        strategy, but we'll worry about that later!^^<SPACE> drops a bomb
113        (you can only drop one bomb at a time).^^<P> pauses the game, with any
114        key resuming.^^<Q> quits the current game.^^^[Press any key to
115        continue]^";
116       @read_char 1 0 0 temp1;
117       @erase_window $ffff;
118     }
119   } until (option==81 or 113);
120   @erase_window $ffff;
121   print "^^^^^^^Thanks for playing!^";
122   rtrue;
123 ];
124
125 [ BomberGame i j x y bx by temp1 temp2 temp3 pausetime;
126   skill_level++;
127   if (skill_level<5) pausetime=3;
128   else
129   { if (skill_level<10) pausetime=2;
130     else pausetime=1;
131   }
132   win_flag=0;
133   dead_flag=0;
134   @erase_window $ffff;
135   x=2; y=2;
136   @split_window height;
137   @set_window 1;
138   if (use_colour==1) @set_colour 1 2;
139   else style reverse;
140   @set_cursor 15 1;
141   spaces(42);
142   @set_cursor 1 1;
143   spaces(42);
144   for (i=1: i<=15: i++)
145   { @set_cursor i 1;
146     print " ";
147     @set_cursor i 42;
148     print " ";
149   }
150   if (use_colour==1)
151   { @set_colour 1 6;
152     for (j=2: j<=14: j++)
153     { @set_cursor j 2;
154       spaces(40);
155     }
156   }
157   else
158   { style roman;
159   }
160   for (i=0: i<20: i++)
161   { switch(skill_level)
162     { 1: by=random(8);
163       2: by=random(10);
164       3: by=random(5)+5;
165       default: by=random(3)+7;
166     } 
167     buildings->i=by;
168     if (use_colour==1)
169     { do
170       { temp1=random(7)+1;
171       } until (temp1~=6);
172       @set_colour 1 temp1;
173     }
174     for (j=(15-by): j<15: j++)
175     { bx=2+(i*2);
176       @set_cursor j bx;
177       if (use_colour==1) print "  ";
178       else print "[]";
179     }
180   }
181   j=1;
182   bx=0;
183   by=0;
184   @set_colour 1 1;
185   @set_cursor 5 46;
186   print "Score:";
187   @set_cursor 8 46;
188   print "High score:";
189   @set_cursor 9 46;
190   print hi_score;
191   UpdateScore();
192   @set_cursor y x;
193   @set_colour 5 6;
194   print "-}";
195   do                              ! Main game loop
196   { @set_cursor 1 width;
197     @read_char 1 1 TimeOut i;
198     if (i==80 or 112) BomberPause();
199     if (i==81 or 113) dead_flag=1;
200     if (bx>0)
201     { @set_cursor by bx;
202       @set_colour 1 6;
203       print " ";
204       by++;
205       temp1=(bx/2)-1;
206       temp2=(15-(buildings->temp1));
207       if (temp2==by)
208       { if (buildings->temp1>0)
209         { score=score+3;
210           UpdateScore();
211         }
212         if (buildings->temp1>3)
213         { for (temp3=temp2: temp3<(temp2+3): temp3++)
214           { @set_cursor temp3 bx;
215             @set_colour 1 6;
216             print "  ";
217           }
218           buildings->temp1=(buildings->temp1)-3;
219         }
220         else
221         { for (temp3=temp2: temp3<=14: temp3++)
222           { @set_cursor temp3 bx;
223             @set_colour 1 6;
224             print "  ";
225           }
226           buildings->temp1=0;
227         }
228         bx=0;
229         by=0;
230       }
231       if (by>15) { bx=0; by=0; }
232       if (bx>0)
233       { @set_cursor by bx;
234         @set_colour 9 6;
235         print "*";
236       }
237     }
238     if (i==32 && bx==0)
239     { bx=x;
240       by=y;
241     }
242     j++;
243     if (j==pausetime)
244     { j=1;
245       @set_cursor y x;
246       @set_colour 1 6;
247       print "  ";
248       x=x+2;
249       if (x==42)
250       { score=score+1;
251         UpdateScore();
252         if (y<14) { x=2; y++; }
253         else win_flag=1;
254       }
255       @set_cursor y x;
256       temp1=(x/2)-1;
257       temp2=(15-(buildings->temp1));
258       if (temp2==y)
259       { @set_colour 3 5;
260         print "##";
261         for (i=0: i<=10: i++)
262         { @read_char 1 1 TimeOut j;
263         }
264         dead_flag=1;
265       }
266       else 
267       { @set_colour 5 6;
268         print "-}";
269       }
270     }
271   }
272   until (win_flag==1 || dead_flag==1);
273   @set_colour 1 1;
274 ];
275
276 [ TimeOut;
277   rtrue;
278 ];
279
280 [ BomberPause spare;
281   @read_char 1 spare;
282 ];
283
284 [ UpdateScore;
285   @set_colour 1 1;
286   @set_cursor 6 46;
287   print score;
288 ];