TempleOSCDV4.12.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:47:56 +02:00
1 parent 93ca216483
commit b84bbff6db
381 files changed
+18356 -18798

No files matched your search

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+100 -100
View File
@@ -83,7 +83,7 @@ $SP,"<1>",BI=1$
#define SCREEN_SCALE 512
#define SCRN_SCALE 512
#define PLOT_GRID_WIDTH 24
#define PLOT_GRID_HEIGHT 24
#define MAN_HEIGHT 125
@@ -110,10 +110,10 @@ U0 CFTransform(CDC *dc,I64 *x,I64 *y,I64 *z)
{
I64 zz;
Mat4x4MulXYZ(dc->r,x,y,z);
zz=SCREEN_SCALE/3+*z;
zz=SCRN_SCALE/3+*z;
if (zz<1) zz=1;
*x=SCREEN_SCALE/2* *x/zz;
*y=SCREEN_SCALE/2* (*y+MAN_HEIGHT)/zz;
*x=SCRN_SCALE/2* *x/zz;
*y=SCRN_SCALE/2* (*y+MAN_HEIGHT)/zz;
*x+=dc->x;
*y+=dc->y;
*z+=dc->z;
@@ -131,8 +131,8 @@ Bool LOSPlot(U8 *,I64 x,I64 y,I64)
Bool LOS(I64 x1,I64 y1,I64 x2,I64 y2)
{//Line of sight
return Line(NULL,x1*LOS_SCALE/SCREEN_SCALE,y1*LOS_SCALE/SCREEN_SCALE,0,
x2*LOS_SCALE/SCREEN_SCALE,y2*LOS_SCALE/SCREEN_SCALE,0,&LOSPlot);
return Line(NULL,x1*LOS_SCALE/SCRN_SCALE,y1*LOS_SCALE/SCRN_SCALE,0,
x2*LOS_SCALE/SCRN_SCALE,y2*LOS_SCALE/SCRN_SCALE,0,&LOSPlot);
}
U0 DrawIt(CTask *task,CDC *dc)
@@ -141,28 +141,28 @@ U0 DrawIt(CTask *task,CDC *dc)
c,x1w,y1w,x1h,y1h,xh,yh,zh,
cx=task->pix_width/2,
cy=task->pix_height/2;
U8 *temps;
U8 *tmps;
F64 tt;
CD3I32 poly[4];
Monster *tempm;
Monster *tmpm;
DCDepthBufAlloc(dc);
MemSet(panels_processed_bitmap,0,(map_width*map_height+7)>>3);
//World to screen
//World to scrn
Mat4x4RotZ(dc->r,man_é+ã/2);
Mat4x4RotX(dc->r,ã/2);
DCMat4x4Set(dc,dc->r);
xh=-man_xx/SCREEN_SCALE; yh=-man_yy/SCREEN_SCALE; zh=0;
xh=-man_xx/SCRN_SCALE; yh=-man_yy/SCRN_SCALE; zh=0;
Mat4x4MulXYZ(dc->r,&xh,&yh,&zh);
Mat4x4TranslationEqu(dc->r,xh,yh,zh);
//Screen to world
//Scrn to world
s2w=Mat4x4IdentNew(task);
Mat4x4RotX(s2w,-ã/2);
Mat4x4RotZ(s2w,-man_é-ã/2);
xh=0; yh=0; zh=SCREEN_SCALE;
xh=0; yh=0; zh=SCRN_SCALE;
Mat4x4MulXYZ(s2w,&xh,&yh,&zh);
//Rotate light source
@@ -194,12 +194,12 @@ U0 DrawIt(CTask *task,CDC *dc)
x1w=x1h;
y1w=y1h;
for (i=0;i<PLOT_GRID_WIDTH*4;i++) {
xx=x1w/SCREEN_SCALE; yy=y1w/SCREEN_SCALE;
x=xx*SCREEN_SCALE-man_xx; y=yy*SCREEN_SCALE-man_yy;
xx=x1w/SCRN_SCALE; yy=y1w/SCRN_SCALE;
x=xx*SCRN_SCALE-man_xx; y=yy*SCRN_SCALE-man_yy;
if (1<=xx<map_width-1 && 1<=yy<map_height-1 &&
!LBts(panels_processed_bitmap,yy*map_width+xx)) {
if ((c=map[yy*map_width+xx]) &&
LOS(xx*SCREEN_SCALE+SCREEN_SCALE/2,yy*SCREEN_SCALE+SCREEN_SCALE/2,
LOS(xx*SCRN_SCALE+SCRN_SCALE/2,yy*SCRN_SCALE+SCRN_SCALE/2,
man_xx,man_yy)) {
if (c==YELLOW)
dc->color=DKGRAY;
@@ -208,62 +208,62 @@ U0 DrawIt(CTask *task,CDC *dc)
poly[0].x=x;
poly[0].y=y;
poly[0].z=0;
poly[1].x=x+SCREEN_SCALE;
poly[1].x=x+SCRN_SCALE;
poly[1].y=y;
poly[1].z=0;
poly[2].x=x+SCREEN_SCALE;
poly[2].y=y+SCREEN_SCALE;
poly[2].x=x+SCRN_SCALE;
poly[2].y=y+SCRN_SCALE;
poly[2].z=0;
poly[3].x=x;
poly[3].y=y+SCREEN_SCALE;
poly[3].y=y+SCRN_SCALE;
poly[3].z=0;
GrFillPoly3(dc,4,poly);
if (c==GREEN) {
x1=x+SCREEN_SCALE/2;
y1=y+SCREEN_SCALE/2;
x1=x+SCRN_SCALE/2;
y1=y+SCRN_SCALE/2;
z1=0;
DCTransform(dc,&x1,&y1,&z1);
if (z1>0)
SpriteMat3B(dc,x+SCREEN_SCALE/2,y+SCREEN_SCALE/2,0,$IB,"<5>",BI=5$,r3);
SpriteMat3B(dc,x+SCRN_SCALE/2,y+SCRN_SCALE/2,0,$IB,"<5>",BI=5$,r3);
} else if (c==YELLOW) {
x1=x+SCREEN_SCALE/2;
y1=y+SCREEN_SCALE/2;
x1=x+SCRN_SCALE/2;
y1=y+SCRN_SCALE/2;
z1=0;
DCTransform(dc,&x1,&y1,&z1);
if (z1>0)
SpriteMat3B(dc,x+SCREEN_SCALE/2,y+SCREEN_SCALE/2,0,$IB,"<6>",BI=6$,r3);
SpriteMat3B(dc,x+SCRN_SCALE/2,y+SCRN_SCALE/2,0,$IB,"<6>",BI=6$,r3);
}
if (!map[(yy+1)*map_width+xx]) {
dc->color=LTGRAY;
poly[0].x=x;
poly[0].y=y+SCREEN_SCALE;
poly[0].y=y+SCRN_SCALE;
poly[0].z=0;
poly[1].x=x+SCREEN_SCALE;
poly[1].y=y+SCREEN_SCALE;
poly[1].x=x+SCRN_SCALE;
poly[1].y=y+SCRN_SCALE;
poly[1].z=0;
poly[2].x=x+SCREEN_SCALE;
poly[2].y=y+SCREEN_SCALE;
poly[2].z=SCREEN_SCALE;
poly[2].x=x+SCRN_SCALE;
poly[2].y=y+SCRN_SCALE;
poly[2].z=SCRN_SCALE;
poly[3].x=x;
poly[3].y=y+SCREEN_SCALE;
poly[3].z=SCREEN_SCALE;
poly[3].y=y+SCRN_SCALE;
poly[3].z=SCRN_SCALE;
GrFillPoly3(dc,4,poly);
}
if (!map[yy*map_width+xx+1]) {
dc->color=WHITE;
poly[0].x=x+SCREEN_SCALE;
poly[0].x=x+SCRN_SCALE;
poly[0].y=y;
poly[0].z=0;
poly[1].x=x+SCREEN_SCALE;
poly[1].y=y+SCREEN_SCALE;
poly[1].x=x+SCRN_SCALE;
poly[1].y=y+SCRN_SCALE;
poly[1].z=0;
poly[2].x=x+SCREEN_SCALE;
poly[2].y=y+SCREEN_SCALE;
poly[2].z=SCREEN_SCALE;
poly[3].x=x+SCREEN_SCALE;
poly[2].x=x+SCRN_SCALE;
poly[2].y=y+SCRN_SCALE;
poly[2].z=SCRN_SCALE;
poly[3].x=x+SCRN_SCALE;
poly[3].y=y;
poly[3].z=SCREEN_SCALE;
poly[3].z=SCRN_SCALE;
GrFillPoly3(dc,4,poly);
}
if (!map[(yy-1)*map_width+xx]) {
@@ -271,15 +271,15 @@ U0 DrawIt(CTask *task,CDC *dc)
poly[0].x=x;
poly[0].y=y;
poly[0].z=0;
poly[1].x=x+SCREEN_SCALE;
poly[1].x=x+SCRN_SCALE;
poly[1].y=y;
poly[1].z=0;
poly[2].x=x+SCREEN_SCALE;
poly[2].x=x+SCRN_SCALE;
poly[2].y=y;
poly[2].z=SCREEN_SCALE;
poly[2].z=SCRN_SCALE;
poly[3].x=x;
poly[3].y=y;
poly[3].z=SCREEN_SCALE;
poly[3].z=SCRN_SCALE;
GrFillPoly3(dc,4,poly);
}
if (!map[yy*map_width+xx-1]) {
@@ -288,14 +288,14 @@ U0 DrawIt(CTask *task,CDC *dc)
poly[0].y=y;
poly[0].z=0;
poly[1].x=x;
poly[1].y=y+SCREEN_SCALE;
poly[1].y=y+SCRN_SCALE;
poly[1].z=0;
poly[2].x=x;
poly[2].y=y+SCREEN_SCALE;
poly[2].z=SCREEN_SCALE;
poly[2].y=y+SCRN_SCALE;
poly[2].z=SCRN_SCALE;
poly[3].x=x;
poly[3].y=y;
poly[3].z=SCREEN_SCALE;
poly[3].z=SCRN_SCALE;
GrFillPoly3(dc,4,poly);
}
}
@@ -308,9 +308,9 @@ U0 DrawIt(CTask *task,CDC *dc)
}
//Draw Monsters
for (i=0,tempm=monsters;i<NUM_MONSTERS;i++,tempm++) {
x=tempm->x;
y=tempm->y;
for (i=0,tmpm=monsters;i<NUM_MONSTERS;i++,tmpm++) {
x=tmpm->x;
y=tmpm->y;
if (LOS(x,y,man_xx,man_yy)) {
x-=man_xx;
y-=man_yy;
@@ -319,13 +319,13 @@ U0 DrawIt(CTask *task,CDC *dc)
zz=0;
DCTransform(dc,&xx,&yy,&zz);
if (zz>0) {
if (tempm->dead)
if (tmpm->dead)
SpriteMat3B(dc,x,y,0,$IB,"<2>",BI=2$,r2);
else {
tt=Tri(tS,1.0);
temps=SpriteInterpolate(tt,$IB,"<3>",BI=3$,$IB,"<4>",BI=4$);
SpriteMat3B(dc,x,y,0,temps,r1);
Free(temps);
tmps=SpriteInterpolate(tt,$IB,"<3>",BI=3$,$IB,"<4>",BI=4$);
SpriteMat3B(dc,x,y,0,tmps,r1);
Free(tmps);
}
}
}
@@ -350,12 +350,12 @@ U0 DrawIt(CTask *task,CDC *dc)
//Draw Things on heads-up Map
dc->color=LTPURPLE;
for (i=0,tempm=monsters;i<NUM_MONSTERS;i++,tempm++)
if (!tempm->dead)
GrPlot3(dc,2*(tempm->x/SCREEN_SCALE),
2*(map_height-1-tempm->y/SCREEN_SCALE),0);
for (i=0,tmpm=monsters;i<NUM_MONSTERS;i++,tmpm++)
if (!tmpm->dead)
GrPlot3(dc,2*(tmpm->x/SCRN_SCALE),
2*(map_height-1-tmpm->y/SCRN_SCALE),0);
dc->color=LTCYAN;
GrPlot3(dc,2*(man_xx/SCREEN_SCALE),2*(map_height-1-man_yy/SCREEN_SCALE),0);
GrPlot3(dc,2*(man_xx/SCRN_SCALE),2*(map_height-1-man_yy/SCRN_SCALE),0);
if (tf) {
dc->color=LTRED;
@@ -378,13 +378,13 @@ U0 Fire()
{
I64 i,x,y;
F64 d,dx,dy,xx=Cos(man_é),yy=Sin(man_é);
Monster *tempm;
Monster *tmpm;
Noise(100,300,1000);
for (i=0,tempm=monsters;i<NUM_MONSTERS;i++,tempm++) {
x=tempm->x;
y=tempm->y;
if (!tempm->dead &&
for (i=0,tmpm=monsters;i<NUM_MONSTERS;i++,tmpm++) {
x=tmpm->x;
y=tmpm->y;
if (!tmpm->dead &&
LOS(x,y,man_xx,man_yy)) {
dx=x-man_xx;
dy=man_yy-y;
@@ -392,7 +392,7 @@ U0 Fire()
dx/=d;
dy/=d;
if (dx*xx+dy*yy>0.995) {
tempm->dead=TRUE;
tmpm->dead=TRUE;
if (!--monsters_left) {
tf=tS;
if (tf-t0<best_score)
@@ -408,7 +408,7 @@ U0 Init()
{
I64 i,x,y;
CDC *dc;
Monster *tempm;
Monster *tmpm;
DocClear;
"$$BG,BLACK$$%h*c",TEXT_ROWS/2,'\n';
@@ -424,16 +424,16 @@ U0 Init()
for (x=0;x<map_width-2;x++)
map[(map_height-2-y)*map_width+x+1]=GrPeek(dc,x*MAP_SCALE,y*MAP_SCALE);
DCDel(dc);
man_xx=(1+MAN_START_X)*SCREEN_SCALE;
man_yy=(map_height-1-MAN_START_Y)*SCREEN_SCALE;
man_xx=(1+MAN_START_X)*SCRN_SCALE;
man_yy=(map_height-1-MAN_START_Y)*SCRN_SCALE;
man_é=0;
for (i=0,tempm=monsters;i<NUM_MONSTERS;i++,tempm++) {
tempm->dead=FALSE;
for (i=0,tmpm=monsters;i<NUM_MONSTERS;i++,tmpm++) {
tmpm->dead=FALSE;
do {
tempm->x=RandU64%((map_width-2)*SCREEN_SCALE)+SCREEN_SCALE;
tempm->y=RandU64%((map_height-2)*SCREEN_SCALE)+SCREEN_SCALE;
} while (!map[(tempm->y/SCREEN_SCALE)*map_width+tempm->x/SCREEN_SCALE]);
tmpm->x=RandU64%((map_width-2)*SCRN_SCALE)+SCRN_SCALE;
tmpm->y=RandU64%((map_height-2)*SCRN_SCALE)+SCRN_SCALE;
} while (!map[(tmpm->y/SCRN_SCALE)*map_width+tmpm->x/SCRN_SCALE]);
}
monsters_left=NUM_MONSTERS;
tf=0;
@@ -443,33 +443,33 @@ U0 Init()
U0 AnimateTask(I64)
{
I64 i,x,y,dd;
Monster *tempm;
Monster *tmpm;
while (TRUE) {
dd=0.25*SCREEN_SCALE*Sin(tS/2);
for (i=0,tempm=monsters;i<NUM_MONSTERS;i++,tempm++)
if (!tempm->dead) {
x=tempm->x;
y=tempm->y;
dd=0.25*SCRN_SCALE*Sin(tS/2);
for (i=0,tmpm=monsters;i<NUM_MONSTERS;i++,tmpm++)
if (!tmpm->dead) {
x=tmpm->x;
y=tmpm->y;
if (i&1)
x+=dd;
else
y+=dd;
if (0<=x<=map_width*SCREEN_SCALE &&
0<=y<=map_height*SCREEN_SCALE &&
map[(y/SCREEN_SCALE)*map_width+x/SCREEN_SCALE]) {
if (!map[(y/SCREEN_SCALE)*map_width+x/SCREEN_SCALE+1] &&
x-RoundI64(x,SCREEN_SCALE)>SCREEN_SCALE/2 ||
!map[(y/SCREEN_SCALE)*map_width+x/SCREEN_SCALE-1] &&
x-RoundI64(x,SCREEN_SCALE)<SCREEN_SCALE/2)
x=RoundI64(x,SCREEN_SCALE)+SCREEN_SCALE/2;
if (!map[(y/SCREEN_SCALE+1)*map_width+x/SCREEN_SCALE] &&
y-RoundI64(y,SCREEN_SCALE)>SCREEN_SCALE/2 ||
!map[(y/SCREEN_SCALE-1)*map_width+x/SCREEN_SCALE] &&
y-RoundI64(y,SCREEN_SCALE)<SCREEN_SCALE/2)
y=RoundI64(y,SCREEN_SCALE)+SCREEN_SCALE/2;
tempm->x=x;
tempm->y=y;
if (0<=x<=map_width*SCRN_SCALE &&
0<=y<=map_height*SCRN_SCALE &&
map[(y/SCRN_SCALE)*map_width+x/SCRN_SCALE]) {
if (!map[(y/SCRN_SCALE)*map_width+x/SCRN_SCALE+1] &&
x-RoundI64(x,SCRN_SCALE)>SCRN_SCALE/2 ||
!map[(y/SCRN_SCALE)*map_width+x/SCRN_SCALE-1] &&
x-RoundI64(x,SCRN_SCALE)<SCRN_SCALE/2)
x=RoundI64(x,SCRN_SCALE)+SCRN_SCALE/2;
if (!map[(y/SCRN_SCALE+1)*map_width+x/SCRN_SCALE] &&
y-RoundI64(y,SCRN_SCALE)>SCRN_SCALE/2 ||
!map[(y/SCRN_SCALE-1)*map_width+x/SCRN_SCALE] &&
y-RoundI64(y,SCRN_SCALE)<SCRN_SCALE/2)
y=RoundI64(y,SCRN_SCALE)+SCRN_SCALE/2;
tmpm->x=x;
tmpm->y=y;
}
}
Sleep(20);
@@ -497,13 +497,13 @@ U0 SongTask(I64)
U0 MoveMan(F64 é)
{
I64 x,y,color,step=SCREEN_SCALE/2;
I64 x,y,color,step=SCRN_SCALE/2;
do {
x=man_xx+step*Cos(é);
y=man_yy-step*Sin(é);
x=Clamp(x,0,map_width*SCREEN_SCALE);
y=Clamp(y,0,map_height*SCREEN_SCALE);
color=map[y/SCREEN_SCALE*map_width+x/SCREEN_SCALE];
x=Clamp(x,0,map_width*SCRN_SCALE);
y=Clamp(y,0,map_height*SCRN_SCALE);
color=map[y/SCRN_SCALE*map_width+x/SCRN_SCALE];
if (color==DKGRAY || color==GREEN) {
man_xx=x;
man_yy=y;
+13 -13
View File
@@ -1,7 +1,7 @@
/*
Char graphics are how games on the C64 were made. You don't need to do it
this way, unless for fun. You can just make device context bigger than
the screen and scroll around.
the scrn and scroll around.
See $LK,"::/Demo/Games/RawHide.HC"$ or $LK,"::/Demo/Games/BigGuns.HC"$.
@@ -17,17 +17,17 @@ The nice thing about character graphics are the animations.
U16 map[MAP_HEIGHT][MAP_WIDTH];
I64 screen_pix_x,screen_pix_y;
I64 scrn_pix_x,scrn_pix_y;
U0 DrawIt(CTask *task,CDC *)
{
U16 *ptr;
I64 i,j,y=screen_pix_y>>3;
I64 i,j,y=scrn_pix_y>>3;
gr.hide_col=gr.hide_row=TRUE;
gr.pan_text_x=7-screen_pix_x&7;
gr.pan_text_y=7-screen_pix_y&7;
gr.pan_text_x=7-scrn_pix_x&7;
gr.pan_text_y=7-scrn_pix_y&7;
for (i=0;i<task->win_height;i++) {
ptr=&map[y++][screen_pix_x>>3];
ptr=&map[y++][scrn_pix_x>>3];
for (j=0;j<task->win_width;j++)
//By the time you clip to window and handle Fs->scroll_x,Fs->scroll_y,
//it is too much trouble to do raw access to gr.text_base like we do
@@ -58,7 +58,7 @@ U0 AnimateTask(I64)
while (TRUE) {
font[CH_WATER]=waves[i++&0x3];
Sleep(200);
WinMgrSync;
Refresh;
}
}
@@ -66,9 +66,9 @@ U0 ScrollTaskX(I64 sign)
{
I64 i;
for (i=0;i<32;i++) {
screen_pix_x=ClampI64(screen_pix_x+sign,0,
scrn_pix_x=ClampI64(scrn_pix_x+sign,0,
(MAP_WIDTH-TEXT_COLS+1)*FONT_WIDTH);
WinMgrSync;
Refresh;
}
}
@@ -76,17 +76,17 @@ U0 ScrollTaskY(I64 sign)
{
I64 i;
for (i=0;i<32;i++) {
screen_pix_y=ClampI64(screen_pix_y+sign,0,
scrn_pix_y=ClampI64(scrn_pix_y+sign,0,
(MAP_HEIGHT-TEXT_ROWS+2)*FONT_HEIGHT);
WinMgrSync;
Refresh;
}
}
U0 Init()
{
I64 i,j,x,y;
screen_pix_x=(MAP_WIDTH-TEXT_COLS)>>1*FONT_WIDTH;
screen_pix_y=(MAP_HEIGHT-TEXT_ROWS)>>1*FONT_HEIGHT;
scrn_pix_x=(MAP_WIDTH-TEXT_COLS)>>1*FONT_WIDTH;
scrn_pix_y=(MAP_HEIGHT-TEXT_ROWS)>>1*FONT_HEIGHT;
MemSetU16(map,CH_WATER+(BLUE<<4+LTBLUE)<<8,MAP_WIDTH*MAP_HEIGHT);
for (i=1;i<MAP_WIDTH-1;i++)
+1 -1
View File
@@ -98,7 +98,7 @@ U0 CircleTrace()
//window mgr calls the UpdateWin() routine
//and places msgs in the que, so there's
//no need to do anything until the window mgr runs.
WinMgrSync;
Refresh;
} while (msg_code!=MSG_IP_L_UP);
music.mute=TRUE; Sleep(200);
+77 -77
View File
@@ -49,10 +49,10 @@ U8 *tiles1[16]={NULL,$IB,"<7>",BI=7$ ,$IB,"<5>",BI=5$ ,NULL,NULL,NULL,NULL,NULL,
U8 *tiles2[16]={NULL,$IB,"<8>",BI=8$ ,$IB,"<5>",BI=5$ ,NULL,NULL,NULL,NULL,NULL,
$IB,"<6>",BI=6$ ,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
#define SCREEN_SCALE 24
#define SCREEN_WIDTH 24
#define SCREEN_HEIGHT 24
I64 screen_x,screen_y;
#define SCRN_SCALE 24
#define SCRN_WIDTH 24
#define SCRN_HEIGHT 24
I64 scrn_x,scrn_y;
#define MAP_SCALE 4
I64 map_width,map_height;
@@ -97,7 +97,7 @@ U0 DrawIt(CTask *task,CDC *dc)
CD3I32 poly[4];
U8 **_tiles;
F64 tt;
Monster *tempm;
Monster *tmpm;
if (Blink(5))
_tiles=tiles1;
@@ -115,32 +115,32 @@ U0 DrawIt(CTask *task,CDC *dc)
//if you did it like $LK,"::/Demo/Games/BigGuns.HC"$
//with a $LK,"CDC",A="MN:CDC"$.
for (y=-SCREEN_HEIGHT/2;y<SCREEN_HEIGHT/2;y++) {
yy=y+screen_y;
for (y=-SCRN_HEIGHT/2;y<SCRN_HEIGHT/2;y++) {
yy=y+scrn_y;
if (0<=yy<map_height)
for (x=-SCREEN_WIDTH/2;x<SCREEN_WIDTH/2;x++) {
xx=x+screen_x;
for (x=-SCRN_WIDTH/2;x<SCRN_WIDTH/2;x++) {
xx=x+scrn_x;
if (0<=xx<map_width) {
if ((color=map[yy*map_width+xx]) &&
LOS(xx,yy,man_x,man_y)) {
if (_tiles[color]) {
x1=x*SCREEN_SCALE;
y1=y*SCREEN_SCALE;
x1=x*SCRN_SCALE;
y1=y*SCRN_SCALE;
z1=0;
DCTransform(dc_t,&x1,&y1,&z1);
Sprite3(dc,x1,y1,z1,_tiles[color]);
} else {//If no tile defined, do solid color.
poly[0].x=x*SCREEN_SCALE;
poly[0].y=y*SCREEN_SCALE;
poly[0].x=x*SCRN_SCALE;
poly[0].y=y*SCRN_SCALE;
poly[0].z=0;
poly[1].x=(x+1)*SCREEN_SCALE-1;
poly[1].y=y*SCREEN_SCALE;
poly[1].x=(x+1)*SCRN_SCALE-1;
poly[1].y=y*SCRN_SCALE;
poly[1].z=0;
poly[2].x=(x+1)*SCREEN_SCALE;
poly[2].y=(y+1)*SCREEN_SCALE-1;
poly[2].x=(x+1)*SCRN_SCALE;
poly[2].y=(y+1)*SCRN_SCALE-1;
poly[2].z=0;
poly[3].x=x*SCREEN_SCALE-1;
poly[3].y=(y+1)*SCREEN_SCALE-1;
poly[3].x=x*SCRN_SCALE-1;
poly[3].y=(y+1)*SCRN_SCALE-1;
poly[3].z=0;
dc_t->color=color;
GrFillPoly3(dc_t,4,poly);
@@ -150,23 +150,23 @@ U0 DrawIt(CTask *task,CDC *dc)
}
}
for (y=-SCREEN_HEIGHT/2;y<SCREEN_HEIGHT/2;y++) {
yy=y+screen_y;
for (y=-SCRN_HEIGHT/2;y<SCRN_HEIGHT/2;y++) {
yy=y+scrn_y;
if (0<=yy<map_height)
for (x=-SCREEN_WIDTH/2;x<SCREEN_WIDTH/2;x++) {
xx=x+screen_x;
for (x=-SCRN_WIDTH/2;x<SCRN_WIDTH/2;x++) {
xx=x+scrn_x;
if (0<=xx<map_width) {
if (!map[yy*map_width+xx]) {
if (yy+1<map_height && LOS(xx,yy+1,man_x,man_y)) {
x1=x*SCREEN_SCALE;
y1=y*SCREEN_SCALE;
x1=x*SCRN_SCALE;
y1=y*SCRN_SCALE;
z1=0;
DCTransform(dc_t,&x1,&y1,&z1);
Sprite3(dc,x1,y1,z1,$IB,"<9>",BI=9$);
}
if (xx+1<map_width && LOS(xx+1,yy,man_x,man_y)) {
x1=x*SCREEN_SCALE;
y1=y*SCREEN_SCALE;
x1=x*SCRN_SCALE;
y1=y*SCRN_SCALE;
z1=0;
DCTransform(dc_t,&x1,&y1,&z1);
Sprite3(dc,x1,y1,z1,$IB,"<10>",BI=10$);
@@ -176,13 +176,13 @@ U0 DrawIt(CTask *task,CDC *dc)
}
}
for (i=0,tempm=monsters;i<NUM_MONSTERS;i++,tempm++)
if (!tempm->dead && LOS(tempm->x,tempm->y,man_x,man_y)) {
x1=(tempm->x-screen_x)*SCREEN_SCALE+SCREEN_SCALE/2;
y1=(tempm->y-screen_y)*SCREEN_SCALE+SCREEN_SCALE/2;
for (i=0,tmpm=monsters;i<NUM_MONSTERS;i++,tmpm++)
if (!tmpm->dead && LOS(tmpm->x,tmpm->y,man_x,man_y)) {
x1=(tmpm->x-scrn_x)*SCRN_SCALE+SCRN_SCALE/2;
y1=(tmpm->y-scrn_y)*SCRN_SCALE+SCRN_SCALE/2;
z1=0;
DCTransform(dc_t,&x1,&y1,&z1);
if (tempm->dx<0) {
if (tmpm->dx<0) {
dc->flags|=DCF_SYMMETRY|DCF_JUST_MIRROR;
DCSymmetrySet(dc,x1,y1,x1,y1+1);
} else
@@ -190,14 +190,14 @@ U0 DrawIt(CTask *task,CDC *dc)
Sprite3(dc,x1,y1,z1,$IB,"<4>",BI=4$);
}
x1=(man_x-screen_x)*SCREEN_SCALE+SCREEN_SCALE/2;
y1=(man_y-screen_y)*SCREEN_SCALE+SCREEN_SCALE/2;
x1=(man_x-scrn_x)*SCRN_SCALE+SCRN_SCALE/2;
y1=(man_y-scrn_y)*SCRN_SCALE+SCRN_SCALE/2;
z1=0;
if (tS-man_attack_t0<0.2) {
x1+=Tri(tS-man_attack_t0,0.2)*SCREEN_SCALE*man_dx;
y1+=Tri(tS-man_attack_t0,0.2)*SCREEN_SCALE*man_dy;
x1+=Tri(tS-man_attack_t0,0.2)*SCRN_SCALE*man_dx;
y1+=Tri(tS-man_attack_t0,0.2)*SCRN_SCALE*man_dy;
if (man_dy!=1)
y1-=Saw(tS-man_attack_t0,0.2)*SCREEN_SCALE;
y1-=Saw(tS-man_attack_t0,0.2)*SCRN_SCALE;
}
DCTransform(dc_t,&x1,&y1,&z1);
if (man_dx<0) {
@@ -229,14 +229,14 @@ U0 DrawIt(CTask *task,CDC *dc)
U0 Attack()
{
I64 i;
Monster *tempm;
Monster *tmpm;
man_attack_t0=tS;
Noise(100,300,1000);
for (i=0,tempm=monsters;i<NUM_MONSTERS;i++,tempm++) {
if (!tempm->dead &&
man_x+man_dx==tempm->x && man_y+man_dy==tempm->y) {
tempm->dead=TRUE;
for (i=0,tmpm=monsters;i<NUM_MONSTERS;i++,tmpm++) {
if (!tmpm->dead &&
man_x+man_dx==tmpm->x && man_y+man_dy==tmpm->y) {
tmpm->dead=TRUE;
if (!--monsters_left) {
tf=tS;
if (tf-t0<best_score)
@@ -250,7 +250,7 @@ U0 Init()
{
I64 i,x,y;
CDC *dc;
Monster *tempm;
Monster *tmpm;
dc=Sprite2DC($IB,"<1>",BI=1$);
map_width =dc->width/MAP_SCALE;
@@ -268,16 +268,16 @@ U0 Init()
man_y=4;
man_dx=0;
man_dy=0;
screen_x=0;
screen_y=0;
for (i=0,tempm=monsters;i<NUM_MONSTERS;i++,tempm++) {
tempm->dead=FALSE;
tempm->dx=0;
tempm->dy=0;
scrn_x=0;
scrn_y=0;
for (i=0,tmpm=monsters;i<NUM_MONSTERS;i++,tmpm++) {
tmpm->dead=FALSE;
tmpm->dx=0;
tmpm->dy=0;
do {
tempm->x=RandU64%(map_width-2)+1;
tempm->y=RandU64%(map_height-2)+1;
} while (!map[(tempm->y)*map_width+tempm->x]);
tmpm->x=RandU64%(map_width-2)+1;
tmpm->y=RandU64%(map_height-2)+1;
} while (!map[(tmpm->y)*map_width+tmpm->x]);
}
monsters_left=NUM_MONSTERS;
tf=0;
@@ -293,20 +293,20 @@ U0 CleanUp()
U0 AnimateTask(I64)
{
I64 i,x,y,dx,dy;
Monster *tempm;
Monster *tmpm;
while (TRUE) {
for (i=0,tempm=monsters;i<NUM_MONSTERS;i++,tempm++)
if (!tempm->dead) {
for (i=0,tmpm=monsters;i<NUM_MONSTERS;i++,tmpm++)
if (!tmpm->dead) {
dx=RandU16%3-1;
dy=RandU16%3-1;
x=tempm->x+dx;
y=tempm->y+dy;
x=tmpm->x+dx;
y=tmpm->y+dy;
if (0<=x<map_width && 0<=y<map_height && map[y*map_width+x]) {
tempm->x=x;
tempm->y=y;
tempm->dx=dx;
tempm->dy=dy;
tmpm->x=x;
tmpm->y=y;
tmpm->dx=dx;
tmpm->dy=dy;
}
}
Sleep(1000);
@@ -368,10 +368,10 @@ U0 DunGen()
if (man_x+1<map_width &&
map[man_y*map_width+(man_x+1)]==DKGRAY) {
man_x++;
if (man_x-screen_x>SCREEN_WIDTH/2-3) {
screen_x+=SCREEN_WIDTH/2;
if (screen_x+SCREEN_WIDTH/2>map_width)
screen_x=map_width-SCREEN_WIDTH/2;
if (man_x-scrn_x>SCRN_WIDTH/2-3) {
scrn_x+=SCRN_WIDTH/2;
if (scrn_x+SCRN_WIDTH/2>map_width)
scrn_x=map_width-SCRN_WIDTH/2;
}
}
break;
@@ -384,10 +384,10 @@ U0 DunGen()
if (man_x-1>=0 &&
map[man_y*map_width+(man_x-1)]==DKGRAY) {
man_x--;
if (man_x-screen_x<-SCREEN_WIDTH/2+3) {
screen_x-=SCREEN_WIDTH/2;
if (screen_x-SCREEN_WIDTH/2<0)
screen_x=SCREEN_WIDTH/2;
if (man_x-scrn_x<-SCRN_WIDTH/2+3) {
scrn_x-=SCRN_WIDTH/2;
if (scrn_x-SCRN_WIDTH/2<0)
scrn_x=SCRN_WIDTH/2;
}
}
break;
@@ -400,10 +400,10 @@ U0 DunGen()
if (man_y-1>=0 &&
map[(man_y-1)*map_width+man_x]==DKGRAY) {
man_y--;
if (man_y-screen_y<-SCREEN_HEIGHT/2+3) {
screen_y-=SCREEN_HEIGHT/2;
if (screen_y-SCREEN_HEIGHT/2<0)
screen_y=SCREEN_HEIGHT/2;
if (man_y-scrn_y<-SCRN_HEIGHT/2+3) {
scrn_y-=SCRN_HEIGHT/2;
if (scrn_y-SCRN_HEIGHT/2<0)
scrn_y=SCRN_HEIGHT/2;
}
}
break;
@@ -416,10 +416,10 @@ U0 DunGen()
if (man_y+1<map_height &&
map[(man_y+1)*map_width+man_x]==DKGRAY) {
man_y++;
if (man_y-screen_y>SCREEN_HEIGHT/2-3) {
screen_y+=SCREEN_HEIGHT/2;
if (screen_y+SCREEN_HEIGHT/2>map_height)
screen_y=map_height-SCREEN_HEIGHT/2;
if (man_y-scrn_y>SCRN_HEIGHT/2-3) {
scrn_y+=SCRN_HEIGHT/2;
if (scrn_y+SCRN_HEIGHT/2>map_height)
scrn_y=map_height-SCRN_HEIGHT/2;
}
}
break;
+82 -82
View File
@@ -21,7 +21,7 @@ RegExeBranch("TempleOS/EagleDive");
#define ROCK_ELEVATION 45
#define SNOW_ELEVATION 55
//Too big makes off-screen draws take place.
//Too big makes off-scrn draws take place.
#define MAX_PANEL_SIZE 16
@@ -294,9 +294,9 @@ U0 MPDoPanels(CTask *task)
{
I64 i,j,l,k1,k2,w,h,threshold,lo,hi;
Bool cont;
Panel *tempp,*start_ptr=NULL,*end_ptr=NULL;
Panel *tmpp,*start_ptr=NULL,*end_ptr=NULL;
CD3I32 *poly;
Obj *tempo;
Obj *tmpo;
lo=Gs->num*(MAP_HEIGHT-1)/mp_cnt;
hi=(Gs->num+1)*(MAP_HEIGHT-1)/mp_cnt;
for (threshold=8;threshold>=1;threshold--)
@@ -317,75 +317,75 @@ U0 MPDoPanels(CTask *task)
}
} while (cont);
if (w>=threshold || h>=threshold) {
tempp=CAlloc(sizeof(Panel),task);
QueInit(&tempp->next_obj);
tmpp=CAlloc(sizeof(Panel),task);
QueInit(&tmpp->next_obj);
l=elevations[j][i];
if (l<=WATER_ELEVATION*MAP_SCALE &&
elevations[j][i+w-1]<=WATER_ELEVATION*MAP_SCALE &&
elevations[j+h-1][i]<=WATER_ELEVATION*MAP_SCALE &&
elevations[j+h-1][i+w-1]<=WATER_ELEVATION*MAP_SCALE) {
tempp->color=BLUE;
tmpp->color=BLUE;
if (Rand<0.05) {
tempo=MAlloc(sizeof(Obj),task);
tempo->p.x=(i+w/2)*MAP_SCALE;
tempo->p.y=(j+h/2)*MAP_SCALE;
tmpo=MAlloc(sizeof(Obj),task);
tmpo->p.x=(i+w/2)*MAP_SCALE;
tmpo->p.y=(j+h/2)*MAP_SCALE;
if (Rand<0.1) {
tempo->fish=FALSE;
tmpo->fish=FALSE;
if (RandI16&1)
tempo->img=$IB,"<2>",BI=2$; //Boat
tmpo->img=$IB,"<2>",BI=2$; //Boat
else
tempo->img=$IB,"<3>",BI=3$; //Boat
tempo->p.z=(WATER_ELEVATION+2)*MAP_SCALE;
tmpo->img=$IB,"<3>",BI=3$; //Boat
tmpo->p.z=(WATER_ELEVATION+2)*MAP_SCALE;
} else {
tempo->fish=TRUE;
tempo->img=$IB,"<1>",BI=1$; //Fish
tempo->p.z=WATER_ELEVATION*MAP_SCALE;
tmpo->fish=TRUE;
tmpo->img=$IB,"<1>",BI=1$; //Fish
tmpo->p.z=WATER_ELEVATION*MAP_SCALE;
}
QueIns(tempo,tempp->last_obj);
QueIns(tmpo,tmpp->last_obj);
}
} else {
if (l<ROCK_ELEVATION*MAP_SCALE) {
if (RandI16&1)
tempp->color=LTGREEN;
tmpp->color=LTGREEN;
else
tempp->color=GREEN+LTGREEN<<16+ROPF_DITHER;
tmpp->color=GREEN+LTGREEN<<16+ROPF_DITHER;
if (Rand<0.03) {
tempo=MAlloc(sizeof(Obj),task);
tempo->p.x=(i+w/2)*MAP_SCALE;
tempo->p.y=(j+h/2)*MAP_SCALE;
tempo->p.z=l;
tempo->img=$IB,"<4>",BI=4$; //Tree
tempo->fish=FALSE;
QueIns(tempo,tempp->last_obj);
tmpo=MAlloc(sizeof(Obj),task);
tmpo->p.x=(i+w/2)*MAP_SCALE;
tmpo->p.y=(j+h/2)*MAP_SCALE;
tmpo->p.z=l;
tmpo->img=$IB,"<4>",BI=4$; //Tree
tmpo->fish=FALSE;
QueIns(tmpo,tmpp->last_obj);
}
} else if (l<SNOW_ELEVATION*MAP_SCALE) {
if (!(RandU16&3)) {
if (RandI16&1)
tempp->color=LTGRAY;
tmpp->color=LTGRAY;
else
tempp->color=DKGRAY+LTGRAY<<16+ROPF_DITHER;
tmpp->color=DKGRAY+LTGRAY<<16+ROPF_DITHER;
} else {
if (RandI16&1)
tempp->color=LTGREEN;
tmpp->color=LTGREEN;
else
tempp->color=GREEN+LTGREEN<<16+ROPF_DITHER;
tmpp->color=GREEN+LTGREEN<<16+ROPF_DITHER;
}
} else {
if (!(RandU16&3)) {
if (RandI16&1)
tempp->color=WHITE;
tmpp->color=WHITE;
else
tempp->color=LTGRAY;
tmpp->color=LTGRAY;
} else {
if (RandI16&1)
tempp->color=LTGRAY+WHITE<<16+ROPF_DITHER;
tmpp->color=LTGRAY+WHITE<<16+ROPF_DITHER;
else
tempp->color=DKGRAY+LTGRAY<<16+ROPF_DITHER;
tmpp->color=DKGRAY+LTGRAY<<16+ROPF_DITHER;
}
}
}
tempp->num_sides=4;
poly=tempp->pts=MAlloc(sizeof(CD3I32)*tempp->num_sides,task);
tmpp->num_sides=4;
poly=tmpp->pts=MAlloc(sizeof(CD3I32)*tmpp->num_sides,task);
poly[0].x=MAP_SCALE*i;
poly[0].y=MAP_SCALE*j;
poly[0].z=elevations[j][i];
@@ -398,13 +398,13 @@ U0 MPDoPanels(CTask *task)
poly[3].x=MAP_SCALE*i;
poly[3].y=MAP_SCALE*(j+h);
poly[3].z=elevations[j+h][i];
tempp->next=start_ptr;
start_ptr=tempp;
tmpp->next=start_ptr;
start_ptr=tmpp;
if (!end_ptr)
end_ptr=tempp;
end_ptr=tmpp;
for (k2=0;k2<h;k2++)
for (k1=0;k1<w;k1++)
panels[j+k2][i+k1]=tempp;
panels[j+k2][i+k1]=tmpp;
}
}
}
@@ -602,21 +602,21 @@ U0 MPDrawIt(CTask *task,CDC *dc)
x3,y3,z3,dd,dd_old,
cx=task->pix_width>>1,
cy=task->pix_height>>1;
Panel reg *tempp;
Obj *tempo;
Panel reg *tmpp;
Obj *tmpo;
Bool w_on_map,h_on_map;
xx=x/(MAP_SCALE*COORDINATE_SCALE);
yy=y/(MAP_SCALE*COORDINATE_SCALE);
//World to screen coordinates
//World to scrn coordinates
Mat4x4IdentEqu(dc->r);
Mat4x4RotZ(dc->r,heading);
Mat4x4RotX(dc->r,è);
Mat4x4RotZ(dc->r,roll);
DCMat4x4Set(dc,dc->r);
//Screen to world coordinates
//Scrn to world coordinates
//This gives us the vects for stepping through the grid in
//the direction the plane is facing. we step horizontally and vertically
@@ -635,7 +635,7 @@ U0 MPDrawIt(CTask *task,CDC *dc)
//The layer for core1 is not cleared automatically
//it is persistent. I have carefully syncronized to the update
//cycle initiated by core0 to prevent flicker.
//cycle initiated by Core0 to prevent flicker.
dc->flags|=DCF_TRANSFORMATION;
dc->transform=&EDTransform;
@@ -691,17 +691,17 @@ U0 MPDrawIt(CTask *task,CDC *dc)
for (j=0;j<strip_height && cnts.jiffies<update_jiffy_limit;j++) {
x1=x1h>>8; y1=y1h>>8;
if (0<=x1<MAP_WIDTH && 0<=y1<MAP_HEIGHT) {
if ((tempp=panels[y1][x1]) && tempp->update!=update) {
tempp->update=update;
if (tempp->cnt>8*(1.1-Gs->idle_factor)) {
dc->color=tempp->color;
tempp->cnt=GrFillPoly3(dc,tempp->num_sides,tempp->pts);
if ((tmpp=panels[y1][x1]) && tmpp->update!=update) {
tmpp->update=update;
if (tmpp->cnt>8*(1.1-Gs->idle_factor)) {
dc->color=tmpp->color;
tmpp->cnt=GrFillPoly3(dc,tmpp->num_sides,tmpp->pts);
} else
tempp->cnt++;
tempo=tempp->next_obj;
while (tempo!=&tempp->next_obj) {
Sprite3(dc,tempo->p.x,tempo->p.y,tempo->p.z,tempo->img);
tempo=tempo->next;
tmpp->cnt++;
tmpo=tmpp->next_obj;
while (tmpo!=&tmpp->next_obj) {
Sprite3(dc,tmpo->p.x,tmpo->p.y,tmpo->p.z,tmpo->img);
tmpo=tmpo->next;
}
}
h_on_map=TRUE;
@@ -938,28 +938,28 @@ U0 Core0EagleDive()
//We made an alias of this we don't want freed.
dc->depth_buf=NULL;
DCDel(dc);
WinMgrSync;
Refresh;
}
Obj *FishFind(I64 x1,I64 y1,I64 *_dd)
{
I64 dd,best_dd=MAX_I64;
Obj *res=NULL,*tempo;
Panel *tempp=panel_head;
while (tempp) {
tempo=tempp->next_obj;
while (tempo!=&tempp->next_obj) {
if (tempo->fish) {
dd=SqrI64(tempo->p.x-x1)+SqrI64(tempo->p.y-y1);
Obj *res=NULL,*tmpo;
Panel *tmpp=panel_head;
while (tmpp) {
tmpo=tmpp->next_obj;
while (tmpo!=&tmpp->next_obj) {
if (tmpo->fish) {
dd=SqrI64(tmpo->p.x-x1)+SqrI64(tmpo->p.y-y1);
if (dd<best_dd) {
best_dd=dd;
res=tempo;
res=tmpo;
}
}
tempo=tempo->next;
tmpo=tmpo->next;
}
tempp=tempp->next;
tmpp=tmpp->next;
}
*_dd=best_dd;
return res;
@@ -971,12 +971,12 @@ U0 AnimateTask(I64)
{//Steadily moves the airplane fwd.
I64 *s2w,x1,y1,z1,dx,dy,dz,dd;
F64 t0=tS,ms,é,d;
Obj *tempo;
Obj *tmpo;
while (TRUE) {
ms=1000*(tS-t0);
t0=tS;
if (!game_tf) {
//Screen to world coordinates
//Scrn to world coordinates
s2w=Mat4x4IdentNew;
Mat4x4RotZ(s2w,-roll);
Mat4x4RotX(s2w,-è);
@@ -1000,12 +1000,12 @@ U0 AnimateTask(I64)
WrapAngles;
}
speed=1.0;
if (rolled_over || !(tempo=FishFind(x1,y1,&dd)))
if (rolled_over || !(tmpo=FishFind(x1,y1,&dd)))
claws_down=0;
else {
d=Sqrt(dd);
x1-=tempo->p.x;
y1-=tempo->p.y;
x1-=tmpo->p.x;
y1-=tmpo->p.y;
é=ACos((dx*x1+dy*y1)/(d*1<<16));
if (é>0 && d<MAP_SCALE*4)
claws_down=Saw(d,MAP_SCALE*4);
@@ -1017,8 +1017,8 @@ U0 AnimateTask(I64)
if (game_tf-game_t0<best_score)
best_score=game_tf-game_t0;
}
QueRem(tempo);
Free(tempo);
QueRem(tmpo);
Free(tmpo);
music.mute=TRUE;
Snd(1000); Sleep(200); Snd(0);
music.mute=FALSE;
@@ -1035,7 +1035,7 @@ U0 AnimateTask(I64)
speed=Clamp(speed+(0.0005-0.0002*Abs(è)/(ã/4)),0.1,5.0);
}
}
WinMgrSync;
Refresh;
}
}
@@ -1104,14 +1104,14 @@ U0 Init()
U0 CleanUp()
{
Panel *tempp=panel_head,*tempp1;
Panel *tmpp=panel_head,*tmpp1;
MPEnd;
while (tempp) {
tempp1=tempp->next;
QueDel(&tempp->next_obj);
Free(tempp->pts);
Free(tempp);
tempp=tempp1;
while (tmpp) {
tmpp1=tmpp->next;
QueDel(&tmpp->next_obj);
Free(tmpp->pts);
Free(tmpp);
tmpp=tmpp1;
}
DCDel(main_dc);
}
@@ -1171,7 +1171,7 @@ U0 EagleDive()
case '\n':
Fs->draw_it=NULL;
CleanUp;
WinMgrSync;
Refresh;
Init;
Fs->draw_it=&DrawIt;
break;
Binary file not shown.
Binary file not shown.
+331 -331
View File
@@ -96,36 +96,36 @@ Obj *ObjFind(F64 x,F64 y,
I64 flag_mask=OF_ACTIVE|OF_RETURNING,I64 flag_val=OF_ACTIVE,
I64 type_mask=-1,I64 player_mask=-1,F64 *_d=NULL)
{
Obj *tempo=obj_head.next,*best=NULL;
Obj *tmpo=obj_head.next,*best=NULL;
F64 dd,best_dd=MAX_F64;
while (tempo!=&obj_head) {
if (tempo->flags&flag_mask==flag_val &&
Bt(&type_mask,tempo->type)&&Bt(&player_mask,tempo->player)) {
dd=Sqr(tempo->x-x)+Sqr(tempo->y-y);
while (tmpo!=&obj_head) {
if (tmpo->flags&flag_mask==flag_val &&
Bt(&type_mask,tmpo->type)&&Bt(&player_mask,tmpo->player)) {
dd=Sqr(tmpo->x-x)+Sqr(tmpo->y-y);
if (dd<best_dd) {
best=tempo;
best=tmpo;
best_dd=dd;
}
}
tempo=tempo->next;
tmpo=tmpo->next;
}
if (_d) *_d=Sqrt(best_dd);
return best;
}
U0 ObjDel(Obj *tempo)
U0 ObjDel(Obj *tmpo)
{
if (tempo) {
if (tS<tempo->death_time)
tempo->flags&=~OF_ACTIVE;
if (tmpo) {
if (tS<tmpo->death_time)
tmpo->flags&=~OF_ACTIVE;
else {
if (tempo->squadron>=0)
SquadronRem(tempo);
QueRem(tempo);
if (tempo->squadron>=0)
LBts(&squadrons[tempo->squadron].dead_mask,tempo->member_num);
num_alive[tempo->player]--;
Free(tempo);
if (tmpo->squadron>=0)
SquadronRem(tmpo);
QueRem(tmpo);
if (tmpo->squadron>=0)
LBts(&squadrons[tmpo->squadron].dead_mask,tmpo->member_num);
num_alive[tmpo->player]--;
Free(tmpo);
}
}
}
@@ -160,53 +160,53 @@ U0 DrawIt(CTask *task,CDC *dc)
{
I64 i,j,k;
F64 d,cur_time=tS;
Obj *tempo;
Torpedo *tempt;
Obj *tmpo;
Torpedo *tmpt;
tempt=torpedo_head.next;
while (tempt!=&torpedo_head) {
tmpt=torpedo_head.next;
while (tmpt!=&torpedo_head) {
dc->color=WHITE;
GrPlot(dc,tempt->x,tempt->y);
tempt=tempt->next;
GrPlot(dc,tmpt->x,tmpt->y);
tmpt=tmpt->next;
}
tempo=obj_head.next;
while (tempo!=&obj_head) {
if (tempo->flags&OF_ACTIVE && tempo->flags&OF_SHIP) {
SpriteZ3B(dc,tempo->x,tempo->y,0,
imgs[tempo->player][tempo->type],tempo->é+ã/2);
tmpo=obj_head.next;
while (tmpo!=&obj_head) {
if (tmpo->flags&OF_ACTIVE && tmpo->flags&OF_SHIP) {
SpriteZ3B(dc,tmpo->x,tmpo->y,0,
imgs[tmpo->player][tmpo->type],tmpo->é+ã/2);
k=0;
for (j=0;j<FIRE_HEIGHT;j++)
for (i=0;i<FIRE_WIDTH;i++)
if (Bt(tempo->fire,k++)) {
if (Bt(tmpo->fire,k++)) {
dc->color=fire_colors[ToI64(k+10*tS)&(FIRE_COLORS-1)];
GrPlot(dc,
tempo->x+FIRE_X_SCALE*(i-FIRE_WIDTH /2+(11*tS+i)%1.7)
*Cos(tempo->é)-
FIRE_Y_SCALE*(j-FIRE_HEIGHT/2+(12*tS+j)%1.7)*Sin(tempo->é),
tempo->y+FIRE_Y_SCALE*(j-FIRE_HEIGHT/2+(19*tS+j)%1.7)
*Cos(tempo->é)+
FIRE_X_SCALE*(i-FIRE_WIDTH /2+(13*tS+i)%1.7)*Sin(tempo->é));
tmpo->x+FIRE_X_SCALE*(i-FIRE_WIDTH /2+(11*tS+i)%1.7)
*Cos(tmpo->é)-
FIRE_Y_SCALE*(j-FIRE_HEIGHT/2+(12*tS+j)%1.7)*Sin(tmpo->é),
tmpo->y+FIRE_Y_SCALE*(j-FIRE_HEIGHT/2+(19*tS+j)%1.7)
*Cos(tmpo->é)+
FIRE_X_SCALE*(i-FIRE_WIDTH /2+(13*tS+i)%1.7)*Sin(tmpo->é));
}
if (Blink) {
dc->color=BLACK;
GrLine(dc,tempo->x+5,tempo->y,tempo->x+5+10,tempo->y);
GrLine(dc,tmpo->x+5,tmpo->y,tmpo->x+5+10,tmpo->y);
if (tempo->life_percent>0) {
if (tempo->life_percent<33)
if (tmpo->life_percent>0) {
if (tmpo->life_percent<33)
dc->color=RED;
else if (tempo->life_percent<66)
else if (tmpo->life_percent<66)
dc->color=YELLOW;
else
dc->color=GREEN;
GrLine(dc,tempo->x+5,tempo->y,
tempo->x+5+10*tempo->life_percent/100,tempo->y);
GrLine(dc,tmpo->x+5,tmpo->y,
tmpo->x+5+10*tmpo->life_percent/100,tmpo->y);
}
dc->color=BLACK;
GrLine(dc,tempo->x+5,tempo->y+2,tempo->x+5+10,tempo->y+2);
d=tempo->fuel*100/tempo->max_fuel;
GrLine(dc,tmpo->x+5,tmpo->y+2,tmpo->x+5+10,tmpo->y+2);
d=tmpo->fuel*100/tmpo->max_fuel;
if (d>0) {
if (d<33)
dc->color=RED;
@@ -214,23 +214,23 @@ U0 DrawIt(CTask *task,CDC *dc)
dc->color=YELLOW;
else
dc->color=GREEN;
GrLine(dc,tempo->x+5,tempo->y+2,tempo->x+5+10*d/100,tempo->y+2);
GrLine(dc,tmpo->x+5,tmpo->y+2,tmpo->x+5+10*d/100,tmpo->y+2);
}
}
}
tempo=tempo->next;
tmpo=tmpo->next;
}
tempo=obj_head.next;
while (tempo!=&obj_head) {
if (tempo->flags&OF_ACTIVE && !(tempo->flags&OF_SHIP))
SpriteZ3B(dc,tempo->x,tempo->y,0,
imgs[tempo->player][tempo->type],tempo->é+ã/2);
if (tempo->flags&OF_SHOOTING) {
tmpo=obj_head.next;
while (tmpo!=&obj_head) {
if (tmpo->flags&OF_ACTIVE && !(tmpo->flags&OF_SHIP))
SpriteZ3B(dc,tmpo->x,tmpo->y,0,
imgs[tmpo->player][tmpo->type],tmpo->é+ã/2);
if (tmpo->flags&OF_SHOOTING) {
dc->color=LTRED;
GrLine(dc,tempo->x,tempo->y,tempo->target_x,tempo->target_y,3);
GrLine(dc,tmpo->x,tmpo->y,tmpo->target_x,tmpo->target_y,3);
}
tempo=tempo->next;
tmpo=tmpo->next;
}
dc->flags|=DCF_TRANSFORMATION;
@@ -277,8 +277,8 @@ U0 Init()
{
I64 i,fighter,ship,player,squadron,
w=Fs->pix_width,h=Fs->pix_height;
Squadron *temps;
Obj *tempo,*tempo1;
Squadron *tmps;
Obj *tmpo,*tmpo1;
QueInit(&obj_head);
QueInit(&torpedo_head);
@@ -292,83 +292,83 @@ U0 Init()
for (player=0;player<NUM_PLAYERS;player++) {
num_alive[player]=0;
for (ship=0;ship<num_cruisers[player];ship++) {
tempo1=CAlloc(sizeof(Obj));
tmpo1=CAlloc(sizeof(Obj));
num_alive[player]++;
tempo1->type=OT_CRUISER; tempo1->player=player;
tempo1->squadron=-1; tempo1->member_num=ship;
tempo1->flags=OF_ACTIVE|OF_SHIP;
tempo1->x=0.8*w*(Rand-0.5)+w>>1; tempo1->y=0.8*h*(Rand-0.5)+h>>1;
tempo1->host=NULL;
tempo1->speed=35.0; tempo1->turn_rate=2.5;
tempo1->é=2*ã*(Rand-0.5); tempo1->dé=0;
tempo1->life_percent=100.0;
tempo1->fuel=tempo1->max_fuel=100000;
tempo1->fuel_burn_rate=100.0;
tempo1->air_guns =5000; tempo1->air_guns_range =30.0;
tempo1->ship_guns=10000; tempo1->ship_guns_range=30.0;
tempo1->torpedos =tempo1->max_torpedos=0;
tempo1->torpedos_range =0.0;
tempo1->next_action_time=0;
QueIns(tempo1,obj_head.last);
tmpo1->type=OT_CRUISER; tmpo1->player=player;
tmpo1->squadron=-1; tmpo1->member_num=ship;
tmpo1->flags=OF_ACTIVE|OF_SHIP;
tmpo1->x=0.8*w*(Rand-0.5)+w>>1; tmpo1->y=0.8*h*(Rand-0.5)+h>>1;
tmpo1->host=NULL;
tmpo1->speed=35.0; tmpo1->turn_rate=2.5;
tmpo1->é=2*ã*(Rand-0.5); tmpo1->dé=0;
tmpo1->life_percent=100.0;
tmpo1->fuel=tmpo1->max_fuel=100000;
tmpo1->fuel_burn_rate=100.0;
tmpo1->air_guns =5000; tmpo1->air_guns_range =30.0;
tmpo1->ship_guns=10000; tmpo1->ship_guns_range=30.0;
tmpo1->torpedos =tmpo1->max_torpedos=0;
tmpo1->torpedos_range =0.0;
tmpo1->next_action_time=0;
QueIns(tmpo1,obj_head.last);
}
for (ship=0;ship<num_carriers[player];ship++) {
tempo1=CAlloc(sizeof(Obj));
tmpo1=CAlloc(sizeof(Obj));
num_alive[player]++;
tempo1->type=OT_CARRIER; tempo1->player=player;
tempo1->squadron=-1; tempo1->member_num=ship;
tempo1->flags=OF_ACTIVE|OF_SHIP;
tempo1->x=0.8*w*(Rand-0.5)+w>>1; tempo1->y=0.8*h*(Rand-0.5)+h>>1;
tempo1->host=NULL;
tempo1->speed=28.0; tempo1->turn_rate=1.0;
tempo1->é=2*ã*(Rand-0.5); tempo1->dé=0;
tempo1->life_percent=100.0;
tempo1->fuel=tempo1->max_fuel=750000;
tempo1->fuel_burn_rate=500.0;
tempo1->air_guns =5000; tempo1->air_guns_range =20.0;
tempo1->ship_guns=2000; tempo1->ship_guns_range=30.0;
tempo1->torpedos =tempo1->max_torpedos=0;
tempo1->torpedos_range =0.0;
tempo1->next_action_time=0;
QueIns(tempo1,obj_head.last);
tmpo1->type=OT_CARRIER; tmpo1->player=player;
tmpo1->squadron=-1; tmpo1->member_num=ship;
tmpo1->flags=OF_ACTIVE|OF_SHIP;
tmpo1->x=0.8*w*(Rand-0.5)+w>>1; tmpo1->y=0.8*h*(Rand-0.5)+h>>1;
tmpo1->host=NULL;
tmpo1->speed=28.0; tmpo1->turn_rate=1.0;
tmpo1->é=2*ã*(Rand-0.5); tmpo1->dé=0;
tmpo1->life_percent=100.0;
tmpo1->fuel=tmpo1->max_fuel=750000;
tmpo1->fuel_burn_rate=500.0;
tmpo1->air_guns =5000; tmpo1->air_guns_range =20.0;
tmpo1->ship_guns=2000; tmpo1->ship_guns_range=30.0;
tmpo1->torpedos =tmpo1->max_torpedos=0;
tmpo1->torpedos_range =0.0;
tmpo1->next_action_time=0;
QueIns(tmpo1,obj_head.last);
for (squadron=0;squadron<num_squadrons_per_carrier[player];
squadron++,num_squadrons++) {
for (fighter=0;fighter<num_planes_per_squadron[player];fighter++) {
tempo=CAlloc(sizeof(Obj));
tmpo=CAlloc(sizeof(Obj));
num_alive[player]++;
tempo->type=OT_FIGHTER; tempo->player=player;
tempo->squadron=num_squadrons; tempo->member_num=fighter;
tempo->flags=0;
tempo->host=tempo1;
tempo->speed=300.0; tempo->turn_rate=25.0;
tempo->life_percent=100.0;
tempo->fuel=tempo->max_fuel=1000;
tempo->fuel_burn_rate=1.0;
tempo->air_guns =35000; tempo->air_guns_range =8.0;
tempo->ship_guns=0; tempo->ship_guns_range=0.0;
tempo->torpedos =tempo->max_torpedos=1;
tempo->torpedos_range =20.0;
QueIns(tempo,obj_head.last);
tmpo->type=OT_FIGHTER; tmpo->player=player;
tmpo->squadron=num_squadrons; tmpo->member_num=fighter;
tmpo->flags=0;
tmpo->host=tmpo1;
tmpo->speed=300.0; tmpo->turn_rate=25.0;
tmpo->life_percent=100.0;
tmpo->fuel=tmpo->max_fuel=1000;
tmpo->fuel_burn_rate=1.0;
tmpo->air_guns =35000; tmpo->air_guns_range =8.0;
tmpo->ship_guns=0; tmpo->ship_guns_range=0.0;
tmpo->torpedos =tmpo->max_torpedos=1;
tmpo->torpedos_range =20.0;
QueIns(tmpo,obj_head.last);
}
}
}
}
squadrons=CAlloc(num_squadrons*sizeof(Squadron));
for (i=0,temps=squadrons;i<num_squadrons;i++,temps++) {
temps->next_in_squadron=temps->last_in_squadron=temps;
temps->squadron=i;
for (i=0,tmps=squadrons;i<num_squadrons;i++,tmps++) {
tmps->next_in_squadron=tmps->last_in_squadron=tmps;
tmps->squadron=i;
}
tempo=obj_head.next;
while (tempo!=&obj_head) {
if (tempo->squadron>=0) {
temps=&squadrons[tempo->squadron];
temps->host =tempo->host;
temps->player=tempo->player;
temps->total_mask=1<<num_planes_per_squadron[tempo->player]-1;
SquadronIns(tempo,temps->last_in_squadron);
tmpo=obj_head.next;
while (tmpo!=&obj_head) {
if (tmpo->squadron>=0) {
tmps=&squadrons[tmpo->squadron];
tmps->host =tmpo->host;
tmps->player=tmpo->player;
tmps->total_mask=1<<num_planes_per_squadron[tmpo->player]-1;
SquadronIns(tmpo,tmps->last_in_squadron);
}
tempo=tempo->next;
tmpo=tmpo->next;
}
}
@@ -382,36 +382,36 @@ U0 CleanUp()
Obj *ObjLaunch(I64 player,I64 squadron=-1,
Obj *host=NULL,F64 x=MAX_F64,F64 y=MAX_F64,F64 é=MAX_F64)
{
Obj *tempo;
Obj *tmpo;
F64 cur_time=tS;
if (!host)
host=ObjFind(x,y,,,1<<OT_CARRIER,1<<player);
if (host && cur_time>host->next_action_time) {
if (é==MAX_F64)
é=Arg(x-host->x,y-host->y);
tempo=obj_head.next;
while (tempo!=&obj_head) {
if (tempo->host==host && (squadron<0||tempo->squadron==squadron) &&
!(tempo->flags&OF_ACTIVE) &&
(tempo->squadron<0||squadrons[tempo->squadron].action==SA_PARKED||
squadrons[tempo->squadron].action==SA_LAUNCHING)) {
if (tempo->fuel<=0.0)
tmpo=obj_head.next;
while (tmpo!=&obj_head) {
if (tmpo->host==host && (squadron<0||tmpo->squadron==squadron) &&
!(tmpo->flags&OF_ACTIVE) &&
(tmpo->squadron<0||squadrons[tmpo->squadron].action==SA_PARKED||
squadrons[tmpo->squadron].action==SA_LAUNCHING)) {
if (tmpo->fuel<=0.0)
//When low on fuel, not zero, gets launched and captured.
LBts(&squadrons[tempo->squadron].dead_mask,tempo->member_num);
LBts(&squadrons[tmpo->squadron].dead_mask,tmpo->member_num);
else {
tempo->flags=tempo->flags&~OF_RETURNING|OF_ACTIVE;
tempo->é=host->é;
tmpo->flags=tmpo->flags&~OF_RETURNING|OF_ACTIVE;
tmpo->é=host->é;
if (x==MAX_F64 || y==MAX_F64 || Sqr(x-host->x)+Sqr(y-host->y)>3*3)
tempo->dé=Wrap(é-tempo->é,-ã);
tmpo->dé=Wrap(é-tmpo->é,-ã);
else
tempo->dé=0;
tempo->x=host->x;
tempo->y=host->y;
tmpo->dé=0;
tmpo->x=host->x;
tmpo->y=host->y;
host->next_action_time=cur_time+0.25/game_speed;
return tempo;
return tmpo;
}
}
tempo=tempo->next;
tmpo=tmpo->next;
}
}
return NULL;
@@ -419,23 +419,23 @@ Obj *ObjLaunch(I64 player,I64 squadron=-1,
Squadron *SquadronLaunch(I64 player,F64 x=MAX_F64,F64 y=MAX_F64)
{
Squadron *temps;
Obj *tempo;
if (tempo=ObjLaunch(player,,,x,y)) {
Squadron *tmps;
Obj *tmpo;
if (tmpo=ObjLaunch(player,,,x,y)) {
if (player==0) {
launch_unit_x1=tempo->x;
launch_unit_y1=tempo->y;
launch_unit_x1=tmpo->x;
launch_unit_y1=tmpo->y;
launch_unit_x2=ip.pos.x-main_task->pix_left-main_task->scroll_x;
launch_unit_y2=ip.pos.y-main_task->pix_top -main_task->scroll_y;
launch_t=tS+0.5;
}
if (tempo->squadron>=0) {
temps=&squadrons[tempo->squadron];
if (temps->action==SA_PARKED) {
temps->action=SA_LAUNCHING;
temps->é=tempo->é+tempo->dé;
if (tmpo->squadron>=0) {
tmps=&squadrons[tmpo->squadron];
if (tmps->action==SA_PARKED) {
tmps->action=SA_LAUNCHING;
tmps->é=tmpo->é+tmpo->dé;
}
return temps;
return tmps;
}
}
return NULL;
@@ -443,31 +443,31 @@ Squadron *SquadronLaunch(I64 player,F64 x=MAX_F64,F64 y=MAX_F64)
Obj *ObjReturn(I64 player,F64 x,F64 y)
{
Obj *tempo;
if (tempo=ObjFind(x,y,OF_ACTIVE,OF_ACTIVE,1<<OT_FIGHTER,1<<player))
tempo->flags|=OF_RETURNING;
return tempo;
Obj *tmpo;
if (tmpo=ObjFind(x,y,OF_ACTIVE,OF_ACTIVE,1<<OT_FIGHTER,1<<player))
tmpo->flags|=OF_RETURNING;
return tmpo;
}
Squadron *SquadronReturn(I64 player,F64 x,F64 y)
{
Squadron *temps;
Obj *tempo;
if (tempo=ObjReturn(player,x,y)) {
Squadron *tmps;
Obj *tmpo;
if (tmpo=ObjReturn(player,x,y)) {
if (player==0) {
return_unit_x1=tempo->x;
return_unit_y1=tempo->y;
if (tempo->host) {
return_unit_x2=tempo->host->x;
return_unit_y2=tempo->host->y;
return_unit_x1=tmpo->x;
return_unit_y1=tmpo->y;
if (tmpo->host) {
return_unit_x2=tmpo->host->x;
return_unit_y2=tmpo->host->y;
return_t=tS+0.5;
}
}
if (tempo->squadron>=0) {
temps=&squadrons[tempo->squadron];
if (temps->action==SA_FLYING)
temps->action=SA_RETURNING;
return temps;
if (tmpo->squadron>=0) {
tmps=&squadrons[tmpo->squadron];
if (tmps->action==SA_FLYING)
tmps->action=SA_RETURNING;
return tmps;
}
}
return NULL;
@@ -475,36 +475,36 @@ Squadron *SquadronReturn(I64 player,F64 x,F64 y)
Obj *ObjSeté(I64 player,F64 x=MAX_F64,F64 y=MAX_F64,F64 é=MAX_F64)
{
Obj *tempo;
if ((tempo=ObjFind(x,y,,,,1<<player)) && tempo->flags&OF_ACTIVE &&
!(tempo->flags&OF_RETURNING)) {
Obj *tmpo;
if ((tmpo=ObjFind(x,y,,,,1<<player)) && tmpo->flags&OF_ACTIVE &&
!(tmpo->flags&OF_RETURNING)) {
if (é==MAX_F64)
é=Arg(x-tempo->x,y-tempo->y);
tempo->dé+=Wrap(é-(tempo->é+tempo->dé),-ã);
return tempo;
é=Arg(x-tmpo->x,y-tmpo->y);
tmpo->dé+=Wrap(é-(tmpo->é+tmpo->dé),-ã);
return tmpo;
}
return NULL;
}
Squadron *SquadronSeté(I64 player,F64 x=MAX_F64,F64 y=MAX_F64,F64 é=MAX_F64)
{
Squadron *temps;
Obj *tempo;
if (tempo=ObjSeté(player,x,y,é)) {
Squadron *tmps;
Obj *tmpo;
if (tmpo=ObjSeté(player,x,y,é)) {
if (player==0) {
set_é_unit_x1=tempo->x;
set_é_unit_y1=tempo->y;
set_é_unit_x1=tmpo->x;
set_é_unit_y1=tmpo->y;
set_é_unit_x2=ip.pos.x-main_task->pix_left-main_task->scroll_x;
set_é_unit_y2=ip.pos.y-main_task->pix_top -main_task->scroll_y;
set_é_t=tS+0.5;
}
if (tempo->squadron>=0) {
temps=&squadrons[tempo->squadron];
if (temps->action==SA_FLYING) {
temps->action=SA_SET_é;
temps->é=tempo->é+tempo->dé;
if (tmpo->squadron>=0) {
tmps=&squadrons[tmpo->squadron];
if (tmps->action==SA_FLYING) {
tmps->action=SA_SET_é;
tmps->é=tmpo->é+tmpo->dé;
}
return temps;
return tmps;
}
}
return NULL;
@@ -513,76 +513,76 @@ Squadron *SquadronSet
U0 SquadronActions()
{
I64 i,completed_mask;
Obj *tempo;
Squadron *temps;
for (i=0,temps=squadrons;i<num_squadrons;i++,temps++) {
Obj *tmpo;
Squadron *tmps;
for (i=0,tmps=squadrons;i<num_squadrons;i++,tmps++) {
completed_mask=0;
switch (temps->action) {
switch (tmps->action) {
case SA_LAUNCHING:
ObjLaunch(temps->player,i,temps->host,,,temps->é);
tempo=temps->next_in_squadron;
while (tempo!=temps) {
LBEqu(&completed_mask,tempo->member_num,tempo->flags&OF_ACTIVE);
tempo=tempo->next_in_squadron;
ObjLaunch(tmps->player,i,tmps->host,,,tmps->é);
tmpo=tmps->next_in_squadron;
while (tmpo!=tmps) {
LBEqu(&completed_mask,tmpo->member_num,tmpo->flags&OF_ACTIVE);
tmpo=tmpo->next_in_squadron;
}
if (completed_mask|temps->dead_mask==temps->total_mask)
temps->action=SA_FLYING;
if (completed_mask|tmps->dead_mask==tmps->total_mask)
tmps->action=SA_FLYING;
break;
case SA_FLYING:
tempo=temps->next_in_squadron;
while (tempo!=temps) {
LBEqu(&completed_mask,tempo->member_num,!(tempo->flags&OF_ACTIVE));
tempo=tempo->next_in_squadron;
tmpo=tmps->next_in_squadron;
while (tmpo!=tmps) {
LBEqu(&completed_mask,tmpo->member_num,!(tmpo->flags&OF_ACTIVE));
tmpo=tmpo->next_in_squadron;
}
if (completed_mask|temps->dead_mask==temps->total_mask)
temps->action=SA_PARKED;
if (completed_mask|tmps->dead_mask==tmps->total_mask)
tmps->action=SA_PARKED;
break;
case SA_SET_é:
tempo=temps->next_in_squadron;
while (tempo!=temps) {
tempo->dé+=Wrap(temps->é-(tempo->é+tempo->dé),-ã);
tempo=tempo->next_in_squadron;
tmpo=tmps->next_in_squadron;
while (tmpo!=tmps) {
tmpo->dé+=Wrap(tmps->é-(tmpo->é+tmpo->dé),-ã);
tmpo=tmpo->next_in_squadron;
}
temps->action=SA_FLYING;
tmps->action=SA_FLYING;
break;
case SA_RETURNING:
tempo=temps->next_in_squadron;
while (tempo!=temps) {
tempo->flags|=OF_RETURNING;
LBEqu(&completed_mask,tempo->member_num,!(tempo->flags&OF_ACTIVE));
tempo=tempo->next_in_squadron;
tmpo=tmps->next_in_squadron;
while (tmpo!=tmps) {
tmpo->flags|=OF_RETURNING;
LBEqu(&completed_mask,tmpo->member_num,!(tmpo->flags&OF_ACTIVE));
tmpo=tmpo->next_in_squadron;
}
if (completed_mask|temps->dead_mask==temps->total_mask)
temps->action=SA_PARKED;
if (completed_mask|tmps->dead_mask==tmps->total_mask)
tmps->action=SA_PARKED;
break;
}
if (temps->dead_mask==temps->total_mask)
temps->action=SA_DEAD;
if (tmps->dead_mask==tmps->total_mask)
tmps->action=SA_DEAD;
}
}
U0 AI(I64 player,F64 period)
{
Obj *tempo;
tempo=obj_head.next;
while (tempo!=&obj_head) {
if (tempo->player==player) {
if (tempo->type==OT_CARRIER && Rand<5*period)
SquadronLaunch(player,tempo->x,tempo->y);
if (tempo->flags&OF_ACTIVE && !(tempo->flags&OF_RETURNING) &&
Obj *tmpo;
tmpo=obj_head.next;
while (tmpo!=&obj_head) {
if (tmpo->player==player) {
if (tmpo->type==OT_CARRIER && Rand<5*period)
SquadronLaunch(player,tmpo->x,tmpo->y);
if (tmpo->flags&OF_ACTIVE && !(tmpo->flags&OF_RETURNING) &&
Rand<10.0*period)
SquadronSeté(player,tempo->x,tempo->y,tempo->é+pi/2*(Rand-0.5));
SquadronSeté(player,tmpo->x,tmpo->y,tmpo->é+pi/2*(Rand-0.5));
}
tempo=tempo->next;
tmpo=tmpo->next;
}
}
U0 ShipDammage(Obj *tempo,F64 d)
U0 ShipDamage(Obj *tmpo,F64 d)
{
I64 i,x=Rand*FIRE_WIDTH,y=Rand*FIRE_HEIGHT;
tempo->life_percent-=d;
tmpo->life_percent-=d;
while (d>0) {
if (!Bts(tempo->fire,y*FIRE_WIDTH+x))
if (!Bts(tmpo->fire,y*FIRE_WIDTH+x))
d-=500.0/(FIRE_WIDTH*FIRE_HEIGHT);
else
d-=25.0/(FIRE_WIDTH*FIRE_HEIGHT);
@@ -600,16 +600,16 @@ U0 ShipDammage(Obj *tempo,F64 d)
}
}
U0 ShipFix(Obj *tempo,F64 d)
U0 ShipFix(Obj *tmpo,F64 d)
{
tempo->life_percent+=d;
if (tempo->life_percent>=100.0) {
tempo->life_percent=100.0;
MemSet(tempo->fire,0,sizeof(Obj.fire));
tmpo->life_percent+=d;
if (tmpo->life_percent>=100.0) {
tmpo->life_percent=100.0;
MemSet(tmpo->fire,0,sizeof(Obj.fire));
return;
}
while (d>0)
if (Btr(tempo->fire,FIRE_WIDTH*FIRE_HEIGHT*Rand))
if (Btr(tmpo->fire,FIRE_WIDTH*FIRE_HEIGHT*Rand))
d-=400.0/(FIRE_WIDTH*FIRE_HEIGHT);
else
d-=20.0/(FIRE_WIDTH*FIRE_HEIGHT);
@@ -618,35 +618,35 @@ U0 ShipFix(Obj *tempo,F64 d)
U0 Combat(F64 period)
{
F64 d;
Obj *tempo,*tempo1;
Torpedo *tempt;
tempo=obj_head.next;
while (tempo!=&obj_head) {
tempo->flags&=~OF_SHOOTING;
if (tempo->flags&OF_ACTIVE &&
(tempo1=ObjFind(tempo->x,tempo->y,OF_ACTIVE,OF_ACTIVE,,
1<<(tempo->player^1),&d))) {
tempo->target_x=tempo1->x;
tempo->target_y=tempo1->y;
if (tempo1->flags&OF_SHIP) {
if (tempo->torpedos && d<tempo->torpedos_range && Rand<125*period) {
tempo->torpedos--;
tempt=CAlloc(sizeof(Torpedo));
tempt->x=tempo->x;
tempt->y=tempo->y;
tempt->speed=100;
d/=tempt->speed*(GAME_SPEED_SCALE*game_speed);
tempo1->death_time=tempt->timeout=tS+d;
tempt->target=tempo1;
tempt->é=Arg(tempo1->x-tempo->x,tempo1->y-tempo->y);
QueIns(tempt,torpedo_head.last);
Obj *tmpo,*tmpo1;
Torpedo *tmpt;
tmpo=obj_head.next;
while (tmpo!=&obj_head) {
tmpo->flags&=~OF_SHOOTING;
if (tmpo->flags&OF_ACTIVE &&
(tmpo1=ObjFind(tmpo->x,tmpo->y,OF_ACTIVE,OF_ACTIVE,,
1<<(tmpo->player^1),&d))) {
tmpo->target_x=tmpo1->x;
tmpo->target_y=tmpo1->y;
if (tmpo1->flags&OF_SHIP) {
if (tmpo->torpedos && d<tmpo->torpedos_range && Rand<125*period) {
tmpo->torpedos--;
tmpt=CAlloc(sizeof(Torpedo));
tmpt->x=tmpo->x;
tmpt->y=tmpo->y;
tmpt->speed=100;
d/=tmpt->speed*(GAME_SPEED_SCALE*game_speed);
tmpo1->death_time=tmpt->timeout=tS+d;
tmpt->target=tmpo1;
tmpt->é=Arg(tmpo1->x-tmpo->x,tmpo1->y-tmpo->y);
QueIns(tmpt,torpedo_head.last);
Sweep(2000,2000,300);
} else if (tempo->ship_guns>0 && d<tempo->ship_guns_range) {
tempo->flags|=OF_SHOOTING;
} else if (tmpo->ship_guns>0 && d<tmpo->ship_guns_range) {
tmpo->flags|=OF_SHOOTING;
if (Rand<125.0*period) {
ShipDammage(tempo1,tempo->ship_guns*Rand*period);
ShipDamage(tmpo1,tmpo->ship_guns*Rand*period);
if (Rand<10.0*period)
tempo1->fuel*=0.75*Rand+0.25;
tmpo1->fuel*=0.75*Rand+0.25;
}
if (tS>next_noise) {
Noise(100,75,200);
@@ -654,12 +654,12 @@ U0 Combat(F64 period)
}
}
} else {
if (tempo->air_guns>0 && d<tempo->air_guns_range) {
tempo->flags|=OF_SHOOTING;
if (tmpo->air_guns>0 && d<tmpo->air_guns_range) {
tmpo->flags|=OF_SHOOTING;
if (Rand<125.0*period) {
tempo1->life_percent-=tempo->air_guns*Rand*period;
tmpo1->life_percent-=tmpo->air_guns*Rand*period;
if (Rand<10.0*period)
tempo1->fuel*=0.75*Rand+0.25;
tmpo1->fuel*=0.75*Rand+0.25;
}
if (tS>next_noise) {
Noise(25,500,2000);
@@ -668,109 +668,109 @@ U0 Combat(F64 period)
}
}
}
tempo=tempo->next;
tmpo=tmpo->next;
}
tempo=obj_head.next;
while (tempo!=&obj_head) {
tempo1=tempo->next;
if (tempo->type==OT_FIGHTER &&
(tempo->life_percent<=0.0 || tempo->flags&OF_ACTIVE &&
tempo->fuel<=0.0 || tempo->host &&
!(tempo->flags&OF_ACTIVE) && tempo->host->life_percent<=0.0))
ObjDel(tempo);
tempo=tempo1;
tmpo=obj_head.next;
while (tmpo!=&obj_head) {
tmpo1=tmpo->next;
if (tmpo->type==OT_FIGHTER &&
(tmpo->life_percent<=0.0 || tmpo->flags&OF_ACTIVE &&
tmpo->fuel<=0.0 || tmpo->host &&
!(tmpo->flags&OF_ACTIVE) && tmpo->host->life_percent<=0.0))
ObjDel(tmpo);
tmpo=tmpo1;
}
tempo=obj_head.next;
while (tempo!=&obj_head) {
tempo1=tempo->next;
if (tempo->life_percent<=0.0)
ObjDel(tempo);
tempo=tempo1;
tmpo=obj_head.next;
while (tmpo!=&obj_head) {
tmpo1=tmpo->next;
if (tmpo->life_percent<=0.0)
ObjDel(tmpo);
tmpo=tmpo1;
}
}
#define ANIMATE_FREQ 50
U0 AnimateTask(I64)
{
Obj *tempo;
Torpedo *tempt,*tempt1;
Obj *tmpo;
Torpedo *tmpt,*tmpt1;
F64 d,period;
while (TRUE) {
period=GAME_SPEED_SCALE*game_speed/ANIMATE_FREQ;
SquadronActions;
tempo=obj_head.next;
while (tempo!=&obj_head) {
if (tempo->flags&OF_ACTIVE && tempo->fuel>0) {
if (tempo->dé) {
d=tempo->dé;
if (d> tempo->turn_rate*period) d= tempo->turn_rate*period;
if (d<-tempo->turn_rate*period) d=-tempo->turn_rate*period;
tempo->é +=d;
tempo->dé-=d;
tmpo=obj_head.next;
while (tmpo!=&obj_head) {
if (tmpo->flags&OF_ACTIVE && tmpo->fuel>0) {
if (tmpo->dé) {
d=tmpo->dé;
if (d> tmpo->turn_rate*period) d= tmpo->turn_rate*period;
if (d<-tmpo->turn_rate*period) d=-tmpo->turn_rate*period;
tmpo->é +=d;
tmpo->dé-=d;
}
tempo->x+=tempo->speed*Cos(tempo->é)*period*tempo->life_percent/100.0;
tempo->y+=tempo->speed*Sin(tempo->é)*period*tempo->life_percent/100.0;
tempo->fuel-=tempo->speed*tempo->fuel_burn_rate*period;
tmpo->x+=tmpo->speed*Cos(tmpo->é)*period*tmpo->life_percent/100.0;
tmpo->y+=tmpo->speed*Sin(tmpo->é)*period*tmpo->life_percent/100.0;
tmpo->fuel-=tmpo->speed*tmpo->fuel_burn_rate*period;
}
tempo=tempo->next;
tmpo=tmpo->next;
}
tempt=torpedo_head.next;
while (tempt!=&torpedo_head) {
tempt1=tempt->next;
if (tS>tempt->timeout) {
tempo=tempt->target;
tmpt=torpedo_head.next;
while (tmpt!=&torpedo_head) {
tmpt1=tmpt->next;
if (tS>tmpt->timeout) {
tmpo=tmpt->target;
if (Rand<0.333333) {
ShipDammage(tempo,150*Rand*Rand);
ShipDamage(tmpo,150*Rand*Rand);
if (Rand<0.333333)
tempo->fuel*=0.75*Rand+0.25;
tmpo->fuel*=0.75*Rand+0.25;
}
QueRem(tempt);
Free(tempt);
QueRem(tmpt);
Free(tmpt);
} else {
tempt->x+=tempt->speed*Cos(tempt->é)*period;
tempt->y+=tempt->speed*Sin(tempt->é)*period;
tmpt->x+=tmpt->speed*Cos(tmpt->é)*period;
tmpt->y+=tmpt->speed*Sin(tmpt->é)*period;
}
tempt=tempt1;
tmpt=tmpt1;
}
tempo=obj_head.next;
while (tempo!=&obj_head) {
if (tempo->host && !(tempo->flags&OF_ACTIVE)) {
tempo->x=tempo->host->x;
tempo->y=tempo->host->y;
tmpo=obj_head.next;
while (tmpo!=&obj_head) {
if (tmpo->host && !(tmpo->flags&OF_ACTIVE)) {
tmpo->x=tmpo->host->x;
tmpo->y=tmpo->host->y;
}
tempo=tempo->next;
tmpo=tmpo->next;
}
tempo=obj_head.next;
while (tempo!=&obj_head) {
if (tempo->flags&OF_ACTIVE) {
if (tempo->host) {
d=Sqrt(Sqr(tempo->x-tempo->host->x)+Sqr(tempo->y-tempo->host->y));
if (d<8 && tempo->max_fuel-tempo->fuel>30) {
tempo->life_percent=100.0;
if (tempo->host->fuel>0) {
d=tempo->max_fuel-tempo->fuel;
if (d>tempo->host->fuel) d=tempo->host->fuel;
tempo->host->fuel-=d;
tempo->fuel+=d;
tmpo=obj_head.next;
while (tmpo!=&obj_head) {
if (tmpo->flags&OF_ACTIVE) {
if (tmpo->host) {
d=Sqrt(Sqr(tmpo->x-tmpo->host->x)+Sqr(tmpo->y-tmpo->host->y));
if (d<8 && tmpo->max_fuel-tmpo->fuel>30) {
tmpo->life_percent=100.0;
if (tmpo->host->fuel>0) {
d=tmpo->max_fuel-tmpo->fuel;
if (d>tmpo->host->fuel) d=tmpo->host->fuel;
tmpo->host->fuel-=d;
tmpo->fuel+=d;
}
tempo->torpedos=tempo->max_torpedos;
tempo->x=tempo->host->x;
tempo->y=tempo->host->y;
tempo->flags&=~OF_ACTIVE;
} else if (d>tempo->fuel-250)
tempo->flags|=OF_RETURNING;
if (tempo->flags&OF_RETURNING)
tempo->dé+=Wrap(Arg(tempo->host->x-tempo->x,
tempo->host->y-tempo->y)-(tempo->é+tempo->dé),-ã);
} else if (tempo->type==OT_CARRIER)
ShipFix(tempo,2.5*period);
tmpo->torpedos=tmpo->max_torpedos;
tmpo->x=tmpo->host->x;
tmpo->y=tmpo->host->y;
tmpo->flags&=~OF_ACTIVE;
} else if (d>tmpo->fuel-250)
tmpo->flags|=OF_RETURNING;
if (tmpo->flags&OF_RETURNING)
tmpo->dé+=Wrap(Arg(tmpo->host->x-tmpo->x,
tmpo->host->y-tmpo->y)-(tmpo->é+tmpo->dé),-ã);
} else if (tmpo->type==OT_CARRIER)
ShipFix(tmpo,2.5*period);
}
tempo=tempo->next;
tmpo=tmpo->next;
}
AI(1,period);
@@ -793,7 +793,7 @@ U0 FlatTops()
PopUpOk("$$GREEN$${Left-Mouse}$$FG$$\t\tChange Course\n"
"$$GREEN$${Right-Mouse}$$FG$$\t\tLaunch Squadron\n"
"$$GREEN$${Right-Double-Mouse}$$FG$$\tReturn Squadron\n"
"$$GREEN$${Ctrl-Left Grab}$$FG$$\tScroll Screen\n");
"$$GREEN$${Ctrl-Left Grab}$$FG$$\tScroll Scrn\n");
MenuPush(
"File {"
" Abort(,CH_SHIFT_ESC);"
+43 -43
View File
@@ -11,22 +11,22 @@ CMathODE *ode=NULL;
U0 DrawIt(CTask *,CDC *dc)
{
MyMass *tempm;
MySpring *temps;
MyMass *tmpm;
MySpring *tmps;
dc->color=RED;
temps=ode->next_spring;
while (temps!=&ode->next_spring) {
GrLine(dc,temps->end1->x,temps->end1->y,
temps->end2->x,temps->end2->y);
temps=temps->next;
tmps=ode->next_spring;
while (tmps!=&ode->next_spring) {
GrLine(dc,tmps->end1->x,tmps->end1->y,
tmps->end2->x,tmps->end2->y);
tmps=tmps->next;
}
dc->color=BLACK;
tempm=ode->next_mass;
while (tempm!=&ode->next_mass) {
GrCircle(dc,tempm->x,tempm->y,tempm->radius);
tempm=tempm->next;
tmpm=ode->next_mass;
while (tmpm!=&ode->next_mass) {
GrCircle(dc,tmpm->x,tmpm->y,tmpm->radius);
tmpm=tmpm->next;
}
}
@@ -36,46 +36,46 @@ U0 MyDerivative(CMathODE *ode,F64,COrder2D3 *,COrder2D3 *)
//We can add new forces here.
F64 d,dd;
CD3 p;
MyMass *tempm1,*tempm2;
MyMass *tmpm1,*tmpm2;
tempm1=ode->next_mass;
while (tempm1!=&ode->next_mass) {
tempm2=tempm1->next;
while (tempm2!=&ode->next_mass) {
D3Sub(&p,&tempm2->state->x,&tempm1->state->x);
tmpm1=ode->next_mass;
while (tmpm1!=&ode->next_mass) {
tmpm2=tmpm1->next;
while (tmpm2!=&ode->next_mass) {
D3Sub(&p,&tmpm2->state->x,&tmpm1->state->x);
dd=D3NormSqr(&p);
if (dd<=Sqr(tempm1->radius+tempm2->radius)) {
if (dd<=Sqr(tmpm1->radius+tmpm2->radius)) {
d=Sqrt(dd)+0.0001;
dd=10.0*Sqr(Sqr(Sqr(tempm1->radius+tempm2->radius)-dd));
dd=10.0*Sqr(Sqr(Sqr(tmpm1->radius+tmpm2->radius)-dd));
D3MulEqu(&p,dd/d);
D3AddEqu(&tempm2->DstateDt->DxDt,&p);
D3SubEqu(&tempm1->DstateDt->DxDt,&p);
D3AddEqu(&tmpm2->DstateDt->DxDt,&p);
D3SubEqu(&tmpm1->DstateDt->DxDt,&p);
}
tempm2=tempm2->next;
tmpm2=tmpm2->next;
}
tempm1=tempm1->next;
tmpm1=tmpm1->next;
}
}
U0 PlaceMass(I64 x, I64 y)
{
MyMass *tempm=CAlloc(sizeof(MyMass));
tempm->mass=1.0;
tempm->drag_profile_factor=100.0;
tempm->x=x;
tempm->y=y;
tempm->radius=10*(Rand+0.25);
QueIns(tempm,ode->last_mass);
MyMass *tmpm=CAlloc(sizeof(MyMass));
tmpm->mass=1.0;
tmpm->drag_profile_factor=100.0;
tmpm->x=x;
tmpm->y=y;
tmpm->radius=10*(Rand+0.25);
QueIns(tmpm,ode->last_mass);
}
U0 PlaceSpring(MyMass *tempm1,MyMass *tempm2)
U0 PlaceSpring(MyMass *tmpm1,MyMass *tmpm2)
{
MySpring *temps=CAlloc(sizeof(MySpring));
temps->end1=tempm1;
temps->end2=tempm2;
temps->const=10000;
temps->rest_len=100;
QueIns(temps,ode->last_spring);
MySpring *tmps=CAlloc(sizeof(MySpring));
tmps->end1=tmpm1;
tmps->end2=tmpm2;
tmps->const=10000;
tmps->rest_len=100;
QueIns(tmps,ode->last_spring);
}
U0 Init()
@@ -100,7 +100,7 @@ U0 CleanUp()
U0 MassSpringDemo()
{
I64 msg_code,a1,a2;
MyMass *tempm1=NULL,*tempm2=NULL;
MyMass *tmpm1=NULL,*tmpm2=NULL;
PopUpOk("Left-Click to place mas\n"
"Right-Click and drag to\n"
@@ -137,13 +137,13 @@ U0 MassSpringDemo()
PlaceMass(a1,a2);
break;
case MSG_IP_R_DOWN:
tempm1=MassFind(ode,a1,a2);
tempm2=NULL;
tmpm1=MassFind(ode,a1,a2);
tmpm2=NULL;
break;
case MSG_IP_R_UP:
if (tempm1 && (tempm2=MassFind(ode,a1,a2)) && tempm1!=tempm2)
PlaceSpring(tempm1,tempm2);
tempm1=tempm2=NULL;
if (tmpm1 && (tmpm2=MassFind(ode,a1,a2)) && tmpm1!=tmpm2)
PlaceSpring(tmpm1,tmpm2);
tmpm1=tmpm2=NULL;
break;
case MSG_KEY_DOWN:
switch (a1) {
+1 -1
View File
@@ -102,7 +102,7 @@ U0 Maze()
ch=GetChar;
break;
}
WinMgrSync;
Refresh;
}
} while (ch!=CH_SHIFT_ESC && ch!=CH_ESC);
catch
+59 -64
View File
@@ -17,23 +17,18 @@ CDC *map_dc;
#define GATE_HEIGHT 7
F64 gate_é,gate_t;
$BG,10$#define GE_COW 0
$BG,10$
$SP,"<1>",BI=1$ $SP,"<2>",BI=2$ $SP,"<3>",BI=3$
#define GE_BULL 1
$SP,"<4>",BI=4$ $SP,"<5>",BI=5$ $SP,"<6>",BI=6$
#define GE_HORSE 2
$SP,"<7>",BI=7$ $SP,"<8>",BI=8$
#define GE_NUM 3
$SP,"<9>",BI=9$
$SP,"<10>",BI=10$
@@ -148,35 +143,35 @@ U0 RiverDropsDel()
U0 RiverDropsNext(CTask *mem_task)
{
RiverDrop *tempr,*tempr1;
RiverDrop *tmpr,*tmpr1;
while (LBts(&rd_lock,0))
Yield;
tempr=rd_head.next;
while (tempr!=&rd_head) {
tempr1=tempr->next;
if (++tempr->y>=MAP_HEIGHT-MAP_BORDER) {
QueRem(tempr);
Free(tempr);
tmpr=rd_head.next;
while (tmpr!=&rd_head) {
tmpr1=tmpr->next;
if (++tmpr->y>=MAP_HEIGHT-MAP_BORDER) {
QueRem(tmpr);
Free(tmpr);
} else {
do {
if (RandU16&1 && GrPeek(map_dc,r_x[tempr->y]+tempr->dx,
tempr->y+tempr->dy)==BLUE)
if (RandU16&1 && GrPeek(map_dc,r_x[tmpr->y]+tmpr->dx,
tmpr->y+tmpr->dy)==BLUE)
break;
tempr->dx=ClampI64(tempr->dx+RandU16%3-1,-r_width[tempr->y]/2,
r_width[tempr->y]/2);
tempr->dy=ClampI64(tempr->dy+RandU16%3-1,-r_width[tempr->y]/2,
r_width[tempr->y]/2);
} while (GrPeek(map_dc,r_x[tempr->y]+tempr->dx,
tempr->y+tempr->dy)!=BLUE &&
GrPeek(map_dc,r_x[tempr->y],tempr->y)==BLUE);//Might be reiniting
tmpr->dx=ClampI64(tmpr->dx+RandU16%3-1,-r_width[tmpr->y]/2,
r_width[tmpr->y]/2);
tmpr->dy=ClampI64(tmpr->dy+RandU16%3-1,-r_width[tmpr->y]/2,
r_width[tmpr->y]/2);
} while (GrPeek(map_dc,r_x[tmpr->y]+tmpr->dx,
tmpr->y+tmpr->dy)!=BLUE &&
GrPeek(map_dc,r_x[tmpr->y],tmpr->y)==BLUE);//Might be reiniting
}
tempr=tempr1;
tmpr=tmpr1;
}
tempr=MAlloc(sizeof(RiverDrop),mem_task);
tempr->y=MAP_BORDER;
tempr->dx=0;
tempr->dy=0;
QueIns(tempr,rd_head.last);
tmpr=MAlloc(sizeof(RiverDrop),mem_task);
tmpr->y=MAP_BORDER;
tmpr->dx=0;
tmpr->dy=0;
QueIns(tmpr,rd_head.last);
LBtr(&rd_lock,0);
}
@@ -184,14 +179,14 @@ U0 RiverDropsDraw(CDC *dc,I64 cx,I64 cy)
{
I64 i;
F64 t=tS;
RiverDrop *tempr;
RiverDrop *tmpr;
while (LBts(&rd_lock,0))
Yield;
tempr=rd_head.next;
tmpr=rd_head.next;
dc->color=LTBLUE;
while (tempr!=&rd_head) {
GrPlot(dc,r_x[tempr->y]+tempr->dx-cx,tempr->y+tempr->dy-cy);
tempr=tempr->next;
while (tmpr!=&rd_head) {
GrPlot(dc,r_x[tmpr->y]+tmpr->dx-cx,tmpr->y+tmpr->dy-cy);
tmpr=tmpr->next;
}
LBtr(&rd_lock,0);
@@ -336,7 +331,7 @@ U0 AnimateTask(CTask *parent)
I64 i,cx,cy,cursor_x,cursor_y,dd,ddx,ddy,cnt,max_speed=MAX_I64,updates=0,
my_outside_cnt;
F64 f,d,dx,dy,s,stress;
Animal *tempa,*tempa1;
Animal *tmpa,*tmpa1;
while (TRUE) {
max_speed=ClampU64(max_speed,MAX_U32/3,200*MAX_U32);
cx=(MAP_WIDTH -parent->pix_width)/2,
@@ -349,30 +344,30 @@ U0 AnimateTask(CTask *parent)
gate_t=tS;
RedrawGate;
for (i=0;i<NUM_ANIMALS;i++) {
tempa=&a[i];
if (!tempa->dead) {
tmpa=&a[i];
if (!tmpa->dead) {
//Move away from horse
ddx=tempa->x.i32[1]-cursor_x;
ddy=tempa->y.i32[1]-cursor_y;
ddx=tmpa->x.i32[1]-cursor_x;
ddy=tmpa->y.i32[1]-cursor_y;
if (dd=SqrI64(ddx)+SqrI64(ddy)) {
d=Sqrt(dd);
dx=ddx/d;
dy=ddy/d;
f=5.0e2*MAX_U32/dd;
tempa->dx+=f*dx;
tempa->dy+=f*dy;
tmpa->dx+=f*dx;
tmpa->dy+=f*dy;
}
//Resel buddy about every NUM_ANIMALS*10ms=5.12 seconds
tempa1=&a[tempa->buddy];
if (tempa1->dead || i==updates%NUM_ANIMALS) {
tmpa1=&a[tmpa->buddy];
if (tmpa1->dead || i==updates%NUM_ANIMALS) {
BuddySel(i);
tempa1=&a[tempa->buddy];
tmpa1=&a[tmpa->buddy];
}
//Move toward buddy
ddx=tempa->x.i32[1]-tempa1->x.i32[1];
ddy=tempa->y.i32[1]-tempa1->y.i32[1];
ddx=tmpa->x.i32[1]-tmpa1->x.i32[1];
ddy=tmpa->y.i32[1]-tmpa1->y.i32[1];
if (dd=SqrI64(ddx)+SqrI64(ddy)) {
d=Sqrt(dd);
s=d`1.25-80;
@@ -380,42 +375,42 @@ U0 AnimateTask(CTask *parent)
dx=ddx/d;
dy=ddy/d;
f=-0.001*s*MAX_U32;
tempa->dx+=f*dx;
tempa->dy+=f*dy;
tmpa->dx+=f*dx;
tmpa->dy+=f*dy;
}
//Make velocity similar to buddy
tempa->dx+=0.1*(tempa1->dx-tempa->dx);
tempa->dy+=0.1*(tempa1->dy-tempa->dy);
tmpa->dx+=0.1*(tmpa1->dx-tmpa->dx);
tmpa->dy+=0.1*(tmpa1->dy-tmpa->dy);
//Add random movement, limit speed and dampen speed
tempa->dx=0.995*ClampI64(tempa->dx+RandI32/32,-max_speed,max_speed);
tempa->dy=0.995*ClampI64(tempa->dy+RandI32/32,-max_speed,max_speed);
tmpa->dx=0.995*ClampI64(tmpa->dx+RandI32/32,-max_speed,max_speed);
tmpa->dy=0.995*ClampI64(tmpa->dy+RandI32/32,-max_speed,max_speed);
//Slow in river
if (GrPeek(map_dc,tempa->x.i32[1],tempa->y.i32[1])!=LTGREEN) {
tempa->dx/=2;
tempa->dy/=2;
if (GrPeek(map_dc,tmpa->x.i32[1],tmpa->y.i32[1])!=LTGREEN) {
tmpa->dx/=2;
tmpa->dy/=2;
}
if (CheckMap((tempa->x+tempa->dx)>>32,(tempa->y+tempa->dy)>>32)) {
tempa->x+=tempa->dx;
tempa->y+=tempa->dy;
if (CheckMap((tmpa->x+tmpa->dx)>>32,(tmpa->y+tmpa->dy)>>32)) {
tmpa->x+=tmpa->dx;
tmpa->y+=tmpa->dy;
}
//Keep on map
if (!(MAP_BORDER+ANIMAL_WIDTH/2
<=tempa->x.i32[1]<MAP_WIDTH-MAP_BORDER-ANIMAL_WIDTH/2)) {
tempa->x -=tempa->dx;
tempa->dx=-tempa->dx;
<=tmpa->x.i32[1]<MAP_WIDTH-MAP_BORDER-ANIMAL_WIDTH/2)) {
tmpa->x -=tmpa->dx;
tmpa->dx=-tmpa->dx;
}
if (!(MAP_BORDER+ANIMAL_HEIGHT
<=tempa->y.i32[1]<MAP_HEIGHT-MAP_BORDER)) {
tempa->y -=tempa->dy;
tempa->dy=-tempa->dy;
<=tmpa->y.i32[1]<MAP_HEIGHT-MAP_BORDER)) {
tmpa->y -=tmpa->dy;
tmpa->dy=-tmpa->dy;
}
cnt++;
if (tempa->x>>32>=FENCE_WIDTH || tempa->y>>32>=FENCE_HEIGHT)
if (tmpa->x>>32>=FENCE_WIDTH || tmpa->y>>32>=FENCE_HEIGHT)
my_outside_cnt++;
}
}
Binary file not shown.
Binary file not shown.
File renamed without changes.
+7 -7
View File
@@ -1,4 +1,4 @@
//Generate "StadiumBG.GRA.Z" from "StadiumBG.DD.Z"
//Generate "StadiumBG.GR.Z" from "StadiumBG.DD.Z"
U0 StadiumGen()
{
@@ -13,19 +13,19 @@ U0 StadiumGen()
DocClear;
Type("StadiumBG.DD");
"$$CM,0,%d$$",TEXT_ROWS-3;
fp_old_update=gr.fp_final_screen_update; //hide mouse cursor
gr.fp_final_screen_update=NULL;
fp_old_update=gr.fp_final_scrn_update; //hide mouse cursor
gr.fp_final_scrn_update=NULL;
WinMgrSync(2,TRUE);
dc2=DCScreenCapture;
Refresh(2,TRUE);
dc2=DCScrnCapture;
dc=DCExt(dc2,0,FONT_HEIGHT,GR_WIDTH,GR_HEIGHT);
DCDel(dc2);
GRAWrite("StadiumBG",dc,DCSF_COMPRESSED|DCSF_PALETTE_GET);
GRWrite("StadiumBG",dc,DCSF_COMPRESSED|DCSF_PALETTE_GET);
DCDel(dc);
DocCursor(ON);
gr.fp_final_screen_update=fp_old_update;
gr.fp_final_scrn_update=fp_old_update;
DocClear;
}
+2 -2
View File
@@ -54,11 +54,11 @@ U0 TakeTurn(I64 player)
Beep(1000);
while (!ip.lb) {
DrawBoard(player);
WinMgrSync;
Refresh;
}
while (ip.lb) {
DrawBoard(player);
WinMgrSync;
Refresh;
}
x=ip.pos.x-Fs->pix_left;
y=ip.pos.y-Fs->pix_top;
+15 -15
View File
@@ -96,7 +96,7 @@ U0 DrawIt(CTask *task,CDC *dc)
}
}
Unit *FindUnit(I64 x,I64 y,I64 player)
Unit *UnitFind(I64 x,I64 y,I64 player)
{
I64 i,dd,best_dd=MAX_I64;
Unit *res=NULL;
@@ -112,7 +112,7 @@ Unit *FindUnit(I64 x,I64 y,I64 player)
return res;
}
U0 CheckForKills(I64 x1,I64 y1,I64 player)
U0 KillsChk(I64 x1,I64 y1,I64 player)
{
I64 i,j,x2,y2,dd;
Bool found;
@@ -141,7 +141,7 @@ U0 CheckForKills(I64 x1,I64 y1,I64 player)
}
}
Bool MoveUnit(Unit *tempu,I64 x2,I64 y2)
Bool UnitMove(Unit *tmpu,I64 x2,I64 y2)
{
I64 i,r,c,r2,c2,x=start_x,y=start_y;
S2W(&x2,&y2);
@@ -151,8 +151,8 @@ Bool MoveUnit(Unit *tempu,I64 x2,I64 y2)
c=x; r=y;
S2Circle(&c,&r);
if (c==c2 && r==r2) {
end_x=tempu->x=x2;
end_y=tempu->y=y2;
end_x=tmpu->x=x2;
end_y=tmpu->y=y2;
return TRUE;
}
if (r2!=r) {
@@ -284,7 +284,7 @@ U0 CleanUp()
U0 TreeCheckers()
{
I64 msg_code,a1,a2,ch,sc;
Unit *tempu;
Unit *tmpu;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
MenuPush(
@@ -307,7 +307,7 @@ U0 TreeCheckers()
try {
cn_start:
Init;
tempu=NULL;
tmpu=NULL;
show_start=FALSE;
Fs->draw_it=&DrawIt;
while (TRUE) {
@@ -326,21 +326,21 @@ cn_start:
break;
case MSG_IP_L_DOWN:
if (num_alive[0]>1 && num_alive[1]>1) {
tempu=FindUnit(a1,a2,cur_player);
end_x=start_x=tempu->x;
end_y=start_y=tempu->y;
tmpu=UnitFind(a1,a2,cur_player);
end_x=start_x=tmpu->x;
end_y=start_y=tmpu->y;
show_start=TRUE;
}
break;
case MSG_IP_MOVE:
if (tempu)
MoveUnit(tempu,a1,a2);
if (tmpu)
UnitMove(tmpu,a1,a2);
break;
case MSG_IP_L_UP:
MoveUnit(tempu,a1,a2);
CheckForKills(tempu->x,tempu->y,cur_player);
UnitMove(tmpu,a1,a2);
KillsChk(tmpu->x,tmpu->y,cur_player);
show_start=FALSE;
tempu=NULL;
tmpu=NULL;
cur_player=1-cur_player;
break;
}
+120 -120
View File
@@ -150,32 +150,32 @@ F64 Dip
return ASin((y_front-y_back)/CAR_LENGTH);
}
Track *TrackFind(Track *_tempt,I64 x,I64 z)
Track *TrackFind(Track *_tmpt,I64 x,I64 z)
{
Track *res=_tempt,*tempt;
Track *res=_tmpt,*tmpt;
I64 dd,best=SqrI64(res->x-x)+SqrI64(res->z-z);
tempt=_tempt;
tmpt=_tmpt;
while (TRUE) {
tempt=tempt->next;
if (tempt==&track_head)
tempt=tempt->next;
dd=SqrI64(tempt->x-x)+SqrI64(tempt->z-z);
tmpt=tmpt->next;
if (tmpt==&track_head)
tmpt=tmpt->next;
dd=SqrI64(tmpt->x-x)+SqrI64(tmpt->z-z);
if (dd<best) {
best=dd;
res=tempt;
res=tmpt;
} else
break;
}
tempt=_tempt;
tmpt=_tmpt;
while (TRUE) {
tempt=tempt->last;
if (tempt==&track_head)
tempt=tempt->last;
dd=SqrI64(tempt->x-x)+SqrI64(tempt->z-z);
tmpt=tmpt->last;
if (tmpt==&track_head)
tmpt=tmpt->last;
dd=SqrI64(tmpt->x-x)+SqrI64(tmpt->z-z);
if (dd<best) {
best=dd;
res=tempt;
res=tmpt;
} else
break;
}
@@ -185,56 +185,56 @@ Track *TrackFind(Track *_tempt,I64 x,I64 z)
U0 TrackSlice(F64 *_x,F64 *_z,F64 é,F64 d)
{
F64 x=*_x,z=*_z,c=Cos(é),s=Sin(é),dx=d*s,dz=-d*c;
Track *tempt,*last=track_head.last;
Track *tmpt,*last=track_head.last;
if (last==&track_head)
last=NULL;
tempt=CAlloc(sizeof(Track));
tmpt=CAlloc(sizeof(Track));
if (last) {
MemCpy(&tempt->center[0],&last->center[3],sizeof(CD3I32));
MemCpy(&tempt->center[1],&last->center[2],sizeof(CD3I32));
MemCpy(&tmpt->center[0],&last->center[3],sizeof(CD3I32));
MemCpy(&tmpt->center[1],&last->center[2],sizeof(CD3I32));
}
tempt->center[2].x=x+(WIDTH/2)*c+dx;
tempt->center[2].z=z+(WIDTH/2)*s+dz;
tempt->center[2].y=DipY(tempt->center[2].x,tempt->center[2].z);
tempt->center[3].x=x-(WIDTH/2)*c+dx;
tempt->center[3].z=z-(WIDTH/2)*s+dz;
tempt->center[3].y=DipY(tempt->center[3].x,tempt->center[3].z);
tmpt->center[2].x=x+(WIDTH/2)*c+dx;
tmpt->center[2].z=z+(WIDTH/2)*s+dz;
tmpt->center[2].y=DipY(tmpt->center[2].x,tmpt->center[2].z);
tmpt->center[3].x=x-(WIDTH/2)*c+dx;
tmpt->center[3].z=z-(WIDTH/2)*s+dz;
tmpt->center[3].y=DipY(tmpt->center[3].x,tmpt->center[3].z);
if (last) {
MemCpy(&tempt->left[0],&last->left[3],sizeof(CD3I32));
MemCpy(&tempt->left[1],&last->left[2],sizeof(CD3I32));
MemCpy(&tmpt->left[0],&last->left[3],sizeof(CD3I32));
MemCpy(&tmpt->left[1],&last->left[2],sizeof(CD3I32));
}
tempt->left[2].x=x-(WIDTH/2)*c+dx;
tempt->left[2].z=z-(WIDTH/2)*s+dz;
tempt->left[2].y=DipY(tempt->left[2].x,tempt->left[2].z);
tempt->left[3].x=x-(WIDTH/2+SHOULDER)*c+dx;
tempt->left[3].z=z-(WIDTH/2+SHOULDER)*s+dz;
tempt->left[3].y=DipY(tempt->left[3].x,tempt->left[3].z);
tmpt->left[2].x=x-(WIDTH/2)*c+dx;
tmpt->left[2].z=z-(WIDTH/2)*s+dz;
tmpt->left[2].y=DipY(tmpt->left[2].x,tmpt->left[2].z);
tmpt->left[3].x=x-(WIDTH/2+SHOULDER)*c+dx;
tmpt->left[3].z=z-(WIDTH/2+SHOULDER)*s+dz;
tmpt->left[3].y=DipY(tmpt->left[3].x,tmpt->left[3].z);
if (last) {
MemCpy(&tempt->right[0],&last->right[3],sizeof(CD3I32));
MemCpy(&tempt->right[1],&last->right[2],sizeof(CD3I32));
MemCpy(&tmpt->right[0],&last->right[3],sizeof(CD3I32));
MemCpy(&tmpt->right[1],&last->right[2],sizeof(CD3I32));
}
tempt->right[2].x=x+(WIDTH/2+SHOULDER)*c+dx;
tempt->right[2].z=z+(WIDTH/2+SHOULDER)*s+dz;
tempt->right[2].y=DipY(tempt->right[2].x,tempt->right[2].z);
tempt->right[3].x=x+(WIDTH/2)*c+dx;
tempt->right[3].z=z+(WIDTH/2)*s+dz;
tempt->right[3].y=DipY(tempt->right[3].x,tempt->right[3].z);
tmpt->right[2].x=x+(WIDTH/2+SHOULDER)*c+dx;
tmpt->right[2].z=z+(WIDTH/2+SHOULDER)*s+dz;
tmpt->right[2].y=DipY(tmpt->right[2].x,tmpt->right[2].z);
tmpt->right[3].x=x+(WIDTH/2)*c+dx;
tmpt->right[3].z=z+(WIDTH/2)*s+dz;
tmpt->right[3].y=DipY(tmpt->right[3].x,tmpt->right[3].z);
tempt->x=x;
tempt->z=z;
tempt->é=é;
tempt->num=track_head.last->num+1;
tempt->d =track_head.last->d+d;
tmpt->x=x;
tmpt->z=z;
tmpt->é=é;
tmpt->num=track_head.last->num+1;
tmpt->d =track_head.last->d+d;
QueIns(tempt,track_head.last);
QueIns(tmpt,track_head.last);
if (tempt->num&1)
tempt->c=RED;
if (tmpt->num&1)
tmpt->c=RED;
else
tempt->c=WHITE;
tmpt->c=WHITE;
if (x<t_minx) t_minx=x;
if (x>t_maxx) t_maxx=x;
@@ -266,7 +266,7 @@ U0 CoupleEnds()
U0 InitTrack()
{
I64 i,j;
Track *tempt;
Track *tmpt;
F64 x,z,é,d;
MemSet(&track_head,0,sizeof(Track));
@@ -295,13 +295,13 @@ U0 InitTrack()
CoupleEnds;
tempt=track_head.next;
tmpt=track_head.next;
for (i=0;i<mp_cnt;i++) {
j=(i+1)*track_head.last->num/mp_cnt+1;
track_start[i]=tempt;
while (tempt!=&track_head && tempt->num!=j)
tempt=tempt->next;
track_end[i]=tempt;
track_start[i]=tmpt;
while (tmpt!=&track_head && tmpt->num!=j)
tmpt=tmpt->next;
track_end[i]=tmpt;
}
t_minx-=BORDER; t_minz-=BORDER;
@@ -311,13 +311,13 @@ U0 InitTrack()
track_map->color=LTGRAY;
GrRect(track_map,0,0,track_map->width,track_map->height);
tempt=track_head.next;
tmpt=track_head.next;
track_map->color=YELLOW;
track_map->pen_width=3;
while (tempt!=&track_head) {
GrPlot3(track_map,track_map->width-(tempt->x-t_minx)>>MAP_BITS,
(tempt->z-t_minz)>>MAP_BITS,0);
tempt=tempt->next;
while (tmpt!=&track_head) {
GrPlot3(track_map,track_map->width-(tmpt->x-t_minx)>>MAP_BITS,
(tmpt->z-t_minz)>>MAP_BITS,0);
tmpt=tmpt->next;
}
}
@@ -350,9 +350,9 @@ U0 MPUpdateWin(CDC *dc2)
I64 i,x,y,z,
w=task->pix_width,h=task->pix_height,r[16],cx=w>>1;
F64 s,dip_é=Dipé(c[0].p.x,c[0].p.z,c[0].é);
Car *tempc;
Car *tmpc;
CD3I32 poly[4];
Track *tempt,*tempt1;
Track *tmpt,*tmpt1;
CDC *dc=DCAlias(gr.dc2,task);
Mat4x4IdentEqu(r);
@@ -362,19 +362,19 @@ U0 MPUpdateWin(CDC *dc2)
dc->depth_buf=dc2->depth_buf;
//Track
tempt =track_start[Gs->num];
tempt1=track_end [Gs->num];
while (tempt!=tempt1) {
tmpt =track_start[Gs->num];
tmpt1=track_end [Gs->num];
while (tmpt!=tmpt1) {
dc->color=DKGRAY;
if (PrepPoly(&tempt->center,r,cx,h,poly)) {
if (PrepPoly(&tmpt->center,r,cx,h,poly)) {
GrFillPoly3(dc,4,poly);
dc->color=tempt->c;
if (PrepPoly(&tempt->left,r,cx,h,poly))
dc->color=tmpt->c;
if (PrepPoly(&tmpt->left,r,cx,h,poly))
GrFillPoly3(dc,4,poly);
if (PrepPoly(&tempt->right,r,cx,h,poly))
if (PrepPoly(&tmpt->right,r,cx,h,poly))
GrFillPoly3(dc,4,poly);
}
tempt=tempt->next;
tmpt=tmpt->next;
}
dc->flags|=DCF_TRANSFORMATION;
@@ -395,17 +395,17 @@ U0 MPUpdateWin(CDC *dc2)
}
}
for (i=Gs->num+1;i<NUM_CARS;i+=mp_cnt) {
tempc=&c[i];
x=tempc->p.x-c[0].p.x; y=tempc->p.y-c[0].p.y; z=tempc->p.z-c[0].p.z;
tmpc=&c[i];
x=tmpc->p.x-c[0].p.x; y=tmpc->p.y-c[0].p.y; z=tmpc->p.z-c[0].p.z;
Mat4x4MulXYZ(r,&x,&y,&z);
if (z>0) {
s=100.0/(AbsI64(z)+50);
Mat4x4IdentEqu(dc->r);
Mat4x4Scale(dc->r,s*2);
Mat4x4RotX(dc->r,Dipé(tempc->p.x,tempc->p.z,-tempc->é));
Mat4x4RotY(dc->r,tempc->é-c[0].é);
Mat4x4RotX(dc->r,Dipé(tmpc->p.x,tmpc->p.z,-tmpc->é));
Mat4x4RotY(dc->r,tmpc->é-c[0].é);
DCMat4x4Set(dc,dc->r);
Sprite3B(dc,s*x+cx,s*y+h,z+GR_Z_ALL,tempc->img);
Sprite3B(dc,s*x+cx,s*y+h,z+GR_Z_ALL,tmpc->img);
}
}
dc->depth_buf=NULL;
@@ -433,7 +433,7 @@ U0 DrawIt(CTask *task,CDC *dc)
h=task->pix_height,r[16],
cx=w>>1;
F64 s,dip_é=Dipé(c[0].p.x,c[0].p.z,c[0].é);
Car *tempc=&c[0];
Car *tmpc=&c[0];
dc->color=LTCYAN;
GrRect(dc,0,0,w,HORIZON_DIP*Sin(dip_é)+FONT_HEIGHT*4.5);
@@ -462,7 +462,7 @@ U0 DrawIt(CTask *task,CDC *dc)
Yield;
Mat4x4IdentEqu(r);
Mat4x4RotY(r,tempc->dé);
Mat4x4RotY(r,tmpc->dé);
Mat4x4RotX(r,0.4-8*dip_é); //Made this up
dc->transform=&VRTransform;
dc->x=task->pix_width>>1;
@@ -503,40 +503,40 @@ U0 DrawIt(CTask *task,CDC *dc)
U0 AnimateTask(I64)
{
Car *tempc;
Car *tmpc;
I64 i,x,z;
Bool on_track;
Track *tempt,*tempt2;
Track *tmpt,*tmpt2;
while (TRUE) {
if (!game_over)
Snd(0.01*c[0].speed*3+10);
else
Snd(0);
for (i=0;i<NUM_CARS;i++) {
tempc=&c[i];
tempc->p.x-=0.01*tempc->speed*Cos(tempc->é-ã/2);
tempc->p.z+=0.01*tempc->speed*Sin(tempc->é-ã/2);
tempt=TrackFind(tempc->t,tempc->p.x,tempc->p.z);
tmpc=&c[i];
tmpc->p.x-=0.01*tmpc->speed*Cos(tmpc->é-ã/2);
tmpc->p.z+=0.01*tmpc->speed*Sin(tmpc->é-ã/2);
tmpt=TrackFind(tmpc->t,tmpc->p.x,tmpc->p.z);
if (i) {
if (tempt!=tempc->t) {
tempt2=tempt->next;
if (tempt2==&track_head)
tempt2=tempt2->next;
tempc->é=Arg(-tempt2->z+tempc->p.z,-tempt2->x+tempc->p.x);
if (tmpt!=tmpc->t) {
tmpt2=tmpt->next;
if (tmpt2==&track_head)
tmpt2=tmpt2->next;
tmpc->é=Arg(-tmpt2->z+tmpc->p.z,-tmpt2->x+tmpc->p.x);
}
} else {
tempc->é+=0.01*tempc->dé;
x=track_map->width-(tempc->p.x-t_minx)>>MAP_BITS;
z=(tempc->p.z-t_minz)>>MAP_BITS;
tmpc->é+=0.01*tmpc->dé;
x=track_map->width-(tmpc->p.x-t_minx)>>MAP_BITS;
z=(tmpc->p.z-t_minz)>>MAP_BITS;
if (GrPeek(track_map,x,z)!=YELLOW) {
on_track=FALSE;
tempc->speed-=0.01*tempc->speed;
if (tempc->speed<0) tempc->speed=0;
tmpc->speed-=0.01*tmpc->speed;
if (tmpc->speed<0) tmpc->speed=0;
} else
on_track=TRUE;
}
tempc->t=tempt;
tempc->p.y=DipY(tempc->p.x,tempc->p.z);
tmpc->t=tmpt;
tmpc->p.y=DipY(tmpc->p.x,tmpc->p.z);
}
if (!game_over && on_track) {
for (i=1;i<NUM_CARS;i++)
@@ -568,58 +568,58 @@ U8 *imgs[8]={$IB,"<1>",BI=1$,$IB,"<1>",BI=1$,$IB,"<2>",BI=2$,$IB,"<2>",BI=2$,$IB
U0 InitBushes()
{
Bush *tempb;
Bush *tmpb;
I64 i,j,x,z;
track_map->color=LTGREEN;
track_map->pen_width=1;
for (i=0;i<NUM_BUSHES;i++) {
tempb=&b[i];
tmpb=&b[i];
ib_restart:
tempb->p.x=Rand*(t_maxx-t_minx)+t_minx;
tempb->p.z=Rand*(t_maxz-t_minz)+t_minz;
x=track_map->width-(tempb->p.x-t_minx)>>MAP_BITS;
z=(tempb->p.z-t_minz)>>MAP_BITS;
tmpb->p.x=Rand*(t_maxx-t_minx)+t_minx;
tmpb->p.z=Rand*(t_maxz-t_minz)+t_minz;
x=track_map->width-(tmpb->p.x-t_minx)>>MAP_BITS;
z=(tmpb->p.z-t_minz)>>MAP_BITS;
for (j=0;j<8;j++)
if (GrPeek(track_map,x+gr_x_offsets[j],z+gr_y_offsets[j])!=LTGRAY)
goto ib_restart;
GrPlot(track_map,x,z);
tempb->p.y=DipY(tempb->p.x,tempb->p.z);
tempb->sym=RandU16&1;
tempb->img=imgs[i&7];
tmpb->p.y=DipY(tmpb->p.x,tmpb->p.z);
tmpb->sym=RandU16&1;
tmpb->img=imgs[i&7];
}
}
U0 Init()
{
Car *tempc;
Track *tempt;
Car *tmpc;
Track *tmpt;
F64 d;
I64 i;
InitTrack;
InitBushes;
tempt=track_head.next;
tmpt=track_head.next;
for (i=0;i<NUM_CARS;i++) {
tempc=&c[i];
tempc->t=tempt;
tempc->p.x=tempt->x;
tempc->p.z=tempt->z;
tempc->p.y=DipY(tempc->p.x,tempc->p.z);
tempc->é =-tempt->é;
tempc->dé=0;
tmpc=&c[i];
tmpc->t=tmpt;
tmpc->p.x=tmpt->x;
tmpc->p.z=tmpt->z;
tmpc->p.y=DipY(tmpc->p.x,tmpc->p.z);
tmpc->é =-tmpt->é;
tmpc->dé=0;
if (!i) {
tempc->img=$IB,"<5>",BI=5$;
tempc->speed=0;
tmpc->img=$IB,"<5>",BI=5$;
tmpc->speed=0;
} else {
tempc->img=$IB,"<6>",BI=6$;
tempc->speed=2500.0;
tmpc->img=$IB,"<6>",BI=6$;
tmpc->speed=2500.0;
}
d=(i+1)*track_head.last->d/NUM_CARS;
while (tempt->next!=&track_head && tempt->d<d)
tempt=tempt->next;
while (tmpt->next!=&track_head && tmpt->d<d)
tmpt=tmpt->next;
}
distance=0;
tf=0;
+99 -99
View File
@@ -121,9 +121,9 @@ class Step
U0 DrawIt(CTask *task,CDC *dc)
{
I64 r[16],i,w=task->pix_width,h=task->pix_height,x,y;
U8 *img,*temps;
Step *tempst;
Peasant *tempp;
U8 *img,*tmps;
Step *tmpst;
Peasant *tmpp;
F64 tt;
dc->pen_width=1;
@@ -157,35 +157,35 @@ U0 DrawIt(CTask *task,CDC *dc)
}
}
tempst=step_head.next;
while (tempst!=&step_head) {
if (tS-tempst->t0<2.0)
tmpst=step_head.next;
while (tmpst!=&step_head) {
if (tS-tmpst->t0<2.0)
dc->color=DKGRAY;
else
dc->color=LTGRAY;
dc->pen_width=4;
GrPlot3(dc,tempst->x,tempst->y,0);
tempst=tempst->next;
GrPlot3(dc,tmpst->x,tmpst->y,0);
tmpst=tmpst->next;
}
DCDepthBufAlloc(dc);
dc->flags|=DCF_TRANSFORMATION;
dc->pen_width=1;
tempp=peasant_head.next;
while (tempp!=&peasant_head) {
tmpp=peasant_head.next;
while (tmpp!=&peasant_head) {
Mat4x4IdentEqu(r);
Mat4x4RotY(r,tempp->é+ã/2);
Mat4x4RotY(r,tmpp->é+ã/2);
Mat4x4RotX(r,ã/6);
if (tempp->stopped)
SpriteMat3B(dc,tempp->x,tempp->y,GR_Z_ALL,peasant_imgs[0],r);
if (tmpp->stopped)
SpriteMat3B(dc,tmpp->x,tmpp->y,GR_Z_ALL,peasant_imgs[0],r);
else {
temps=SpriteInterpolate(Saw(animate_mS/250.0,1.0),
tmps=SpriteInterpolate(Saw(animate_mS/250.0,1.0),
peasant_imgs[ animate_phase &3],
peasant_imgs[(animate_phase+1)&3]);
SpriteMat3B(dc,tempp->x,tempp->y,GR_Z_ALL,temps,r);
Free(temps);
SpriteMat3B(dc,tmpp->x,tmpp->y,GR_Z_ALL,tmps,r);
Free(tmps);
}
tempp=tempp->next;
tmpp=tmpp->next;
}
dc->pen_width=1;
@@ -195,11 +195,11 @@ U0 DrawIt(CTask *task,CDC *dc)
if (tS>king_timeout)
SpriteMat3B(dc,king_x,king_y,GR_Z_ALL,king_imgs[0],r);
else {
temps=SpriteInterpolate(Saw(king_mS/250.0,1.0),
tmps=SpriteInterpolate(Saw(king_mS/250.0,1.0),
king_imgs[ king_phase &3],
king_imgs[(king_phase+1)&3]);
SpriteMat3B(dc,king_x,king_y,GR_Z_ALL,temps,r);
Free(temps);
SpriteMat3B(dc,king_x,king_y,GR_Z_ALL,tmps,r);
Free(tmps);
}
dc->pen_width=1;
@@ -223,38 +223,38 @@ U0 DrawIt(CTask *task,CDC *dc)
U0 StepNew(CTask *task,I64 x,I64 y,F64 é,Bool left_right,Bool king)
{
Step *temps;
Step *tmps;
if (king) {
temps=MAlloc(sizeof(Step),task);
temps->x=x;
temps->y=y;
temps->t0=tS;
QueIns(temps,king_step_head.last);
tmps=MAlloc(sizeof(Step),task);
tmps->x=x;
tmps->y=y;
tmps->t0=tS;
QueIns(tmps,king_step_head.last);
}
if (left_right) {
temps=MAlloc(sizeof(Step),task);
temps->x=x-3.5*Sin(é)+2.0*Cos(é);
temps->y=y+3.5*Cos(é)+2.0*Sin(é);
temps->t0=tS;
QueIns(temps,step_head.last);
temps=MAlloc(sizeof(Step),task);
temps->x=x-3.5*Sin(é)+5.0*Cos(é);
temps->y=y+3.5*Cos(é)+5.0*Sin(é);
temps->t0=tS;
QueIns(temps,step_head.last);
tmps=MAlloc(sizeof(Step),task);
tmps->x=x-3.5*Sin(é)+2.0*Cos(é);
tmps->y=y+3.5*Cos(é)+2.0*Sin(é);
tmps->t0=tS;
QueIns(tmps,step_head.last);
tmps=MAlloc(sizeof(Step),task);
tmps->x=x-3.5*Sin(é)+5.0*Cos(é);
tmps->y=y+3.5*Cos(é)+5.0*Sin(é);
tmps->t0=tS;
QueIns(tmps,step_head.last);
} else {
temps=MAlloc(sizeof(Step),task);
temps->x=x+3.5*Sin(é)+0.0*Cos(é);
temps->y=y-3.5*Cos(é)+0.0*Sin(é);
temps->t0=tS;
QueIns(temps,step_head.last);
temps=MAlloc(sizeof(Step),task);
temps->x=x+3.5*Sin(é)+3.0*Cos(é);
temps->y=y-3.5*Cos(é)+3.0*Sin(é);
temps->t0=tS;
QueIns(temps,step_head.last);
tmps=MAlloc(sizeof(Step),task);
tmps->x=x+3.5*Sin(é)+0.0*Cos(é);
tmps->y=y-3.5*Cos(é)+0.0*Sin(é);
tmps->t0=tS;
QueIns(tmps,step_head.last);
tmps=MAlloc(sizeof(Step),task);
tmps->x=x+3.5*Sin(é)+3.0*Cos(é);
tmps->y=y-3.5*Cos(é)+3.0*Sin(é);
tmps->t0=tS;
QueIns(tmps,step_head.last);
}
}
@@ -262,7 +262,7 @@ U0 Init()
{
I64 i,min_x,max_x,min_y,max_y,
w=Fs->pix_width,h=Fs->pix_height;
Peasant *tempp;
Peasant *tmpp;
snow_x=snow_y=0;
new_snow_mS=0;
@@ -281,13 +281,13 @@ U0 Init()
SpriteExtents($IB,"<12>",BI=12$,&min_x,&max_x,&min_y,&max_y);
QueInit(&peasant_head);
for (i=0;i<NUM_PEASANTS;i++) {
tempp=MAlloc(sizeof(Peasant));
tempp->x=RandU16%(w-2*BORDER-(max_x-min_x+1))+BORDER-min_x;
tempp->y=RandU16%(h-2*BORDER-(max_y-min_y+1))+BORDER-min_y;
tempp->é=ã*2*Rand;
tempp->door_opened_t0=0;
tempp->stopped=FALSE;
QueIns(tempp,peasant_head.last);
tmpp=MAlloc(sizeof(Peasant));
tmpp->x=RandU16%(w-2*BORDER-(max_x-min_x+1))+BORDER-min_x;
tmpp->y=RandU16%(h-2*BORDER-(max_y-min_y+1))+BORDER-min_y;
tmpp->é=ã*2*Rand;
tmpp->door_opened_t0=0;
tmpp->stopped=FALSE;
QueIns(tmpp,peasant_head.last);
}
animate_phase=0;
animate_mS=0;
@@ -310,88 +310,88 @@ U0 CleanUp()
QueDel(&king_step_head,TRUE);
}
U0 Follow(CTask *,Peasant *tempp)
U0 Follow(CTask *,Peasant *tmpp)
{
Step *temps=king_step_head.next;
Step *tmps=king_step_head.next;
F64 d,best_d=MAX_F64;
while (temps!=&king_step_head) {
if ((d=Sqr(temps->x-tempp->x)+Sqr(temps->y-tempp->y)) &&
while (tmps!=&king_step_head) {
if ((d=Sqr(tmps->x-tmpp->x)+Sqr(tmps->y-tmpp->y)) &&
d<15*15) {
d+=1000*Sqr(tS-temps->t0);
d+=1000*Sqr(tS-tmps->t0);
if (d<best_d) {
best_d=d;
tempp->é=Arg(temps->x-tempp->x,temps->y-tempp->y);
tmpp->é=Arg(tmps->x-tmpp->x,tmps->y-tmpp->y);
}
}
temps=temps->next;
tmps=tmps->next;
}
}
U0 AnimateTask(I64)
{
Step *temps,*temps1;
Peasant *tempp;
Step *tmps,*tmps1;
Peasant *tmpp;
I64 i,w,h;
while (TRUE) {
w=Fs->parent_task->pix_width;
h=Fs->parent_task->pix_height;
temps=step_head.next;
while (temps!=&step_head) {
temps1=temps->next;
if (tS-temps->t0>5.0) {
QueRem(temps);
Free(temps);
tmps=step_head.next;
while (tmps!=&step_head) {
tmps1=tmps->next;
if (tS-tmps->t0>5.0) {
QueRem(tmps);
Free(tmps);
}
temps=temps1;
tmps=tmps1;
}
temps=king_step_head.next;
while (temps!=&king_step_head) {
temps1=temps->next;
if (tS-temps->t0>3.0) {
QueRem(temps);
Free(temps);
tmps=king_step_head.next;
while (tmps!=&king_step_head) {
tmps1=tmps->next;
if (tS-tmps->t0>3.0) {
QueRem(tmps);
Free(tmps);
}
temps=temps1;
tmps=tmps1;
}
not_stopped_cnt=0;
tempp=peasant_head.next;
while (tempp!=&peasant_head) {
if (tempp->stopped) {
if (tempp->door_opened_t0 && tS>tempp->door_opened_t0+1.0) {
tempp->door_opened_t0=0;
tempp->y=tempp->x=-9999;
tmpp=peasant_head.next;
while (tmpp!=&peasant_head) {
if (tmpp->stopped) {
if (tmpp->door_opened_t0 && tS>tmpp->door_opened_t0+1.0) {
tmpp->door_opened_t0=0;
tmpp->y=tmpp->x=-9999;
}
} else {
if (Sqr(tempp->x-w/2)+Sqr(tempp->y-h/2)<20*20) {
tempp->stopped=TRUE;
tempp->door_opened_t0=door_open_t0=tS;
if (Sqr(tmpp->x-w/2)+Sqr(tmpp->y-h/2)<20*20) {
tmpp->stopped=TRUE;
tmpp->door_opened_t0=door_open_t0=tS;
}
for (i=0;i<NUM_TREES;i++) //Hang-out by fire
if (trees[i].fire_frame_idx &&
Sqr(tempp->x-trees[i].x)+Sqr(tempp->y-trees[i].y)<20*20) {
tempp->stopped=TRUE;
Sqr(tmpp->x-trees[i].x)+Sqr(tmpp->y-trees[i].y)<20*20) {
tmpp->stopped=TRUE;
break;
}
if (!tempp->stopped) {
Follow(Fs->parent_task,tempp);
tempp->x+=Cos(tempp->é)/100;
tempp->y+=Sin(tempp->é)/100;
if (!(BORDER/2<=tempp->x<w-BORDER/2) ||
!(BORDER/2<=tempp->y<h-BORDER/2)) {
tempp->é+=ã;
tempp->x+=3*Cos(tempp->é)/100;
tempp->y+=3*Sin(tempp->é)/100;
if (!tmpp->stopped) {
Follow(Fs->parent_task,tmpp);
tmpp->x+=Cos(tmpp->é)/100;
tmpp->y+=Sin(tmpp->é)/100;
if (!(BORDER/2<=tmpp->x<w-BORDER/2) ||
!(BORDER/2<=tmpp->y<h-BORDER/2)) {
tmpp->é+=ã;
tmpp->x+=3*Cos(tmpp->é)/100;
tmpp->y+=3*Sin(tmpp->é)/100;
}
if (!animate_mS && animate_phase&1)
StepNew(Fs->parent_task,tempp->x,tempp->y,tempp->é,
StepNew(Fs->parent_task,tmpp->x,tmpp->y,tmpp->é,
animate_phase&2,FALSE);
not_stopped_cnt++;
}
}
tempp=tempp->next;
tmpp=tmpp->next;
}
if (!not_stopped_cnt && !tf) {
tf=tS;
Binary file not shown.
Binary file not shown.