File: animate.c

package info (click to toggle)
gravitywars 1.102-34
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 2,468 kB
  • ctags: 553
  • sloc: ansic: 3,938; makefile: 52; sh: 52
file content (127 lines) | stat: -rw-r--r-- 2,753 bytes parent folder | download | duplicates (10)
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
/* GravityWars 1.1,  (C) Sami Niemi -95 */

#include "memory.h"
 
/*------------------------------------------------------------------ animate */
void animate() {

  static short obj,n,m,fr,adj,x,y,num_anim;
  static uchar col,c1,c2,c3;

  static uchar *blockadr;
  static uchar *actionadr;

/* Fade the Red Door */

  c1=51+(SIN[(col_frame>>1)&31]>>8);

  pal[DOOR1COLOR*3]=c1;
  pal[DOOR1COLOR*3+1]=15;
  pal[DOOR1COLOR*3+2]=15;
  palB[DOOR1COLOR*3]=c1;
  palB[DOOR1COLOR*3+1]=15;
  palB[DOOR1COLOR*3+2]=15;
  p2[DOOR1COLOR*3]=48-c1;
  p2[DOOR1COLOR*3+1]=48;
  p2[DOOR1COLOR*3+2]=48;
  p2B[DOOR1COLOR*3]=48-c1;
  p2B[DOOR1COLOR*3+1]=48;
  p2B[DOOR1COLOR*3+2]=48;

  gl_setpalettecolor(DOOR1COLOR,c1,0,0);
  col=42+((2048+SIN[(16+col_frame)&31])>>8);
  c1=col>>1;
  c2=63-col;
  c3=col>>2;

  pal[GREENCOLOR*3]=c1;
  pal[GREENCOLOR*3+1]=c2;
  pal[GREENCOLOR*3+2]=c3;
  palB[GREENCOLOR*3]=c1;
  palB[GREENCOLOR*3+1]=c2;
  palB[GREENCOLOR*3+2]=c3;
  p2[GREENCOLOR*3]=63-c1;
  p2[GREENCOLOR*3+1]=63-c2;
  p2[GREENCOLOR*3+2]=63-c3;
  p2B[GREENCOLOR*3]=63-c1;
  p2B[GREENCOLOR*3+1]=63-c2;
  p2B[GREENCOLOR*3+2]=63-c3;
 
  gl_setpalettecolor(GREENCOLOR,c1,c2,c3);
  col_frame++;


/* Statical Animations */

  num_anim=n_anim-1;
  if (n_anim>0) {
    obj=anim_frame & ANIMSPEED; 
    for(n=obj; n<=num_anim; n+=ANIMSTEP) {
      fr=anim[n].frame;
      if ( ( (anim[n].start ^ anim[n].frame) & 7)==0) 
	putbox(anim[n].x << 5, anim[n].y << 5, block[fr>>3]);
      fr+=anim[n].speed;
      if (fr>anim[n].stop) fr=anim[n].start; 
      anim[n].frame=fr; 
    }
    anim_frame++;
  }
/* Action Animations */

  for(n=0; n<=N_ACTION; n++) {
    if (action[n].state) {
      
      blockadr=block[action[n].frame];
      x=action[n].x-16;
      y=action[n].y-16;
      if(action[n].frame==action[n].start) {

	getbox(x,y,actionback[n]);
	actionadr=actionback[n];

	for(m=0; m<=1023; m++)  /* Plot the new ship before scrolling */
	  actionmix[m]=blockadr[m] ? blockadr[m] : actionadr[m];
	putbox(x,y, actionmix);
 	action[n].frame++;
      }
      else
	if (action[n].frame==action[n].stop) {  
	  
/*	  beep(20000);*/
      
          if (action[n].delay>0)
            action[n].delay--;
	  else {
	    putbox(action[n].x-16,action[n].y-16,actionback[n]);
	    action[n].state=FALSE;
	  } 
	}
	else {
	  if (action[n].delay>0)
	    action[n].delay--;
	  else {

	    actionadr=actionback[n];
 	    for(m=0; m<=1023; m++)  /* Plot the new ship before scrolling */
	      actionmix[m]=blockadr[m] ? blockadr[m] : actionadr[m];
	    putbox(x,y, actionmix);
	    action[n].frame++;
	    action[n].delay=action[n].speed;
	  }
	}
    }
  }
}

void AnimateAll() {

#ifdef ANIM
  vga_waitretrace();
  animate();
#endif

#ifdef SCORE
  putscoreOnly(0,win_y);
#endif 
}