1 ! Z-Tornado - Two player weather action game
3 ! Tornado is copyright (C) 2000-2002 Oliver Feiler
4 ! http://www.lionking.org/~kiza/linux/tornado
5 ! Inform version copyright (c) 2003 Sophie Frühling (sfruehling@aon.at)
7 ! This program is free software; you can redistribute it and/or modify
8 ! it under the terms of the GNU General Public License as published by
9 ! the Free Software Foundation; either version 2 of the License, or
10 ! (at your option) any later version.
12 ! This program is distributed in the hope that it will be useful,
13 ! but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ! GNU General Public License for more details.
17 ! You should have received a copy of the GNU General Public License
18 ! along with this program; if not, write to the Free Software
19 ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 ! Next Generation Weather Function
22 ! rain (strength 1) and hail (strength 2)
23 Array weather_array -> 13;
24 [ DrawWeather x shift ch strength tmp i num_moved num_destroyed xx starty yy;
29 for (i = 0: i < 13: i++) {
31 weather_array->i = ch;
33 weather_array->i = ' ';
36 while (num_moved > 0) {
39 for (i = 0: i < 13: i++) {
40 ! bottom, left, or right border
41 if ((yy >= house1_y + 10) || (xx >= screen_width) || (xx <= 1))
42 weather_array->i = strength;
43 ! skip if this object has disappeared (weather_array->i >= strength)
44 if ((weather_array->i ~= ' ' or ch) && weather_array->i >= strength) {
48 ! did we hit something?
49 ! no hit (there is a space character at xx yy)
50 if (CountDestroyed(' ', xx, yy, 1, 1) == 1) {
51 if (weather_array->i == ' ' or ch) {
53 print (char) weather_array->i;
56 ! we have hit something
58 if (weather_array->i == ' ' or ch)
62 ! if ch == hail and we've hit snow, don't delete
63 if ((ch == ':') && (CountDestroyed('*', xx, yy, 1, 1) == 1))
65 weather_array->i = strength;
70 ChangeSnowWorld(' ', xx, yy);
77 xx = x + shift*(yy - 5);
78 @set_cursor screen_height 1;
81 @set_cursor screen_height 1;
83 ! delete the rain/hail/whatever (whatever ?)
86 while (num_moved > 0) {
88 for (i = 0: i < 13: i++) {
89 if (starty >= yy || starty >= house1_y + 10)
91 if (xx + 13 < 1 || xx > screen_width)
93 tmp = GetLoc(xx, starty);
94 if (tmp < fields && snow_world->tmp == ' ') {
95 @set_cursor starty xx;
102 xx = x + shift*(starty - 5);
103 @set_cursor screen_height 1;
106 return num_destroyed;
109 ! Kianga's Next Generation Snow Machine
110 ! Includes Special SnowLogic(tm)
113 Array snow_startx -> 13;
114 Array snow_starty -> 13;
115 [ DrawSnow x shift xx yy i num_moved tmp;
118 for (i = 0: i < 13: i++) {
120 weather_array->i = '*';
122 weather_array->i = ' ';
124 snow_startx->i = x + i;
129 while (num_moved > 0) {
131 ! move each character
132 for (i = 0: i < 13: i++) {
133 ! bottom, left, or right border
134 if ((snow_y->i >= house1_y + 10)
135 || (snow_x->i >= screen_width) || (snow_x->i <= 1))
136 weather_array->i = 1;
137 ! skip if this object has disappeared (weather_array->i >= strength)
138 if ((weather_array->i ~= ' ' or '*') && weather_array->i >= 1)
141 ! did we hit something?
143 if (CountDestroyed(' ', snow_x->i, snow_y->i, 1, 1) == 1) {
144 if (weather_array->i == ' ' or '*') {
148 print (char) weather_array->i;
151 ! we've hit something
153 weather_array->i = 1;
155 xx = snow_x->i - shift;
159 ChangeSnowWorld('*', xx, yy);
163 if (snow_y->i == screen_height - 1) {
164 weather_array->i = 1;
167 if (CountDestroyed(' ', xx, yy, 1, 1) == 1) {
170 ChangeSnowWorld('*', xx, yy);
175 snow_x->i = snow_x->i + shift;
177 @set_cursor screen_height 1;
180 @set_cursor screen_height 1;
184 while (num_moved > 0) {
186 for (i = 0: i < 13: i++) {
187 if (snow_starty->i >= snow_y->i)
191 tmp = GetLoc(xx, yy);
192 if ((tmp < fields) && (snow_world->tmp == ' ')) {
198 snow_startx->i = snow_startx->i + shift;
200 @set_cursor screen_height 1;
205 ! Probably the ugliest function in the whole program.
206 [ DrawLightning x xx y num_destroyed;
207 ! Is needed if screen_width is smaller than 80, maybe due to some
212 num_destroyed = CountDestroyed(' ', house2_x, house2_y, 17, 10);
214 num_destroyed = CountDestroyed(' ', house1_x, house1_y, 17, 10);
216 @set_cursor 5 xx; print "||";
217 ChangeWorld(xx, 5, 2);
218 @set_cursor 6 xx; print "//";
219 ChangeWorld(xx, 6, 2); xx--;
220 @set_cursor 7 xx; print "//@@92@@92";
221 ChangeWorld(xx, 7, 4); xx--;
222 @set_cursor 8 xx; print "//";
223 ChangeWorld(xx, 8, 2); xx = x + 7;
224 @set_cursor 8 xx; print "@@92@@92";
225 ChangeWorld(xx, 8, 2); xx = x + 3;
226 @set_cursor 9 xx; print "||";
227 ChangeWorld(xx, 9, 2); xx = x + 8;
228 @set_cursor 9 xx; print "@@92@@92";
229 ChangeWorld(xx, 9, 2); xx++;
230 @set_cursor 10 xx; print "@@92@@92";
231 ChangeWorld(xx, 10, 2); xx--;
232 @set_cursor 11 xx; print "//@@92@@92";
233 ChangeWorld(xx, 11, 4); xx--;
234 @set_cursor 12 xx; print "//";
235 ChangeWorld(xx, 12, 2); xx = x + 11;
236 @set_cursor 12 xx; print "@@92@@92";
237 ChangeWorld(xx, 12, 2); xx = x + 7;
238 @set_cursor 13 xx; print "||";
239 ChangeWorld(xx, 13, 2); xx--;
240 @set_cursor screen_height 1;
242 @set_cursor 14 xx; print "//@@92@@92";
243 ChangeWorld(xx, 14, 4); xx--;
244 @set_cursor 15 xx; print "//";
245 ChangeWorld(xx, 15, 2); xx = x + 9;
246 @set_cursor 15 xx; print "@@92@@92";
247 ChangeWorld(xx, 15, 2); xx = x + 4;
248 @set_cursor 16 xx; print "//";
249 ChangeWorld(xx, 16, 2); xx = x + 10;
250 @set_cursor 16 xx; print "@@92@@92";
251 ChangeWorld(xx, 16, 2);
252 @set_cursor 17 xx; print "||";
253 ChangeWorld(xx, 17, 2); xx--;
254 @set_cursor 18 xx; print "//@@92@@92";
255 ChangeWorld(xx, 18, 4); xx--;
256 @set_cursor 19 xx; print "//";
257 ChangeWorld(xx, 19, 2); xx = x + 12;
258 @set_cursor 19 xx; print "@@92@@92";
259 ChangeWorld(xx, 19, 2); xx = x + 7;
260 @set_cursor 20 xx; print "//";
261 ChangeWorld(xx, 20, 2);
262 @set_cursor 21 xx; print "@@92@@92";
263 ChangeWorld(xx, 21, 2); xx++;
264 @set_cursor 22 xx; print "@@92@@92";
265 ChangeWorld(xx, 22, 2); xx++;
266 @set_cursor 23 xx; print "@@92@@92";
267 ChangeWorld(xx, 23, 2);
268 @set_cursor screen_height 1;
270 ! ...and delete it again
272 @set_cursor 5 xx; print " ";
273 @set_cursor 6 xx; print " "; xx--;
274 @set_cursor 7 xx; print " "; xx--;
275 @set_cursor 8 xx; print " "; xx = x + 7;
276 @set_cursor 8 xx; print " "; xx = x + 3;
277 @set_cursor 9 xx; print " "; xx = x + 8;
278 @set_cursor 9 xx; print " "; xx++;
279 @set_cursor 10 xx; print " "; xx--;
280 @set_cursor 11 xx; print " "; xx--;
281 @set_cursor 12 xx; print " "; xx = x + 11;
282 @set_cursor 12 xx; print " "; xx = x + 7;
283 @set_cursor 13 xx; print " "; xx--;
284 @set_cursor 14 xx; print " "; xx--;
285 @set_cursor 15 xx; print " "; xx = x + 9;
286 @set_cursor 15 xx; print " "; xx = x + 4;
287 @set_cursor 16 xx; print " "; xx = x + 10;
288 @set_cursor 16 xx; print " ";
289 @set_cursor 17 xx; print " "; xx--;
290 @set_cursor 18 xx; print " "; xx--;
291 @set_cursor 19 xx; print " "; xx = x + 12;
292 @set_cursor 19 xx; print " "; xx = x + 7;
293 @set_cursor 20 xx; print " ";
294 @set_cursor 21 xx; print " "; xx++;
295 @set_cursor 22 xx; print " "; xx++;
296 @set_cursor 23 xx; print " ";
297 @set_cursor screen_height 1;
299 return CountDestroyed(' ', house2_x, house2_y, 17, 10) - num_destroyed;
300 return CountDestroyed(' ', house1_x, house1_y, 17, 10) - num_destroyed;
303 [ DrawTornado x shift xx y shift_right tmp_x tmp_y width width_tmp
307 tmp_x = x; tmp_y = y;
310 num_destroyed = CountDestroyed(' ', house2_x, house2_y, 17, 10);
312 num_destroyed = CountDestroyed(' ', house1_x, house1_y, 17, 10);
318 if (tmp_y == 18) width = 2;
319 if (tmp_y == 21) width = 1;
322 shift_right = shift_right - 3;
324 xx = tmp_x + shift_right;
325 ChangeWorld(xx, tmp_y, width);
326 for (width_tmp = 0: width_tmp < width: width_tmp++) {
327 xx = tmp_x + shift_right + width_tmp;
328 if (xx > 0 && xx <= screen_width) {
329 @set_cursor tmp_y xx; print "#";
333 tmp_x = tmp_x + shift;
334 if (xx > 0 && xx <= screen_width) {
335 @set_cursor screen_height 1;
339 @set_cursor screen_height 1;
341 tmp_x = x; tmp_y = y;
349 if (tmp_y == 18) width = 2;
350 if (tmp_y == 21) width = 1;
353 shift_right = shift_right - 3;
355 for (width_tmp = 0: width_tmp < width: width_tmp++) {
356 xx = tmp_x + shift_right + width_tmp;
357 if (xx > 0 && xx <= screen_width) {
358 @set_cursor tmp_y xx;
363 tmp_x = tmp_x + shift;
364 if (xx > 0 && xx <= screen_width)
365 @set_cursor screen_height 1;
369 return CountDestroyed(' ', house2_x, house2_y, 17, 10) - num_destroyed;
370 return CountDestroyed(' ', house1_x, house1_y, 17, 10) - num_destroyed;
373 ! This *does* look like a cloud in real life ;)
374 ! @{B0} is a degree character on decent interpreters
376 if (x ~= 0) cloud_x = x;
377 else cloud_x = random(screen_width - 29);
378 @set_cursor 1 cloud_x; print ",/+++*++***+****++++++***+@@92,";
379 @set_cursor 2 cloud_x; print "(*+++*****+++++***+++****++)";
380 @set_cursor 3 cloud_x; print "`@@92++******+*++*++*****+++*/'";
381 @set_cursor 4 cloud_x; print " `@{B0}*,.,*@{B0}'`@{B0}*,.,",
382 "*@{B0}`@{B0}*,.,*@{B0}'";
383 @set_cursor screen_height 1;
386 ! Replace the normal cloud with a bigger one
387 [ DrawTornadoCloud i;
388 for (i = 1: i <= screen_width: i++) {
389 @set_cursor 1 i; print (string) random("+", "*");
390 @set_cursor 2 i; print (string) random("+", "*");
391 @set_cursor 3 i; print (string) random("+", "*");