22 const int Height = 26;
24 const int VCenter = 27;
25 const int HCenter = 63;
26 const int RotSpeed = 128;
28 #define MaxShots 6 // maximum number of shots in flight at once
29 #define ShotLen 4 // length in pixels of the shot
30 #define ShotDelay 3 // updates before you can shoot again
36 char FreeShots = MaxShots;
81 int s = ((
unsigned short *)0xe000)[a & 0xfff];
91 return Sin( a + 0x800 );
100 void Rotate(
int x,
int y,
int a,
int * nx,
int * ny)
102 int cs = Cos(a), sn = Sin(a);
103 *nx = ((cs *
x) - (sn * y) + 32768) / 65536;
104 *ny = ((sn *
x) + (cs * y) + 32768) / 65536;
113 int xc[] = { 0, 4, 0, -4};
114 int yc[] = {-5, 5, 3, 5};
117 for(
int i=0; i<4; i++ )
120 Rotate( xc[i], yc[i], ShipAng, &
x[i], &y[i] );
128 line(
x[0], y[0],
x[1], y[1], 1 );
129 line(
x[1], y[1],
x[2], y[2], 1 );
130 line(
x[2], y[2],
x[3], y[3], 1 );
131 line(
x[3], y[3],
x[0], y[0], 1 );
138 if( FreeShots == 0 || ShotTimer != 0 )
return;
141 Shots[UsedShots].dist = 0;
145 Shots[UsedShots].ang = ShipAng >> 7;
152 ShotTimer = ShotDelay;
162 void MoveShot(
int i )
165 int dist = Shots[i].dist + ShotLen + 1;
167 int a = Shots[i].ang << 7;
170 int x = ( Sin(a) * dist + 32768) / 65536;
171 int y = (-Cos(a) * dist + 32768) / 65536;
174 if( abs(
x) >= Width || abs(y) >= Height )
185 memcpy( Shots + i, Shots + UsedShots,
sizeof(
SHOT) );
196 Shots[i].dist = dist;
203 for(
int i=0; i<UsedShots; i++ ) {
211 for(
int i=0; i<UsedShots; i++ )
214 int d0 = Shots[i].dist;
215 int d1 = d0 + ShotLen;
217 int a = Shots[i].ang << 7;
218 int cs = -Cos(a), sn = Sin(a);
220 x0 = ((sn * d0) + 32768) / 65536 + HCenter;
221 y0 = ((cs * d0) + 32768) / 65536 + VCenter;
222 x1 = ((sn * d1) + 32768) / 65536 + HCenter;
223 y1 = ((cs * d1) + 32768) / 65536 + VCenter;
225 line( x0, y0, x1, y1, 1 );
238 ShipAng = (ShipAng + RotSpeed) & 0x1fff;
246 ShipAng = (ShipAng - RotSpeed) & 0x1fff;
252 if( ShotTimer > 0 ) {
256 if( But & ((1<<1) | (1<<4)) ) {