3 #include <fastgraf.h>
\r
8 extern int far *topography; /* BACKGROUND TILE LIST (ARRAY) */
\r
9 extern int far *terrain; /* FOREGROUND TILE LIST (ARRAY) */
\r
10 extern int view_x, view_y; /* VIEW AREA (UPPER LEFT CORNER) */
\r
11 extern int viewpage; /* CURRENTLY VIEWED PAGE */
\r
14 int frogwatchmode=0;
\r
17 /* ANIMATION VARIABLES */
\r
18 struct ANIMATION fire, water1, water2, uranium, frog;
\r
19 struct ANIMATION *anim_list[ANIM_LIST_TOTAL];
\r
23 * Animates all cells to the next frame.
\r
31 int total_updates=0;
\r
36 /* UPDATE ALL ANIM TYPES FOR NEXT FRAME IF TIME TO DO SO */
\r
37 for (a=0; a<ANIM_LIST_TOTAL; a++) /* CHECK ALL ANIM TYPES */
\r
39 if (anim_list[a]->next<1) /* EVENT_DRIVEN ANIMATION */
\r
41 if (anim_list[a]->next==-1) /* EVENT OCCURING! */
\r
43 anim_list[a]->next=0; /* TURN EVENT OFF */
\r
48 else if (anim_list[a]->next<=time) /* IS ANIM READY FOR NEXT FRAME? */
\r
50 anim_list[a]->next=time+anim_list[a]->delay; /* SET NEXT FRAME TIME */
\r
51 anim_list[a]->current+=1;
\r
52 if (anim_list[a]->current>=anim_list[a]->first+anim_list[a]->total)
\r
53 anim_list[a]->current=anim_list[a]->first;
\r
58 if (total_updates==0) return; /* NO ANIMATION TODAY. SORRY */
\r
60 /* VISUALLY UPDATE ALL VIEWABLE ANIMATIONS */
\r
61 for (y=0; y<VIEW_HEIGHT; y++)
\r
62 for (x=0; x<VIEW_WIDTH; x++)
\r
64 i=VIEW_TO_WORLD(VIEW_TILE(x,y)); /* CONVERT VIEW COORDS TO WORLD */
\r
66 if (is_anim(terrain[i]))
\r
69 while (anim_list[a]->anm!=terrain[i]) a++;
\r
70 tile=anim_list[a]->current;
\r
72 /* COPY TILE TO MIX THEN TO CURRENT SCREEN */
\r
73 pagecopy_tile_op (topography[i], MIXING_TILE, TILEPAGE, TILEPAGE);
\r
74 pagecopy_tile_tr (tile, MIXING_TILE, TILEPAGE, TILEPAGE);
\r
75 pagecopy_tile_op (MIXING_TILE, VIEW_TILE(x,y), TILEPAGE, viewpage);
\r
84 #define CHANCE_FROG_NOT_TURN 95
\r
88 * Move frog somewhere new.
\r
91 void gogofrog (void)
\r
93 int fails=0, r, suc;
\r
96 static int facing=RIGHT;
\r
97 static int walking=FALSE;
\r
98 static long nextfrog;
\r
100 if (frogmode==3) return; /* NO FROG! GO AWAY */
\r
104 terrain[WORLD_TILE(x,y)]=EMPTY_TILE;
\r
105 update_tile (WORLD_TILE(x,y));
\r
112 if (nextfrog>fg_getclock())
\r
113 return; /* NOT TIME TO ANIMATE OUR FROGGIE */
\r
115 frog.next=-1; /* TURN ON ANIMATION EVENT FLAG */
\r
117 /* DETERMINE IF FROG CHANGES FACING */
\r
118 if (random(100)>CHANCE_FROG_NOT_TURN)
\r
124 /* CHANGE FACING */
\r
130 if (r<50) facing=UP;
\r
136 if (r<50) facing=RIGHT;
\r
141 /* UPDATE FACING IMAGE */
\r
144 case RIGHT: frog.current=FROG_FACE_RIGHT; break;
\r
145 case LEFT: frog.current=FROG_FACE_LEFT; break;
\r
146 case DOWN: frog.current=FROG_FACE_DOWN; break;
\r
147 case UP: frog.current=FROG_FACE_UP; break;
\r
149 nextfrog=fg_getclock()+frog.delay;
\r
153 /* DETERMINE IF FROG STARTS/STOPS WALKING */
\r
154 if (walking==FALSE)
\r
159 case RIGHT: frog.current=FROG_WALK_RIGHT; break;
\r
160 case LEFT: frog.current=FROG_WALK_LEFT; break;
\r
161 case DOWN: frog.current=FROG_WALK_DOWN; break;
\r
162 case UP: frog.current=FROG_WALK_UP; break;
\r
165 frog.next=-1; /* TURN ON ANIMATION EVENT FLAG */
\r
166 nextfrog=fg_getclock()+frog.delay;
\r
170 /* DETERMINE IF WE CAN WALK OUR FROGGIE THIS WAY! */
\r
175 case RIGHT: newx++; break;
\r
176 case LEFT: newx--; break;
\r
177 case DOWN: newy++; break;
\r
178 case UP: newy--; break;
\r
181 /* CAN'T MOVE -- OBSTRUCTION OR END OF WORLD! */
\r
182 if (newx<0 || newy<0 || newx>=WORLD_WIDTH || newy>=WORLD_HEIGHT
\r
183 || terrain[WORLD_TILE(newx,newy)]!=EMPTY_TILE)
\r
185 /* UPDATE FACING IMAGE TO REFLECT FROG STANDS FAST */
\r
186 if (random(100)<50) switch (facing)
\r
188 case RIGHT: frog.current=FROG_FACE_RIGHT; break;
\r
189 case LEFT: frog.current=FROG_FACE_LEFT; break;
\r
190 case DOWN: frog.current=FROG_FACE_DOWN; break;
\r
191 case UP: frog.current=FROG_FACE_UP; break;
\r
198 nextfrog=fg_getclock()+frog.delay;
\r
202 /* CAN MOVE! MOVE FROG ALONG */
\r
206 if (++frog.current>=FROG_NUM_WALKS+FROG_WALK_RIGHT)
\r
207 frog.current=FROG_WALK_RIGHT;
\r
211 if (++frog.current>=FROG_NUM_WALKS+FROG_WALK_LEFT)
\r
212 frog.current=FROG_WALK_LEFT;
\r
216 if (++frog.current>=FROG_NUM_WALKS+FROG_WALK_DOWN)
\r
217 frog.current=FROG_WALK_DOWN;
\r
221 if (++frog.current>=FROG_NUM_WALKS+FROG_WALK_UP)
\r
222 frog.current=FROG_WALK_UP;
\r
227 /* DON'T MOVE FROG'S X/Y AT CERTAIN FRAMES */
\r
228 if (frog.current==FROG_WALK_UP+1 ||
\r
229 frog.current==FROG_WALK_UP+3 ||
\r
230 frog.current==FROG_WALK_LEFT+1 ||
\r
231 frog.current==FROG_WALK_LEFT+3 ||
\r
232 frog.current==FROG_WALK_RIGHT+1 ||
\r
233 frog.current==FROG_WALK_RIGHT+3 ||
\r
234 frog.current==FROG_WALK_DOWN+1 ||
\r
235 frog.current==FROG_WALK_DOWN+3 )
\r
238 nextfrog=fg_getclock()+frog.delay;
\r
242 terrain[WORLD_TILE(x,y)]=EMPTY_TILE;
\r
243 terrain[WORLD_TILE(newx,newy)]=ANM_FROG;
\r
248 * Simply put, frog watch mode doesn't work.
\r
249 * I got to the point where I said, gosh darnit, who needs
\r
250 * to watch a stinking frog anyway? It's left as is...
\r
256 if (newx>x) if (view_x<WORLD_WIDTH-view_x) view_x++;
\r
257 else if (newx<x) if (view_x>0) view_x--;
\r
258 else if (newy>y) if (view_y<WORLD_HEIGHT-view_y) view_y++;
\r
259 else if (newy<y) if (view_y>0) view_y--;
\r
260 redraw (NONFLIP_REFRESH);
\r
261 /* if (newx>x) suc=redraw (NONFLIP_SCROLL_RIGHT);
\r
262 else if (newx<x) suc=redraw (NONFLIP_SCROLL_LEFT);
\r
263 else if (newy>y) suc=redraw (NONFLIP_SCROLL_DOWN);
\r
264 else if (newy<y) suc=redraw (NONFLIP_SCROLL_UP);*/
\r
265 viewpage=!viewpage; /* SWAP PAGES */
\r
266 update_tile (WORLD_TILE(x,y));
\r
267 fg_setvpage (viewpage); /* VIEW CORRECT PAGE */
\r
268 } else update_tile (WORLD_TILE(x,y));
\r
272 nextfrog=fg_getclock()+frog.delay;
\r
276 /********************* ADD NEW FROG ************************/
\r
278 /* LOCATE VIEWABLE TILE TO PLACE FROG */
\r
280 x=random(VIEW_WIDTH)+view_x;
\r
281 y=random(VIEW_HEIGHT)+view_y;
\r
283 } while (terrain[WORLD_TILE(x,y)]!=EMPTY_TILE && fails<50);
\r
285 if (fails>=50) /* COULDN'T PLACE FROG */
\r
287 fg_music ("L64EC.DE.C$");
\r
293 terrain[WORLD_TILE(x,y)]=ANM_FROG; /* INSTALL FROG! */
\r
294 frog.next=-1; /* UPDATE EVENT */
\r
296 nextfrog=fg_getclock()+frog.delay;
\r
303 * Initializes any animation information, as in at the program start.
\r
306 void init_anim (void)
\r
308 fire.first=fire.current=34;
\r
311 fire.next=fg_getclock()+fire.delay;
\r
314 water1.first=water1.current=60;
\r
317 water1.next=fg_getclock()+water1.delay;
\r
318 water1.anm=ANM_WATER1;
\r
320 water2.first=water2.current=63;
\r
323 water2.next=fg_getclock()+water2.delay;
\r
324 water2.anm=ANM_WATER2;
\r
326 uranium.first=uranium.current=66;
\r
329 uranium.next=fg_getclock()+uranium.delay;
\r
330 uranium.anm=ANM_URANIUM;
\r
332 frog.first=frog.current=FROG_FACE_RIGHT;
\r
333 frog.total=FROG_NUM_WALKS;
\r
338 anim_list[0]=&fire;
\r
339 anim_list[1]=&water1;
\r
340 anim_list[2]=&water2;
\r
341 anim_list[3]=&uranium;
\r
342 anim_list[4]=&frog;
\r