TempleOSCD_150720.ISO
This commit is contained in:
1 parent
401601816c
commit
f8c05f98f4
554 files changed
+26046
-24853
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,7 +1,7 @@
|
||||
//Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
|
||||
AcctRegSetDftEntry("TempleOS/CastleFrankenstein","F64 best_score=9999;\n");
|
||||
AcctRegExeBranch("TempleOS/CastleFrankenstein");
|
||||
RegSetDftEntry("TempleOS/CastleFrankenstein","F64 best_score=9999;\n");
|
||||
RegExeBranch("TempleOS/CastleFrankenstein");
|
||||
|
||||
//Set snap to 4 and width to 4
|
||||
//if you edit this map.
|
||||
@@ -109,7 +109,7 @@ class Monster
|
||||
U0 CFTransform(CDC *dc,I64 *x,I64 *y,I64 *z)
|
||||
{
|
||||
I64 zz;
|
||||
GrRot(dc->r,x,y,z);
|
||||
Mat4x4MulXYZ(dc->r,x,y,z);
|
||||
zz=SCREEN_SCALE/3+*z;
|
||||
if (zz<1) zz=1;
|
||||
*x=SCREEN_SCALE/2* *x/zz;
|
||||
@@ -132,37 +132,38 @@ 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);
|
||||
x2*LOS_SCALE/SCREEN_SCALE,y2*LOS_SCALE/SCREEN_SCALE,0,&LOSPlot);
|
||||
}
|
||||
|
||||
U0 DrawIt(CTask *task,CDC *dc)
|
||||
{
|
||||
I64 i,j,*r1,*r2,*r3,*s2w,xx,yy,zz,x,y,x1,y1,z1,
|
||||
c,x1w,y1w,x1h,y1h,xh,yh,zh,
|
||||
cx=task->pix_width/2,
|
||||
cy=task->pix_height/2;
|
||||
c,x1w,y1w,x1h,y1h,xh,yh,zh,
|
||||
cx=task->pix_width/2,
|
||||
cy=task->pix_height/2;
|
||||
CSprite *temps;
|
||||
F64 tt;
|
||||
CD3I32 poly[4];
|
||||
Monster *tempm;
|
||||
|
||||
DCAllocDepthBuf(dc);
|
||||
DCDepthBufAlloc(dc);
|
||||
MemSet(panels_processed_bitmap,0,(map_width*map_height+7)>>3);
|
||||
|
||||
//World to screen
|
||||
GrRotZEqu(dc->r,man_é+ã/2);
|
||||
GrRotXEqu(dc->r,ã/2);
|
||||
GrSetRotMat(dc,dc->r);
|
||||
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;
|
||||
GrRot(dc->r,&xh,&yh,&zh);
|
||||
GrSetTranslation(dc->r,xh,yh,zh);
|
||||
Mat4x4MulXYZ(dc->r,&xh,&yh,&zh);
|
||||
Mat4x4TranslationEqu(dc->r,xh,yh,zh);
|
||||
|
||||
//Screen to world
|
||||
s2w=GrRotXNew(-ã/2,task);
|
||||
GrRotZEqu(s2w,-man_é-ã/2);
|
||||
s2w=Mat4x4IdentNew(task);
|
||||
Mat4x4RotX(s2w,-ã/2);
|
||||
Mat4x4RotZ(s2w,-man_é-ã/2);
|
||||
xh=0; yh=0; zh=SCREEN_SCALE;
|
||||
GrRot(s2w,&xh,&yh,&zh);
|
||||
Mat4x4MulXYZ(s2w,&xh,&yh,&zh);
|
||||
|
||||
//Rotate light source
|
||||
xx=dc->ls.x; yy=dc->ls.y; zz=-dc->ls.z;
|
||||
@@ -173,15 +174,17 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
dc->transform=&CFTransform;
|
||||
dc->x=cx;
|
||||
dc->y=cy;
|
||||
r1=GrRotXNew(-ã/2,task);
|
||||
GrRotZEqu(r1,tS);
|
||||
GrScaleEqu(r1,MONSTER_SCALE);
|
||||
r1=Mat4x4IdentNew(task);
|
||||
Mat4x4RotX(r1,-ã/2);
|
||||
Mat4x4RotZ(r1,tS);
|
||||
Mat4x4Scale(r1,MONSTER_SCALE);
|
||||
|
||||
r2=GrIdentNew(task);
|
||||
GrScaleEqu(r2,MONSTER_SCALE);
|
||||
r2=Mat4x4IdentNew(task);
|
||||
Mat4x4Scale(r2,MONSTER_SCALE);
|
||||
|
||||
r3=GrRotXNew(-ã/2,task);
|
||||
GrScaleEqu(r3,PLANT_SCALE);
|
||||
r3=Mat4x4IdentNew(task);
|
||||
Mat4x4RotX(r3,-ã/2);
|
||||
Mat4x4Scale(r3,PLANT_SCALE);
|
||||
|
||||
x1h=man_xx+yh*PLOT_GRID_WIDTH/2+xh*(PLOT_GRID_HEIGHT-1);
|
||||
y1h=man_yy-xh*PLOT_GRID_WIDTH/2+yh*(PLOT_GRID_HEIGHT-1);
|
||||
@@ -193,10 +196,10 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
xx=x1w/SCREEN_SCALE; yy=y1w/SCREEN_SCALE;
|
||||
x=xx*SCREEN_SCALE-man_xx; y=yy*SCREEN_SCALE-man_yy;
|
||||
if (1<=xx<map_width-1 && 1<=yy<map_height-1 &&
|
||||
!LBts(panels_processed_bitmap,yy*map_width+xx)) {
|
||||
!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,
|
||||
man_xx,man_yy)) {
|
||||
LOS(xx*SCREEN_SCALE+SCREEN_SCALE/2,yy*SCREEN_SCALE+SCREEN_SCALE/2,
|
||||
man_xx,man_yy)) {
|
||||
if (c==YELLOW)
|
||||
dc->color=DKGRAY;
|
||||
else
|
||||
@@ -218,14 +221,14 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
x1=x+SCREEN_SCALE/2;
|
||||
y1=y+SCREEN_SCALE/2;
|
||||
z1=0;
|
||||
GrTransform(dc,&x1,&y1,&z1);
|
||||
DCTransform(dc,&x1,&y1,&z1);
|
||||
if (z1>0)
|
||||
SpriteMat3B(dc,x+SCREEN_SCALE/2,y+SCREEN_SCALE/2,0,$IB,"<5>",BI=5$,r3);
|
||||
} else if (c==YELLOW) {
|
||||
x1=x+SCREEN_SCALE/2;
|
||||
y1=y+SCREEN_SCALE/2;
|
||||
z1=0;
|
||||
GrTransform(dc,&x1,&y1,&z1);
|
||||
DCTransform(dc,&x1,&y1,&z1);
|
||||
if (z1>0)
|
||||
SpriteMat3B(dc,x+SCREEN_SCALE/2,y+SCREEN_SCALE/2,0,$IB,"<6>",BI=6$,r3);
|
||||
}
|
||||
@@ -313,7 +316,7 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
xx=x;
|
||||
yy=y;
|
||||
zz=0;
|
||||
GrTransform(dc,&xx,&yy,&zz);
|
||||
DCTransform(dc,&xx,&yy,&zz);
|
||||
if (zz>0) {
|
||||
if (tempm->dead)
|
||||
SpriteMat3B(dc,x,y,0,$IB,"<2>",BI=2$,r2);
|
||||
@@ -332,11 +335,11 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
|
||||
//Draw Map heads-up display, scaled 2 pixs
|
||||
Free(dc->r);
|
||||
GrSetRotMat(dc,GrIdentNew(task));
|
||||
DCMat4x4Set(dc,Mat4x4IdentNew(task));
|
||||
dc->x=task->pix_width -2*map_width;
|
||||
dc->y=task->pix_height-2*map_height;
|
||||
dc->z=0;
|
||||
dc->transform=&GrTransform;
|
||||
dc->transform=&DCTransform;
|
||||
dc->pen_width=2;
|
||||
for (i=0;i<map_height;i++)
|
||||
for (j=0;j<map_width;j++) {
|
||||
@@ -345,10 +348,11 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
}
|
||||
|
||||
//Draw Things on heads-up Map
|
||||
dc->color=LTPURPLE;
|
||||
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);
|
||||
GrPlot3(dc,2*(tempm->x/SCREEN_SCALE),
|
||||
2*(map_height-1-tempm->y/SCREEN_SCALE),0);
|
||||
dc->color=LTCYAN;
|
||||
GrPlot3(dc,2*(man_xx/SCREEN_SCALE),2*(map_height-1-man_yy/SCREEN_SCALE),0);
|
||||
|
||||
@@ -363,7 +367,8 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
GrLine(dc,cx,cy-5,cx,cy+5);
|
||||
tt=tS;
|
||||
}
|
||||
GrPrint(dc,0,0,"Enemy:%d Time:%3.2f Best:%3.2f",monsters_left,tt-t0,best_score);
|
||||
GrPrint(dc,0,0,"Enemy:%d Time:%3.2f Best:%3.2f",
|
||||
monsters_left,tt-t0,best_score);
|
||||
Free(s2w);
|
||||
}
|
||||
|
||||
@@ -378,7 +383,7 @@ U0 Fire()
|
||||
x=tempm->x;
|
||||
y=tempm->y;
|
||||
if (!tempm->dead &&
|
||||
LOS(x,y,man_xx,man_yy)) {
|
||||
LOS(x,y,man_xx,man_yy)) {
|
||||
dx=x-man_xx;
|
||||
dy=man_yy-y;
|
||||
if (d=Sqrt(dx*dx+dy*dy)) {
|
||||
@@ -449,17 +454,17 @@ U0 AnimateTask(I64)
|
||||
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]) {
|
||||
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 ||
|
||||
!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 ||
|
||||
!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;
|
||||
@@ -482,9 +487,9 @@ U0 SongTask(I64)
|
||||
Fs->task_end_cb=&SndTaskEndCB;
|
||||
MusicSettingsRst;
|
||||
while (TRUE) {
|
||||
Play("2q.A#1eG2AeA#qAq.A#1eG2eAeA#qA");
|
||||
Play("q.A#1eG2A#A1qG2q.A#1eG2A#A1qG");
|
||||
Play("3eA#A2qG3eA#A2qG3eA#A2G3AA#A2qG");
|
||||
Play("2q.A#1eG2AeA#qAq.A#1eG2eAeA#qA");
|
||||
Play("q.A#1eG2A#A1qG2q.A#1eG2A#A1qG");
|
||||
Play("3eA#A2qG3eA#A2qG3eA#A2G3AA#A2qG");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -520,23 +525,23 @@ U0 CastleFrankenstein()
|
||||
{
|
||||
I64 sc;
|
||||
MenuPush(
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Restart(,'\n');"
|
||||
" Fwd(,,SC_CURSOR_UP);"
|
||||
" Bwd(,,SC_CURSOR_DOWN);"
|
||||
" Left(,,SC_CURSOR_LEFT);"
|
||||
" Right(,,SC_CURSOR_RIGHT);"
|
||||
" Fire(,CH_SPACE);"
|
||||
"}"
|
||||
);
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Restart(,'\n');"
|
||||
" Fwd(,,SC_CURSOR_UP);"
|
||||
" Bwd(,,SC_CURSOR_DOWN);"
|
||||
" Left(,,SC_CURSOR_LEFT);"
|
||||
" Right(,,SC_CURSOR_RIGHT);"
|
||||
" Fire(,CH_SPACE);"
|
||||
"}"
|
||||
);
|
||||
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
Fs->text_attr=DKGRAY<<4+WHITE;
|
||||
Preempt(OFF);
|
||||
Preempt;
|
||||
WinBorder;
|
||||
WinMax;
|
||||
AutoComplete;
|
||||
@@ -583,7 +588,8 @@ fs_done:
|
||||
SettingsPop;
|
||||
CleanUp;
|
||||
MenuPop;
|
||||
AcctRegWriteBranch("TempleOS/CastleFrankenstein","F64 best_score=%5.4f;\n",best_score);
|
||||
RegWriteBranch("TempleOS/CastleFrankenstein","F64 best_score=%5.4f;\n",
|
||||
best_score);
|
||||
}
|
||||
|
||||
CastleFrankenstein;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
//Giotto, a famous artist, drew a freehand circle as a portfolio for a job.
|
||||
|
||||
AcctRegSetDftEntry("TempleOS/CircleTrace","F64 best_score=999;\n");
|
||||
AcctRegExeBranch("TempleOS/CircleTrace");
|
||||
RegSetDftEntry("TempleOS/CircleTrace","F64 best_score=999;\n");
|
||||
RegExeBranch("TempleOS/CircleTrace");
|
||||
|
||||
I64 cx,cy;
|
||||
F64 avg_error=0,elapsed_time=0,total_error=0,score=999;
|
||||
@@ -18,7 +18,8 @@ U0 SongTask(I64)
|
||||
|
||||
U0 DrawIt(CTask *task,CDC *dc)
|
||||
{
|
||||
GrPrint(dc,0,0,"Error:%6.3f Time:%6.3f Score:%6.3f Best:%8.3f",avg_error,elapsed_time,score,best_score);
|
||||
GrPrint(dc,0,0,"Error:%6.3f Time:%6.3f Score:%6.3f Best:%8.3f",
|
||||
avg_error,elapsed_time,score,best_score);
|
||||
}
|
||||
|
||||
#define CIRCLE_RADIUS 100
|
||||
@@ -55,7 +56,7 @@ U0 CircleTrace()
|
||||
GrCircle(dc,cx,cy,CIRCLE_RADIUS);
|
||||
do {
|
||||
msg_code=GetMsg(&a1,&a2,
|
||||
1<<MSG_KEY_DOWN+1<<MSG_IP_L_DOWN);
|
||||
1<<MSG_KEY_DOWN+1<<MSG_IP_L_DOWN);
|
||||
switch (msg_code) {
|
||||
case MSG_KEY_UP:
|
||||
break;
|
||||
@@ -70,7 +71,7 @@ U0 CircleTrace()
|
||||
x1=a1; y1=a2;
|
||||
do {
|
||||
msg_code=ScanMsg(&a1,&a2,
|
||||
1<<MSG_IP_L_UP+1<<MSG_IP_MOVE);
|
||||
1<<MSG_IP_L_UP+1<<MSG_IP_MOVE);
|
||||
switch (msg_code) {
|
||||
case MSG_IP_L_UP:
|
||||
break;
|
||||
@@ -79,7 +80,7 @@ U0 CircleTrace()
|
||||
total_distance+=Sqrt(Sqr(x1-a1)+Sqr(y1-a2));
|
||||
Line(dc,x1,y1,0,a1,a2,0,&CTPlot);
|
||||
x1=a1;y1=a2;
|
||||
//undo overlapping pixs on segments
|
||||
//undo overlapping pixs on segments
|
||||
GrPlot(dc,x1,y1);
|
||||
rad=Sqrt(Sqr(x1-cx)+Sqr(y1-cy));
|
||||
total_error-=Abs(rad-CIRCLE_RADIUS);
|
||||
@@ -109,7 +110,7 @@ U0 CircleTrace()
|
||||
Snd(500);Sleep(50);
|
||||
}
|
||||
} else {
|
||||
Snd(100);Sleep(1000);
|
||||
Snd(100);Sleep(1000);
|
||||
}
|
||||
Snd(0); Sleep(200); music.mute=FALSE;
|
||||
break;
|
||||
@@ -119,7 +120,7 @@ U0 CircleTrace()
|
||||
SettingsPop;
|
||||
DCFill;
|
||||
DCDel(dc);
|
||||
AcctRegWriteBranch("TempleOS/CircleTrace","F64 best_score=%5.4f;\n",best_score);
|
||||
RegWriteBranch("TempleOS/CircleTrace","F64 best_score=%5.4f;\n",best_score);
|
||||
}
|
||||
|
||||
CircleTrace; //Execute when #included
|
||||
Binary file not shown.
Binary file not shown.
@@ -28,12 +28,12 @@ U0 Digits()
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
Fs->text_attr=DKGRAY<<4+WHITE;
|
||||
DocClear;
|
||||
//Set default background and foreground
|
||||
//Set default background and foreground
|
||||
"$$WW,1$$$$BD,DKGRAY$$$$FD,WHITE$$"
|
||||
"\nThis is a memory game. "
|
||||
"Try to remember the digits and enter them. "
|
||||
"They are colored based on electrical "
|
||||
"engineering color codes.\n";
|
||||
"\nThis is a memory game. "
|
||||
"Try to remember the digits and enter them. "
|
||||
"They are colored based on electrical "
|
||||
"engineering color codes.\n";
|
||||
for (i=0;i<10;i++)
|
||||
"$$FG,%Z$$%d: %Z\n",i,"ST_RAINBOW_10",i,i,"ST_RAINBOW_10";
|
||||
"$$FG$$\n"; //set to default background
|
||||
@@ -42,7 +42,7 @@ U0 Digits()
|
||||
while (TRUE) {
|
||||
restart:
|
||||
num=0;
|
||||
//Set to zeros so we have terminators
|
||||
//Set to zeros so we have terminators
|
||||
MemSet(answer,0,sizeof(answer));
|
||||
while (TRUE) {
|
||||
DocClear;
|
||||
|
||||
+67
-68
@@ -1,5 +1,5 @@
|
||||
AcctRegSetDftEntry("TempleOS/DunGen","F64 best_score=9999;\n");
|
||||
AcctRegExeBranch("TempleOS/DunGen");
|
||||
RegSetDftEntry("TempleOS/DunGen","F64 best_score=9999;\n");
|
||||
RegExeBranch("TempleOS/DunGen");
|
||||
|
||||
//Set snap to 4 and width to 4
|
||||
//if you edit this map.
|
||||
@@ -43,17 +43,11 @@ $SP,"<10>",BI=10$
|
||||
$BG$//These are indexed by color #.
|
||||
//See $LK,"COLORS",A="MN:RED"$.
|
||||
|
||||
U8 *tiles1[16]=
|
||||
{NULL,$IB,"<7>",BI=7$ ,$IB,"<5>",BI=5$ ,NULL,
|
||||
NULL,NULL,NULL,NULL,
|
||||
$IB,"<6>",BI=6$ ,NULL,NULL,NULL,
|
||||
NULL,NULL,NULL,NULL};
|
||||
U8 *tiles1[16]={NULL,$IB,"<7>",BI=7$ ,$IB,"<5>",BI=5$ ,NULL,NULL,NULL,NULL,NULL,
|
||||
$IB,"<6>",BI=6$ ,NULL,NULL,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};
|
||||
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
|
||||
@@ -91,7 +85,7 @@ 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+LOS_SCALE/2,y1*LOS_SCALE+LOS_SCALE/2,0,
|
||||
x2*LOS_SCALE+LOS_SCALE/2,y2*LOS_SCALE+LOS_SCALE/2,0,&LOSPlot);
|
||||
x2*LOS_SCALE+LOS_SCALE/2,y2*LOS_SCALE+LOS_SCALE/2,0,&LOSPlot);
|
||||
}
|
||||
|
||||
U0 DrawIt(CTask *task,CDC *dc)
|
||||
@@ -110,9 +104,9 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
else
|
||||
_tiles=tiles2;
|
||||
|
||||
GrRotXEqu(dc_t->r,60*2*ã/360);
|
||||
GrRotZEqu(dc_t->r,15*2*ã/360);
|
||||
GrSetRotMat(dc_t,dc_t->r);
|
||||
Mat4x4RotX(dc_t->r,60*2*ã/360);
|
||||
Mat4x4RotZ(dc_t->r,15*2*ã/360);
|
||||
DCMat4x4Set(dc_t,dc_t->r);
|
||||
dc_t->x=task->pix_width/2;
|
||||
dc_t->y=task->pix_height/2;
|
||||
dc_t->flags|=DCF_TRANSFORMATION;
|
||||
@@ -133,7 +127,7 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
x1=x*SCREEN_SCALE;
|
||||
y1=y*SCREEN_SCALE;
|
||||
z1=0;
|
||||
GrTransform(dc_t,&x1,&y1,&z1);
|
||||
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;
|
||||
@@ -167,14 +161,14 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
x1=x*SCREEN_SCALE;
|
||||
y1=y*SCREEN_SCALE;
|
||||
z1=0;
|
||||
GrTransform(dc_t,&x1,&y1,&z1);
|
||||
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;
|
||||
z1=0;
|
||||
GrTransform(dc_t,&x1,&y1,&z1);
|
||||
DCTransform(dc_t,&x1,&y1,&z1);
|
||||
Sprite3(dc,x1,y1,z1,$IB,"<10>",BI=10$);
|
||||
}
|
||||
}
|
||||
@@ -187,10 +181,10 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
x1=(tempm->x-screen_x)*SCREEN_SCALE+SCREEN_SCALE/2;
|
||||
y1=(tempm->y-screen_y)*SCREEN_SCALE+SCREEN_SCALE/2;
|
||||
z1=0;
|
||||
GrTransform(dc_t,&x1,&y1,&z1);
|
||||
DCTransform(dc_t,&x1,&y1,&z1);
|
||||
if (tempm->dx<0) {
|
||||
dc->flags|=DCF_SYMMETRY|DCF_JUST_MIRROR;
|
||||
GrSetSymmetry(dc,x1,y1,x1,y1+1);
|
||||
DCSymmetrySet(dc,x1,y1,x1,y1+1);
|
||||
} else
|
||||
dc->flags&=~(DCF_SYMMETRY|DCF_JUST_MIRROR);
|
||||
Sprite3(dc,x1,y1,z1,$IB,"<4>",BI=4$);
|
||||
@@ -205,10 +199,10 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
if (man_dy!=1)
|
||||
y1-=Saw(tS-man_attack_t0,0.2)*SCREEN_SCALE;
|
||||
}
|
||||
GrTransform(dc_t,&x1,&y1,&z1);
|
||||
DCTransform(dc_t,&x1,&y1,&z1);
|
||||
if (man_dx<0) {
|
||||
dc->flags|=DCF_SYMMETRY|DCF_JUST_MIRROR;
|
||||
GrSetSymmetry(dc,x1,y1,x1,y1+1);
|
||||
DCSymmetrySet(dc,x1,y1,x1,y1+1);
|
||||
} else
|
||||
dc->flags&=~(DCF_SYMMETRY|DCF_JUST_MIRROR);
|
||||
|
||||
@@ -228,7 +222,8 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
dc->color=LTGREEN;
|
||||
tt=tS;
|
||||
}
|
||||
GrPrint(dc,0,0,"Enemy:%d Time:%3.2f Best:%3.2f",monsters_left,tt-t0,best_score);
|
||||
GrPrint(dc,0,0,"Enemy:%d Time:%3.2f Best:%3.2f",
|
||||
monsters_left,tt-t0,best_score);
|
||||
}
|
||||
|
||||
U0 Attack()
|
||||
@@ -264,7 +259,7 @@ U0 Init()
|
||||
map=MAlloc(map_width*map_height*sizeof(U8));
|
||||
for (y=0;y<map_height;y++)
|
||||
for (x=0;x<map_width;x++)
|
||||
map[y*map_width+x]=GrPeek(dc,x*MAP_SCALE,y*MAP_SCALE);
|
||||
map[y*map_width+x]=GrPeek(dc,x*MAP_SCALE,y*MAP_SCALE);
|
||||
DCDel(dc);
|
||||
|
||||
man_attack_t0=0;
|
||||
@@ -323,23 +318,23 @@ U0 DunGen()
|
||||
I64 ch,sc;
|
||||
|
||||
MenuPush(
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Restart(,'\n');"
|
||||
" Up(,,SC_CURSOR_UP);"
|
||||
" Down(,,SC_CURSOR_DOWN);"
|
||||
" Left(,,SC_CURSOR_LEFT);"
|
||||
" Right(,,SC_CURSOR_RIGHT);"
|
||||
" Attack(,CH_SPACE);"
|
||||
"}"
|
||||
);
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Restart(,'\n');"
|
||||
" Up(,,SC_CURSOR_UP);"
|
||||
" Down(,,SC_CURSOR_DOWN);"
|
||||
" Left(,,SC_CURSOR_LEFT);"
|
||||
" Right(,,SC_CURSOR_RIGHT);"
|
||||
" Attack(,CH_SPACE);"
|
||||
"}"
|
||||
);
|
||||
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
Fs->text_attr=BLACK<<4+WHITE;
|
||||
Preempt(OFF);
|
||||
Preempt;
|
||||
WinMax;
|
||||
AutoComplete;
|
||||
Init;
|
||||
@@ -370,14 +365,15 @@ U0 DunGen()
|
||||
man_dy=0;
|
||||
Attack;
|
||||
} else
|
||||
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+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;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_CURSOR_LEFT:
|
||||
if (man_attack) {
|
||||
@@ -385,14 +381,15 @@ U0 DunGen()
|
||||
man_dy=0;
|
||||
Attack;
|
||||
} else
|
||||
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-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;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_CURSOR_UP:
|
||||
if (man_attack) {
|
||||
@@ -400,14 +397,15 @@ U0 DunGen()
|
||||
man_dy=-1;
|
||||
Attack;
|
||||
} else
|
||||
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-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;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_CURSOR_DOWN:
|
||||
if (man_attack) {
|
||||
@@ -415,14 +413,15 @@ U0 DunGen()
|
||||
man_dy=1;
|
||||
Attack;
|
||||
} else
|
||||
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+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;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -439,7 +438,7 @@ dg_done:
|
||||
PutExcept;
|
||||
SettingsPop;
|
||||
MenuPop;
|
||||
AcctRegWriteBranch("TempleOS/DunGen","F64 best_score=%5.4f;\n",best_score);
|
||||
RegWriteBranch("TempleOS/DunGen","F64 best_score=%5.4f;\n",best_score);
|
||||
CleanUp;
|
||||
}
|
||||
|
||||
|
||||
+123
-176
@@ -1,7 +1,7 @@
|
||||
//Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
|
||||
AcctRegSetDftEntry("TempleOS/EagleDive","I64 best_score=0;\n");
|
||||
AcctRegExeBranch("TempleOS/EagleDive");
|
||||
RegSetDftEntry("TempleOS/EagleDive","I64 best_score=0;\n");
|
||||
RegExeBranch("TempleOS/EagleDive");
|
||||
|
||||
//Keep these power of two so shift is used instead of multiply
|
||||
//to index arrays.
|
||||
@@ -28,7 +28,7 @@ class Panel
|
||||
{
|
||||
Panel *next;
|
||||
I32 n, //num polygon sides
|
||||
num; //panel number
|
||||
num; //panel number
|
||||
CD3I32 *pts;
|
||||
I64 color,cnt;
|
||||
};
|
||||
@@ -68,8 +68,8 @@ Normally, just spawn a popup task,
|
||||
run it and kill it using an icon.
|
||||
*/
|
||||
I16 elevations[MAP_HEIGHT][MAP_WIDTH];
|
||||
I32 normals[MAP_HEIGHT][MAP_WIDTH*2];
|
||||
Panel *panels[MAP_HEIGHT][MAP_WIDTH*2];
|
||||
CD3 normals[MAP_HEIGHT][MAP_WIDTH];
|
||||
Panel *panels[MAP_HEIGHT][MAP_WIDTH];
|
||||
|
||||
I64 num_panels;
|
||||
Panel *panel_root;
|
||||
@@ -91,7 +91,7 @@ class MPCtrl {
|
||||
U0 EDTransform(CDC *dc,I64 *x,I64 *y,I64 *z)
|
||||
{
|
||||
I64 zz;
|
||||
GrRot(dc->r,x,y,z);
|
||||
Mat4x4MulXYZ(dc->r,x,y,z);
|
||||
*z=zz=-*z;
|
||||
if (zz>0) {
|
||||
*x = *x * DISPLAY_SCALE/ zz; //Foreshortening
|
||||
@@ -102,98 +102,48 @@ U0 EDTransform(CDC *dc,I64 *x,I64 *y,I64 *z)
|
||||
}
|
||||
|
||||
U0 CalcNormals()
|
||||
{
|
||||
/*The idea is that there are two tris
|
||||
forming every grid square and we find the normal
|
||||
vect with a curl.
|
||||
{/*Find the normal vect with a curl.
|
||||
|
||||
i j k
|
||||
0 1 dz2
|
||||
1 0 dz1
|
||||
i,j and k are the axis unit vectors,
|
||||
not to be confused with my local index variables.
|
||||
|
||||
Normal:
|
||||
dz1*i + dz2*j - k
|
||||
i j k
|
||||
0 1 dz2
|
||||
1 0 dz1
|
||||
|
||||
i j k
|
||||
-1 0 -dz3
|
||||
0 -1 -dz4
|
||||
|
||||
Normal:
|
||||
-dz3*i - dz4*j + k
|
||||
|
||||
|
||||
Basically, we want to combine grid
|
||||
locations with the same normals. These
|
||||
are not unit vects for one thing.
|
||||
|
||||
What I came-up with is dz1/dz2 and dz3/dz4.
|
||||
|
||||
It works pretty well. It combines
|
||||
more than it should, but that's good
|
||||
because it would result in too many
|
||||
panels.
|
||||
Normal: dz1*i + dz2*j - k
|
||||
*/
|
||||
I64 i,j,k,dz1,dz2;
|
||||
I64 i,j;
|
||||
for (j=0;j<MAP_HEIGHT-1;j++) {
|
||||
k=0;
|
||||
for (i=0;i<MAP_WIDTH-1;i++) {
|
||||
dz1=elevations[j][i+1]-elevations[j][i];
|
||||
dz2=elevations[j+1][i]-elevations[j][i];
|
||||
if (dz2)
|
||||
normals[j][k++]=dz1<<16/dz2;
|
||||
else {
|
||||
if (!dz1)
|
||||
normals[j][k++]=0;
|
||||
else if (dz1>0)
|
||||
normals[j][k++]=MAX_I32;
|
||||
else
|
||||
normals[j][k++]=MIN_I32;
|
||||
}
|
||||
|
||||
dz1=elevations[j+1][i+1]-elevations[j][i+1];
|
||||
dz2=elevations[j+1][i+1]-elevations[j+1][i];
|
||||
if (dz2)
|
||||
normals[j][k++]=dz1<<16/dz2;
|
||||
else {
|
||||
if (!dz1)
|
||||
normals[j][k++]=0;
|
||||
else if (dz1>0)
|
||||
normals[j][k++]=MAX_I32;
|
||||
else
|
||||
normals[j][k++]=MIN_I32;
|
||||
}
|
||||
normals[j][i].x=elevations[j][i+1]-elevations[j][i];
|
||||
normals[j][i].y=elevations[j+1][i]-elevations[j][i];
|
||||
normals[j][i].z=-1;
|
||||
D3Unit(&normals[j][i]);
|
||||
}
|
||||
normals[j][k++]=0;
|
||||
normals[j][k++]=0;
|
||||
}
|
||||
k=0;
|
||||
for (i=0;i<MAP_WIDTH-1;i++) {
|
||||
normals[j][k++]=0;
|
||||
normals[j][k++]=0;
|
||||
MemSet(&normals[j][i],0,sizeof(CD3));
|
||||
}
|
||||
for (i=0;i<MAP_WIDTH-1;i++)
|
||||
MemSet(&normals[j][i],0,sizeof(CD3));
|
||||
}
|
||||
|
||||
Bool TestSameSlope(I64 x,I64 y,I64 w,I64 h)
|
||||
{
|
||||
I64 k1,k2,xx,yy,s;
|
||||
CD3 p,*s;
|
||||
I64 k1,k2;
|
||||
if (!(0<=x && x+w<MAP_WIDTH && 0<=y && y+h<MAP_HEIGHT))
|
||||
return FALSE;
|
||||
//Works well averaging the two slopes of two tris.
|
||||
//If it is too picky, we get too many panels.
|
||||
s=normals[y][x*2]+normals[y][x*2+1];
|
||||
s=&normals[y][x];
|
||||
for (k2=0;k2<h;k2++)
|
||||
for (k1=0;k1<w;k1++) {
|
||||
xx=(x+k1)*2;
|
||||
yy=y+k2;
|
||||
if (normals[yy][xx]+normals[yy][xx+1]!=s)
|
||||
return FALSE;
|
||||
}
|
||||
for (k1=0;k1<w;k1++)
|
||||
if (D3NormSqr(D3Sub(&normals[y+k2][x+k1],s,&p))>.10)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
U0 MPDoPanels(CTask *task)
|
||||
{
|
||||
I64 i,j,k,l,k1,k2,w,h,threshold,lo,hi;
|
||||
I64 i,j,l,k1,k2,w,h,threshold,lo,hi;
|
||||
Bool cont;
|
||||
Panel *tempp,*start_ptr=NULL,*end_ptr=NULL;
|
||||
CD3I32 *poly;
|
||||
@@ -202,9 +152,8 @@ U0 MPDoPanels(CTask *task)
|
||||
hi=(Gs->num+1)*(MAP_HEIGHT-1)/mp.mp_cnt;
|
||||
for (threshold=8;threshold>=1;threshold--)
|
||||
for (j=lo;j<hi;j++) {
|
||||
k=0;
|
||||
for (i=0;i<MAP_WIDTH-1;i++) {
|
||||
if (!panels[j][k]) {
|
||||
if (!panels[j][i]) {
|
||||
w=1;
|
||||
h=1;
|
||||
do {
|
||||
@@ -223,9 +172,9 @@ U0 MPDoPanels(CTask *task)
|
||||
lock {tempp->num=num_panels++;}
|
||||
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) {
|
||||
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;
|
||||
if (Rand<0.05) {
|
||||
tempf=MAlloc(sizeof(Fish),task);
|
||||
@@ -286,13 +235,10 @@ U0 MPDoPanels(CTask *task)
|
||||
if (!end_ptr)
|
||||
end_ptr=tempp;
|
||||
for (k2=0;k2<h;k2++)
|
||||
for (k1=0;k1<w;k1++) {
|
||||
panels[j+k2][(i+k1)*2]=tempp;
|
||||
panels[j+k2][(i+k1)*2+1]=tempp;
|
||||
}
|
||||
for (k1=0;k1<w;k1++)
|
||||
panels[j+k2][i+k1]=tempp;
|
||||
}
|
||||
}
|
||||
k+=2;
|
||||
}
|
||||
}
|
||||
if (end_ptr) {
|
||||
@@ -338,15 +284,8 @@ U0 InitElevations()
|
||||
|
||||
U0 InitMap()
|
||||
{/*We make a topographic data structure "elevations[][]"
|
||||
and convert it to panels. The conversion to panels leaves
|
||||
gaps the way I did it, but it looks good, except for sky leaking through
|
||||
There is no wrong way to pick colors if it looks good, unless
|
||||
you wanted to do lighting.
|
||||
|
||||
"panels[][]" holds the flat and sloped panels for each spot, while
|
||||
"hstep_panels[][]" holds side panels in cases of step-like formations.
|
||||
They require a separate array because a single "elevation[][]" spot can
|
||||
have a panel on top and a panel on the side like stairs.
|
||||
and convert it to panels. "panels[][]" holds the panels
|
||||
for each spot.
|
||||
*/
|
||||
I64 i,x,y,xx,yy;
|
||||
|
||||
@@ -443,61 +382,63 @@ I64 update_jiffy_limit;
|
||||
U0 MPDrawIt(CTask *task,CDC *dc)
|
||||
{
|
||||
I64 j,strip_width,*s2w,x1,y1,z1, xx,yy,
|
||||
xh,yh,zh,yh2,xh2,x1h,y1h,x1wa,y1wa,x1wb,y1wb,
|
||||
x3,y3,z3,
|
||||
cx=task->pix_width>>1,
|
||||
cy=task->pix_height>>1;
|
||||
xh,yh,zh,yh2,xh2,x1h,y1h,x1wa,y1wa,x1wb,y1wb,
|
||||
x3,y3,z3,
|
||||
cx=task->pix_width>>1,
|
||||
cy=task->pix_height>>1;
|
||||
Panel reg *tempp;
|
||||
|
||||
xx=x/(MAP_SCALE*COORDINATE_SCALE);
|
||||
yy=y/(MAP_SCALE*COORDINATE_SCALE);
|
||||
|
||||
//World to screen coordinates
|
||||
GrIdentEqu(dc->r);
|
||||
GrRotZEqu(dc->r,é2);
|
||||
GrRotXEqu(dc->r,è);
|
||||
GrRotZEqu(dc->r,é1);
|
||||
GrSetRotMat(dc,dc->r);
|
||||
Mat4x4IdentEqu(dc->r);
|
||||
Mat4x4RotZ(dc->r,é2);
|
||||
Mat4x4RotX(dc->r,è);
|
||||
Mat4x4RotZ(dc->r,é1);
|
||||
DCMat4x4Set(dc,dc->r);
|
||||
|
||||
//Screen 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
|
||||
//and use the reciprocal slope principle y=mx+b and y=(-1/m)x+b are perpendicular.
|
||||
//This gives us the vects for stepping through the grid in
|
||||
//the direction the plane is facing. we step horizontally and vertically
|
||||
//and use the reciprocal slope principle
|
||||
//y=mx+b and y=(-1/m)x+b are perpendicular.
|
||||
|
||||
s2w=GrIdentNew;
|
||||
GrRotZEqu(s2w,-é1);
|
||||
GrRotXEqu(s2w,-è);
|
||||
GrRotZEqu(s2w,-é2);
|
||||
s2w=Mat4x4IdentNew;
|
||||
Mat4x4RotZ(s2w,-é1);
|
||||
Mat4x4RotX(s2w,-è);
|
||||
Mat4x4RotZ(s2w,-é2);
|
||||
xh=0;
|
||||
yh=0;
|
||||
zh=-256;
|
||||
GrRot(s2w,&xh,&yh,&zh);
|
||||
Mat4x4MulXYZ(s2w,&xh,&yh,&zh);
|
||||
|
||||
//The layer for core#1 is not cleared automatically
|
||||
//it is persistent. I have carefully syncronized to the update
|
||||
//cycle initiated by core#0 to prevent flicker.
|
||||
//The layer for core#1 is not cleared automatically
|
||||
//it is persistent. I have carefully syncronized to the update
|
||||
//cycle initiated by core#0 to prevent flicker.
|
||||
|
||||
dc->flags|=DCF_TRANSFORMATION;
|
||||
dc->transform=&EDTransform;
|
||||
dc->x=cx;
|
||||
dc->y=cy;
|
||||
|
||||
//dc->x and the translation part of dc->r are identical in effect,
|
||||
//but we use both to show-off. We could add offsets together and use one or the other.
|
||||
//dc->x and the translation part of dc->r are identical in effect,
|
||||
//but we use both to show-off. We could add offsets together and
|
||||
//use one or the other.
|
||||
|
||||
x1=-x>>COORDINATE_BITS;
|
||||
y1=-y>>COORDINATE_BITS;
|
||||
z1=-z>>COORDINATE_BITS;
|
||||
GrRot(dc->r,&x1,&y1,&z1);
|
||||
GrSetTranslation(dc->r,x1,y1,z1);
|
||||
Mat4x4MulXYZ(dc->r,&x1,&y1,&z1);
|
||||
Mat4x4TranslationEqu(dc->r,x1,y1,z1);
|
||||
|
||||
//This is a refinement.
|
||||
if (Abs(è*180/ã)>90) {
|
||||
x3=0;
|
||||
y3=-cy;
|
||||
z3=0;
|
||||
GrRot(s2w,&x3,&y3,&z3);
|
||||
Mat4x4MulXYZ(s2w,&x3,&y3,&z3);
|
||||
xx+=x3;
|
||||
yy+=y3;
|
||||
}
|
||||
@@ -528,13 +469,14 @@ 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*2]) && !LBts(panels_processed_bitmap,tempp->num)) {
|
||||
if (tempp->cnt>8*(1.1-Gs->idle_factor)) {
|
||||
dc->color=tempp->color;
|
||||
tempp->cnt=GrFillPoly3(dc,tempp->n,tempp->pts);
|
||||
} else
|
||||
tempp->cnt++;
|
||||
}
|
||||
if ((tempp=panels[y1][x1]) &&
|
||||
!LBts(panels_processed_bitmap,tempp->num)) {
|
||||
if (tempp->cnt>8*(1.1-Gs->idle_factor)) {
|
||||
dc->color=tempp->color;
|
||||
tempp->cnt=GrFillPoly3(dc,tempp->n,tempp->pts);
|
||||
} else
|
||||
tempp->cnt++;
|
||||
}
|
||||
}
|
||||
x1h+=xh;
|
||||
y1h+=yh;
|
||||
@@ -566,7 +508,7 @@ U0 APEagleDiveTask(CTask *master_task)
|
||||
MPDrawIt(master_task,dc);
|
||||
}
|
||||
|
||||
//We made an alias of this we don't want freed.
|
||||
//We made an alias of this we don't want freed.
|
||||
dc->depth_buf=NULL;
|
||||
|
||||
DCDel(dc);
|
||||
@@ -575,30 +517,30 @@ U0 APEagleDiveTask(CTask *master_task)
|
||||
|
||||
U0 DrawHorizon(CDC *dc)
|
||||
{
|
||||
I64 x1,y1,z1,x2,y2,z2,xh,yh,zh,*s2w=GrIdentNew,
|
||||
cx=Fs->pix_width>>1,
|
||||
cy=Fs->pix_height>>1;
|
||||
I64 x1,y1,z1,x2,y2,z2,xh,yh,zh,*s2w=Mat4x4IdentNew,
|
||||
cx=Fs->pix_width>>1,
|
||||
cy=Fs->pix_height>>1;
|
||||
CD3I32 p[4];
|
||||
I32 *old_db=dc->depth_buf;
|
||||
dc->depth_buf=NULL;
|
||||
|
||||
GrIdentEqu(dc->r);
|
||||
GrRotZEqu(dc->r,é2);
|
||||
GrRotXEqu(dc->r,è);
|
||||
GrRotZEqu(dc->r,é1);
|
||||
GrSetRotMat(dc,dc->r);
|
||||
Mat4x4IdentEqu(dc->r);
|
||||
Mat4x4RotZ(dc->r,é2);
|
||||
Mat4x4RotX(dc->r,è);
|
||||
Mat4x4RotZ(dc->r,é1);
|
||||
DCMat4x4Set(dc,dc->r);
|
||||
dc->flags&=~DCF_TRANSFORMATION;
|
||||
dc->transform=&EDTransform;
|
||||
dc->x=cx;
|
||||
dc->y=cy;
|
||||
|
||||
GrRotZEqu(s2w,-é1);
|
||||
GrRotXEqu(s2w,-è);
|
||||
GrRotZEqu(s2w,-é2);
|
||||
Mat4x4RotZ(s2w,-é1);
|
||||
Mat4x4RotX(s2w,-è);
|
||||
Mat4x4RotZ(s2w,-é2);
|
||||
xh=0;
|
||||
yh=0;
|
||||
zh=-256;
|
||||
GrRot(s2w,&xh,&yh,&zh);
|
||||
Mat4x4MulXYZ(s2w,&xh,&yh,&zh);
|
||||
Free(s2w);
|
||||
|
||||
x1=xh+yh*32; y1=yh-xh*32; z1=0;
|
||||
@@ -668,8 +610,8 @@ U0 BSPEagleDive()
|
||||
{
|
||||
CDC *dc=DCAlias(main_dc,Fs);
|
||||
I64 i,xx,yy,height,bkcolor,
|
||||
cx=Fs->pix_width>>1,
|
||||
cy=Fs->pix_height>>1;
|
||||
cx=Fs->pix_width>>1,
|
||||
cy=Fs->pix_height>>1;
|
||||
F64 min_strip_width;
|
||||
Fish *tempf;
|
||||
|
||||
@@ -716,7 +658,9 @@ U0 BSPEagleDive()
|
||||
min_strip_width=MAX_F64;
|
||||
for (i=0;i<mp.mp_cnt;i++)
|
||||
min_strip_width=Min(min_strip_width,32.0*mp.strip_width[i]/(i+32.0));
|
||||
strip_height=ClampI64(strip_height*Clamp(0.25*min_strip_width/strip_height,0.9,1.1),64,1024);
|
||||
strip_height=ClampI64(
|
||||
strip_height*Clamp(0.25*min_strip_width/strip_height,0.9,1.1),
|
||||
64,1024);
|
||||
} else {
|
||||
dc->color=bkcolor;
|
||||
GrRect(dc,0,0,dc->width,dc->height);
|
||||
@@ -730,19 +674,21 @@ U0 BSPEagleDive()
|
||||
GrLine3(dc,cx+5,cy,0,cx-5,cy,0);
|
||||
GrLine3(dc,cx,cy+5,0,cx,cy-5,0);
|
||||
GrPrint(dc,0,0,"é1:%5.1f è:%5.1f é2:%5.1f Strip:%5d",
|
||||
é1*180/ã,è*180/ã,é2*180/ã,strip_height);
|
||||
GrPrint(dc,0,FONT_HEIGHT,"x:%5.1f y:%5.1f z:%5.1f height:%3d score:%d high:%d",
|
||||
ToF64(x)/COORDINATE_SCALE,ToF64(y)/COORDINATE_SCALE,ToF64(z)/COORDINATE_SCALE,
|
||||
height,game_score,best_score);
|
||||
é1*180/ã,è*180/ã,é2*180/ã,strip_height);
|
||||
GrPrint(dc,0,FONT_HEIGHT,
|
||||
"x:%5.1f y:%5.1f z:%5.1f height:%3d score:%d high:%d",
|
||||
ToF64(x)/COORDINATE_SCALE,
|
||||
ToF64(y)/COORDINATE_SCALE,ToF64(z)/COORDINATE_SCALE,
|
||||
height,game_score,best_score);
|
||||
|
||||
if (game_over && Blink) {
|
||||
dc->color=RED;
|
||||
GrPrint(dc,(Fs->pix_width-9*FONT_WIDTH)/2,
|
||||
(Fs->pix_height-FONT_HEIGHT)/2,"Game Over");
|
||||
(Fs->pix_height-FONT_HEIGHT)/2,"Game Over");
|
||||
} else if (tS-game_t0<5.0 && Blink) {
|
||||
dc->color=WHITE;
|
||||
GrPrint(dc,(Fs->pix_width-10*FONT_WIDTH)/2,
|
||||
(Fs->pix_height-FONT_HEIGHT)/2,"Catch Fish");
|
||||
(Fs->pix_height-FONT_HEIGHT)/2,"Catch Fish");
|
||||
}
|
||||
//We made an alias of this we don't want freed.
|
||||
dc->depth_buf=NULL;
|
||||
@@ -761,13 +707,13 @@ U0 AnimateTask(I64)
|
||||
mS=1000*(tS-t0);
|
||||
t0=tS;
|
||||
if (!game_over) {
|
||||
//Screen to world coordinates
|
||||
s2w=GrIdentNew;
|
||||
GrRotZEqu(s2w,-é1);
|
||||
GrRotXEqu(s2w,-è);
|
||||
GrRotZEqu(s2w,-é2);
|
||||
//Screen to world coordinates
|
||||
s2w=Mat4x4IdentNew;
|
||||
Mat4x4RotZ(s2w,-é1);
|
||||
Mat4x4RotX(s2w,-è);
|
||||
Mat4x4RotZ(s2w,-é2);
|
||||
x1=0;y1=0;z1=-speed*mS*COORDINATE_SCALE;
|
||||
GrRot(s2w,&x1,&y1,&z1);
|
||||
Mat4x4MulXYZ(s2w,&x1,&y1,&z1);
|
||||
x+=x1;
|
||||
y+=y1;
|
||||
z+=z1;
|
||||
@@ -779,7 +725,8 @@ U0 AnimateTask(I64)
|
||||
tempf=fish_root.next;
|
||||
while (tempf!=&fish_root) {
|
||||
tempf1=tempf->next;
|
||||
if (SqrI64(tempf->p.x-x1)+SqrI64(tempf->p.y-y1)<MAP_SCALE*MAP_SCALE*5*5) {
|
||||
if (SqrI64(tempf->p.x-x1)+
|
||||
SqrI64(tempf->p.y-y1)<MAP_SCALE*MAP_SCALE*5*5) {
|
||||
game_score++;
|
||||
if (game_score>best_score)
|
||||
best_score=game_score;
|
||||
@@ -810,7 +757,7 @@ U0 MPEnd()
|
||||
update_jiffy_limit=0;
|
||||
mp.app_not_done_flags=1<<mp.mp_cnt-1-1;
|
||||
mp.app_done=TRUE;
|
||||
//Wait for all cores to exit
|
||||
//Wait for all cores to exit
|
||||
while (mp.app_not_done_flags)
|
||||
Sleep(1);
|
||||
}
|
||||
@@ -827,8 +774,8 @@ U0 SongTask(I64)
|
||||
MusicSettingsRst;
|
||||
music.stacatto_factor=0.2;
|
||||
while (TRUE) {
|
||||
Play("3eBDEDBDEDFEEDFEED");
|
||||
Play("BDEDBDEDFEEDFEED");
|
||||
Play("3eBDEDBDEDFEEDFEED");
|
||||
Play("BDEDBDEDFEEDFEED");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -846,7 +793,7 @@ U0 Init(I64 _mp_cnt)
|
||||
mp.mp_cnt=mp_cnt;
|
||||
QueInit(&fish_root);
|
||||
InitMap;
|
||||
DCAllocDepthBuf(main_dc);
|
||||
DCDepthBufAlloc(main_dc);
|
||||
|
||||
strip_height=128;
|
||||
è =-90.0*ã/180.0;
|
||||
@@ -895,18 +842,18 @@ U0 EagleDive(I64 _mp_cnt=MP_MAX_PROCESSORS)
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
AutoComplete;
|
||||
MenuPush(
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Restart(,'\n');"
|
||||
" Down(,,SC_CURSOR_UP);"
|
||||
" Up(,,SC_CURSOR_DOWN);"
|
||||
" Left(,,SC_CURSOR_LEFT);"
|
||||
" Right(,,SC_CURSOR_RIGHT);"
|
||||
"}"
|
||||
);
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Restart(,'\n');"
|
||||
" Down(,,SC_CURSOR_UP);"
|
||||
" Up(,,SC_CURSOR_DOWN);"
|
||||
" Left(,,SC_CURSOR_LEFT);"
|
||||
" Right(,,SC_CURSOR_RIGHT);"
|
||||
"}"
|
||||
);
|
||||
WinMax;
|
||||
WinBorder;
|
||||
"Initializing...\n";
|
||||
@@ -946,7 +893,7 @@ U0 EagleDive(I64 _mp_cnt=MP_MAX_PROCESSORS)
|
||||
Init(_mp_cnt);
|
||||
Fs->draw_it=&DrawIt;
|
||||
break;
|
||||
}
|
||||
}
|
||||
é1=Wrap(é1);
|
||||
è =Wrap(è);
|
||||
é2=Wrap(é2);
|
||||
@@ -958,7 +905,7 @@ U0 EagleDive(I64 _mp_cnt=MP_MAX_PROCESSORS)
|
||||
SettingsPop;
|
||||
CleanUp;
|
||||
#ifjit
|
||||
AcctRegWriteBranch("TempleOS/EagleDive","I64 best_score=%d;\n",best_score);
|
||||
RegWriteBranch("TempleOS/EagleDive","I64 best_score=%d;\n",best_score);
|
||||
#endif
|
||||
MenuPop;
|
||||
}
|
||||
|
||||
Binary file not shown.
+73
-50
@@ -36,13 +36,13 @@ class Obj
|
||||
U16 flags;
|
||||
I16 squadron,member_num;
|
||||
F64 x,y,é,dé,
|
||||
speed,turn_rate,
|
||||
life_percent,
|
||||
target_x,target_y,
|
||||
ship_guns,ship_guns_range,
|
||||
air_guns,air_guns_range,
|
||||
fuel,max_fuel,fuel_burn_rate,
|
||||
death_time,next_action_time;
|
||||
speed,turn_rate,
|
||||
life_percent,
|
||||
target_x,target_y,
|
||||
ship_guns,ship_guns_range,
|
||||
air_guns,air_guns_range,
|
||||
fuel,max_fuel,fuel_burn_rate,
|
||||
death_time,next_action_time;
|
||||
I32 torpedos,max_torpedos;
|
||||
F64 torpedos_range;
|
||||
U8 fire[(FIRE_WIDTH*FIRE_HEIGHT+7)/8];
|
||||
@@ -100,7 +100,7 @@ Obj *ObjFind(F64 x,F64 y,
|
||||
F64 dd,best_dd=MAX_F64;
|
||||
while (tempo!=&obj_root) {
|
||||
if (tempo->flags&flag_mask==flag_val &&
|
||||
Bt(&type_mask,tempo->type)&&Bt(&player_mask,tempo->player)) {
|
||||
Bt(&type_mask,tempo->type)&&Bt(&player_mask,tempo->player)) {
|
||||
dd=Sqr(tempo->x-x)+Sqr(tempo->y-y);
|
||||
if (dd<best_dd) {
|
||||
best=tempo;
|
||||
@@ -162,7 +162,7 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
F64 d,cur_time=tS;
|
||||
Obj *tempo;
|
||||
Torpedo *tempt;
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
Bool old_preempt=Preempt;
|
||||
|
||||
tempt=torpedo_root.next;
|
||||
while (tempt!=&torpedo_root) {
|
||||
@@ -174,17 +174,21 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
tempo=obj_root.next;
|
||||
while (tempo!=&obj_root) {
|
||||
if (tempo->flags&OF_ACTIVE && tempo->flags&OF_SHIP) {
|
||||
SpriteZ3B(dc,tempo->x,tempo->y,0,imgs[tempo->player][tempo->type],tempo->é+ã/2);
|
||||
SpriteZ3B(dc,tempo->x,tempo->y,0,
|
||||
imgs[tempo->player][tempo->type],tempo->é+ã/2);
|
||||
|
||||
k=0;
|
||||
for (j=0;j<FIRE_HEIGHT;j++)
|
||||
for (i=0;i<FIRE_WIDTH;i++)
|
||||
if (Bt(tempo->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->é));
|
||||
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->é));
|
||||
}
|
||||
if (Blink) {
|
||||
dc->color=BLACK;
|
||||
@@ -197,7 +201,8 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
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,tempo->x+5,tempo->y,
|
||||
tempo->x+5+10*tempo->life_percent/100,tempo->y);
|
||||
}
|
||||
|
||||
dc->color=BLACK;
|
||||
@@ -220,7 +225,8 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
tempo=obj_root.next;
|
||||
while (tempo!=&obj_root) {
|
||||
if (tempo->flags&OF_ACTIVE && !(tempo->flags&OF_SHIP))
|
||||
SpriteZ3B(dc,tempo->x,tempo->y,0,imgs[tempo->player][tempo->type],tempo->é+ã/2);
|
||||
SpriteZ3B(dc,tempo->x,tempo->y,0,
|
||||
imgs[tempo->player][tempo->type],tempo->é+ã/2);
|
||||
if (tempo->flags&OF_SHOOTING) {
|
||||
dc->color=LTRED;
|
||||
GrLine(dc,tempo->x,tempo->y,tempo->target_x,tempo->target_y,3);
|
||||
@@ -231,23 +237,29 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
dc->flags|=DCF_TRANSFORMATION;
|
||||
if (cur_time<launch_t) {
|
||||
dc->color=LTGREEN;
|
||||
GrArrow3(dc,launch_unit_x1,launch_unit_y1,0,launch_unit_x2,launch_unit_y2,0);
|
||||
GrArrow3(dc,launch_unit_x1,launch_unit_y1,0,
|
||||
launch_unit_x2,launch_unit_y2,0);
|
||||
}
|
||||
if (cur_time<return_t) {
|
||||
dc->color=LTRED;
|
||||
GrArrow3(dc,return_unit_x1,return_unit_y1,0,return_unit_x2,return_unit_y2,0);
|
||||
GrArrow3(dc,return_unit_x1,return_unit_y1,0,
|
||||
return_unit_x2,return_unit_y2,0);
|
||||
}
|
||||
if (cur_time<set_é_t) {
|
||||
dc->color=YELLOW;
|
||||
GrArrow3(dc,set_é_unit_x1,set_é_unit_y1,0,set_é_unit_x2,set_é_unit_y2,0);
|
||||
GrArrow3(dc,set_é_unit_x1,set_é_unit_y1,0,
|
||||
set_é_unit_x2,set_é_unit_y2,0);
|
||||
}
|
||||
|
||||
dc->color=YELLOW;
|
||||
GrPrint(dc,-task->scroll_x,-task->scroll_y,"Game Speed: %5.2f",game_speed);
|
||||
GrPrint(dc,-task->scroll_x,-task->scroll_y,
|
||||
"Game Speed: %5.2f",game_speed);
|
||||
dc->color=LTCYAN;
|
||||
GrPrint(dc,-task->scroll_x,-task->scroll_y+ FONT_HEIGHT,"Player 1: %d",num_alive[0]);
|
||||
GrPrint(dc,-task->scroll_x,-task->scroll_y+FONT_HEIGHT,
|
||||
"Player 1: %d",num_alive[0]);
|
||||
dc->color=LTPURPLE;
|
||||
GrPrint(dc,-task->scroll_x,-task->scroll_y+2*FONT_HEIGHT,"Player 2: %d",num_alive[1]);
|
||||
GrPrint(dc,-task->scroll_x,-task->scroll_y+2*FONT_HEIGHT,
|
||||
"Player 2: %d",num_alive[1]);
|
||||
|
||||
if ((!num_alive[0]||!num_alive[1]) && Blink) {
|
||||
if (!num_alive[1]) {
|
||||
@@ -266,7 +278,7 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
U0 Init()
|
||||
{
|
||||
I64 i,fighter,ship,player,squadron,
|
||||
w=Fs->pix_width,h=Fs->pix_height;
|
||||
w=Fs->pix_width,h=Fs->pix_height;
|
||||
Squadron *temps;
|
||||
Obj *tempo,*tempo1;
|
||||
QueInit(&obj_root);
|
||||
@@ -322,7 +334,8 @@ U0 Init()
|
||||
tempo1->next_action_time=0;
|
||||
QueIns(tempo1,obj_root.last);
|
||||
|
||||
for (squadron=0;squadron<num_squadrons_per_carrier[player];squadron++,num_squadrons++) {
|
||||
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));
|
||||
num_alive[player]++;
|
||||
@@ -368,7 +381,8 @@ U0 CleanUp()
|
||||
Free(squadrons);
|
||||
}
|
||||
|
||||
Obj *ObjLaunch(I64 player,I64 squadron=-1,Obj *host=NULL,F64 x=MAX_F64,F64 y=MAX_F64,F64 é=MAX_F64)
|
||||
Obj *ObjLaunch(I64 player,I64 squadron=-1,
|
||||
Obj *host=NULL,F64 x=MAX_F64,F64 y=MAX_F64,F64 é=MAX_F64)
|
||||
{
|
||||
Obj *tempo;
|
||||
F64 cur_time=tS;
|
||||
@@ -379,9 +393,12 @@ Obj *ObjLaunch(I64 player,I64 squadron=-1,Obj *host=NULL,F64 x=MAX_F64,F64 y=MAX
|
||||
é=Arg(x-host->x,y-host->y);
|
||||
tempo=obj_root.next;
|
||||
while (tempo!=&obj_root) {
|
||||
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) //When low on fuel, not zero, gets launched and captured.
|
||||
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)
|
||||
//When low on fuel, not zero, gets launched and captured.
|
||||
LBts(&squadrons[tempo->squadron].dead_mask,tempo->member_num);
|
||||
else {
|
||||
tempo->flags=tempo->flags&~OF_RETURNING|OF_ACTIVE;
|
||||
@@ -461,7 +478,8 @@ 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)) {
|
||||
if ((tempo=ObjFind(x,y,,,,1<<player)) && tempo->flags&OF_ACTIVE &&
|
||||
!(tempo->flags&OF_RETURNING)) {
|
||||
if (é==MAX_F64)
|
||||
é=Arg(x-tempo->x,y-tempo->y);
|
||||
tempo->dé+=Wrap(é-(tempo->é+tempo->dé),-ã);
|
||||
@@ -553,7 +571,8 @@ U0 AI(I64 player,F64 period)
|
||||
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) && Rand<10.0*period)
|
||||
if (tempo->flags&OF_ACTIVE && !(tempo->flags&OF_RETURNING) &&
|
||||
Rand<10.0*period)
|
||||
SquadronSeté(player,tempo->x,tempo->y,tempo->é+pi/2*(Rand-0.5));
|
||||
}
|
||||
tempo=tempo->next;
|
||||
@@ -607,7 +626,8 @@ U0 Combat(F64 period)
|
||||
while (tempo!=&obj_root) {
|
||||
tempo->flags&=~OF_SHOOTING;
|
||||
if (tempo->flags&OF_ACTIVE &&
|
||||
(tempo1=ObjFind(tempo->x,tempo->y,OF_ACTIVE,OF_ACTIVE,,1<<(tempo->player^1),&d))) {
|
||||
(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) {
|
||||
@@ -656,8 +676,9 @@ U0 Combat(F64 period)
|
||||
while (tempo!=&obj_root) {
|
||||
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))
|
||||
(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;
|
||||
}
|
||||
@@ -746,7 +767,8 @@ U0 AnimateTask(I64)
|
||||
} 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é),-ã);
|
||||
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);
|
||||
}
|
||||
@@ -771,28 +793,29 @@ U0 FlatTops()
|
||||
DocCursor;
|
||||
DocClear;
|
||||
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");
|
||||
Preempt(OFF),
|
||||
MenuPush(
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Restart(,'\n');"
|
||||
" Faster(,'+');"
|
||||
" Slower(,'-');"
|
||||
"}"
|
||||
);
|
||||
"$$GREEN$${Right-Mouse}$$FG$$\t\tLaunch Squadron\n"
|
||||
"$$GREEN$${Right-Double-Mouse}$$FG$$\tReturn Squadron\n"
|
||||
"$$GREEN$${Ctrl-Left Grab}$$FG$$\tScroll Screen\n");
|
||||
Preempt,
|
||||
MenuPush(
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Restart(,'\n');"
|
||||
" Faster(,'+');"
|
||||
" Slower(,'-');"
|
||||
"}"
|
||||
);
|
||||
Fs->win_inhibit|=WIF_SELF_IP_L|WIF_SELF_IP_R;
|
||||
Init;
|
||||
Fs->draw_it=&DrawIt;
|
||||
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
|
||||
try {
|
||||
while (TRUE)
|
||||
switch(GetMsg(&a1,&a2,1<<MSG_KEY_DOWN|1<<MSG_IP_L_UP|1<<MSG_IP_R_UP|1<<MSG_IP_R_D_UP)) {
|
||||
switch(GetMsg(&a1,&a2,
|
||||
1<<MSG_KEY_DOWN|1<<MSG_IP_L_UP|1<<MSG_IP_R_UP|1<<MSG_IP_R_D_UP)) {
|
||||
case MSG_KEY_DOWN:
|
||||
switch (a1) {
|
||||
case '\n':
|
||||
|
||||
+16
-16
@@ -12,7 +12,7 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
{
|
||||
I64 w=task->pix_width,h=task->pix_height;
|
||||
I64 i,x,y,xx;
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
Bool old_preempt=Preempt;
|
||||
xx=w>>1-car_x+road_x[road_ptr&(NUM_ROAD-1)];
|
||||
|
||||
dc->color=LTGRAY;
|
||||
@@ -24,7 +24,7 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
GrPlot(dc,x-ROAD_WIDTH_BY_2+0.4*i,y);
|
||||
}
|
||||
dc->color=WHITE;
|
||||
|
||||
|
||||
x=w>>1-CAR_WIDTH_BY_2;
|
||||
if (x<xx-ROAD_WIDTH_BY_2)
|
||||
crash=TRUE;
|
||||
@@ -51,7 +51,7 @@ U0 UpdateRoad()
|
||||
while (distance>1.0) {
|
||||
road_trend=ClampI64(road_trend+SignI64(RandU16%3-1),-5,5);
|
||||
road_x[road_ptr&(NUM_ROAD-1)]=
|
||||
road_x[(road_ptr-1)&(NUM_ROAD-1)]+=road_trend/3;
|
||||
road_x[(road_ptr-1)&(NUM_ROAD-1)]+=road_trend/3;
|
||||
road_ptr++;
|
||||
distance-=1.0;
|
||||
}
|
||||
@@ -82,19 +82,19 @@ U0 Halogen()
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
Fs->text_attr=BLACK<<4+WHITE;
|
||||
MenuPush(
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Restart(,'\n');"
|
||||
" Accelerate(,,SC_CURSOR_UP);"
|
||||
" Deccellerate(,,SC_CURSOR_DOWN);"
|
||||
" Left(,,SC_CURSOR_LEFT);"
|
||||
" Right(,,SC_CURSOR_RIGHT);"
|
||||
"}"
|
||||
);
|
||||
Preempt(OFF);
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Restart(,'\n');"
|
||||
" Accelerate(,,SC_CURSOR_UP);"
|
||||
" Deccellerate(,,SC_CURSOR_DOWN);"
|
||||
" Left(,,SC_CURSOR_LEFT);"
|
||||
" Right(,,SC_CURSOR_RIGHT);"
|
||||
"}"
|
||||
);
|
||||
Preempt;
|
||||
AutoComplete;
|
||||
WinMax;
|
||||
Init;
|
||||
|
||||
+18
-20
@@ -9,18 +9,16 @@ class MySpring:CSpring
|
||||
|
||||
CMathODE *ode=NULL;
|
||||
|
||||
U0 DrawIt(CTask *task,CDC *dc)
|
||||
U0 DrawIt(CTask *,CDC *dc)
|
||||
{
|
||||
Bool old_suspend;
|
||||
MyMass *tempm;
|
||||
MySpring *temps;
|
||||
|
||||
old_suspend=Suspend(task);
|
||||
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->end2->x,temps->end2->y);
|
||||
temps=temps->next;
|
||||
}
|
||||
|
||||
@@ -30,13 +28,12 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
GrCircle(dc,tempm->x,tempm->y,tempm->radius);
|
||||
tempm=tempm->next;
|
||||
}
|
||||
Suspend(task,old_suspend);
|
||||
}
|
||||
|
||||
U0 MyDerivative(CMathODE *ode,F64,COrder2D3 *,COrder2D3 *)
|
||||
{//The forces due to springs and drag are
|
||||
//automatically handled by the ode code.
|
||||
//We can add new forces here.
|
||||
//We can add new forces here.
|
||||
F64 d,dd;
|
||||
CD3 p;
|
||||
MyMass *tempm1,*tempm2;
|
||||
@@ -106,13 +103,13 @@ U0 MassSpringDemo()
|
||||
MyMass *tempm1=NULL,*tempm2=NULL;
|
||||
|
||||
PopUpOk("Left-Click to place mas\n"
|
||||
"Right-Click and drag to\n"
|
||||
"connect with spring.\n\n"
|
||||
"Springs are 100 pixs long.\n");
|
||||
"Right-Click and drag to\n"
|
||||
"connect with spring.\n\n"
|
||||
"Springs are 100 pixs long.\n");
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
WinMax;
|
||||
|
||||
/*Preempt(OFF) eliminates a lot of hassles.
|
||||
/*Preempt eliminates a lot of hassles.
|
||||
The concern is about changing
|
||||
que links while the winmgr task
|
||||
is updating the ode or screen.
|
||||
@@ -124,20 +121,20 @@ preempt, we will not be interrupted.
|
||||
There is little downside to Preempt()
|
||||
since we will yield during GetMsg().
|
||||
*/
|
||||
Preempt(OFF);
|
||||
Preempt;
|
||||
|
||||
Fs->win_inhibit|=WIG_DBL_CLICK;
|
||||
AutoComplete;
|
||||
|
||||
MenuPush(
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Restart(,'\n');"
|
||||
"}"
|
||||
);
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Restart(,'\n');"
|
||||
"}"
|
||||
);
|
||||
|
||||
Init;
|
||||
DocCursor;
|
||||
@@ -146,7 +143,8 @@ since we will yield during GetMsg().
|
||||
|
||||
try {
|
||||
while (TRUE) {
|
||||
msg_code=GetMsg(&a1,&a2,1<<MSG_IP_L_DOWN|1<<MSG_IP_R_DOWN|1<<MSG_IP_R_UP|1<<MSG_KEY_DOWN);
|
||||
msg_code=GetMsg(&a1,&a2,
|
||||
1<<MSG_IP_L_DOWN|1<<MSG_IP_R_DOWN|1<<MSG_IP_R_UP|1<<MSG_KEY_DOWN);
|
||||
switch (msg_code) {
|
||||
case MSG_IP_L_DOWN:
|
||||
PlaceMass(a1,a2);
|
||||
|
||||
+8
-8
@@ -8,11 +8,11 @@ U0 DrawIt(CTask *task,CDC *)
|
||||
{ //$LK,"gr.text_base",A="MN:CGrGlbls"$ gets clear 30fps, so we must use our own permanent text array.
|
||||
MemCpy(gr.text_base+TEXT_COLS,text,(TEXT_ROWS-1)*TEXT_COLS*sizeof(U32));
|
||||
|
||||
// You can copy it this way, if you like:
|
||||
// I64 i,j;
|
||||
// for (j=0;j<TEXT_ROWS;j++)
|
||||
// for (i=0;i<TEXT_COLS;i++)
|
||||
// TextChar(task,,i,j,text[j][i]);
|
||||
// You can copy it this way, if you like:
|
||||
// I64 i,j;
|
||||
// for (j=0;j<TEXT_ROWS;j++)
|
||||
// for (i=0;i<TEXT_COLS;i++)
|
||||
// TextChar(task,,i,j,text[j][i]);
|
||||
|
||||
TextPrint(task,0,0,ATTR>>8,"Draw a maze with left button.");
|
||||
TextPrint(task,0,1,ATTR>>8,"Solve maze starting at right click.");
|
||||
@@ -43,7 +43,7 @@ U0 SolveMaze(I64 x,I64 y)
|
||||
stk_dir[stk_ptr++]=dir;
|
||||
while (TRUE) {
|
||||
if (!(0<=x<MinI64(Fs->win_width,TEXT_COLS)) ||
|
||||
!(0<=y<MinI64(Fs->win_height,TEXT_ROWS)) ) {
|
||||
!(0<=y<MinI64(Fs->win_height,TEXT_ROWS)) ) {
|
||||
Beep;Beep;
|
||||
break;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ U0 SolveMaze(I64 x,I64 y)
|
||||
text[y][x]='.'+ATTR;
|
||||
x+=dir_x[dir];
|
||||
y+=dir_y[dir];
|
||||
//u8.[0] is the ASCII
|
||||
//u8.[0] is the ASCII
|
||||
if (text[y][x].u8[0]) {
|
||||
x-=dir_x[dir];
|
||||
y-=dir_y[dir];
|
||||
@@ -91,7 +91,7 @@ U0 Maze()
|
||||
do {
|
||||
MemSet(text,0,sizeof(text));
|
||||
while (!(ch=ScanChar)) {
|
||||
//Input Ptr (mouse) text x,y coordinates.
|
||||
//Input Ptr (mouse) text x,y coordinates.
|
||||
x=ip.pos_text.x-Fs->win_left-Fs->scroll_x/FONT_WIDTH;
|
||||
y=ip.pos_text.y-Fs->win_top-Fs->scroll_y/FONT_HEIGHT;
|
||||
if (ip.lb&&!winmgr.grab_scroll)
|
||||
|
||||
+15
-14
@@ -12,7 +12,7 @@ CDC *cur_dc;
|
||||
U0 DrawFrame(CTask *task,CDC *dc)
|
||||
{
|
||||
I64 w=task->pix_width,h=task->pix_height,
|
||||
cx=w>>1,cy=h>>1;
|
||||
cx=w>>1,cy=h>>1;
|
||||
|
||||
dc->color=LTRED;
|
||||
GrLine(dc,cx-20,cy-50,cx,cy-150);
|
||||
@@ -56,10 +56,11 @@ U0 DrawDrops(CTask *,CDC *dc)
|
||||
|
||||
U0 UpdateCurBase(CTask *task,CDC *dc)
|
||||
{
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
Bool old_preempt=Preempt;
|
||||
cur_dc->color=ROP_EQU;
|
||||
dc->flags|=DCF_NO_TRANSPARENTS;
|
||||
GrBlot(cur_dc,-task->pix_left-task->scroll_x,-task->pix_top-task->scroll_y,dc);
|
||||
GrBlot(cur_dc,-task->pix_left-task->scroll_x,
|
||||
-task->pix_top-task->scroll_y,dc);
|
||||
dc->flags&=~DCF_NO_TRANSPARENTS;
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
@@ -87,7 +88,7 @@ U0 AnimateTask(I64)
|
||||
break;
|
||||
j++;
|
||||
} while (j<=NUM_DROPS);
|
||||
|
||||
|
||||
drops[cur_drop].x=RandU32%w;
|
||||
drops[cur_drop].y=0;
|
||||
}
|
||||
@@ -150,16 +151,16 @@ U0 RainDrops()
|
||||
{
|
||||
I64 ch,sc;
|
||||
MenuPush(
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Restart(,'\n');"
|
||||
" OpenUpper(,'1');"
|
||||
" OpenLower(,'2');"
|
||||
"}"
|
||||
);
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Restart(,'\n');"
|
||||
" OpenUpper(,'1');"
|
||||
" OpenLower(,'2');"
|
||||
"}"
|
||||
);
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
WinMax;
|
||||
cur_dc=DCNew(GR_WIDTH,GR_HEIGHT);
|
||||
|
||||
+62
-49
@@ -1,7 +1,7 @@
|
||||
//Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
|
||||
AcctRegSetDftEntry("TempleOS/RawHide","F64 best_score=9999;\n");
|
||||
AcctRegExeBranch("TempleOS/RawHide");
|
||||
RegSetDftEntry("TempleOS/RawHide","F64 best_score=9999;\n");
|
||||
RegExeBranch("TempleOS/RawHide");
|
||||
|
||||
F64 t0,tf;
|
||||
I64 outside_cnt;
|
||||
@@ -62,7 +62,7 @@ U0 RiverNew()
|
||||
U0 RiverMake()
|
||||
{
|
||||
I64 i,x,y,dx,dy,w,old_x,old_y;
|
||||
//Plan lower course of river
|
||||
//Plan lower course of river
|
||||
old_x=-1;old_y=-1;
|
||||
x=MAP_WIDTH<<32/2; y=MAP_HEIGHT<<32/2;
|
||||
dx=0; dy=1<<32;
|
||||
@@ -79,7 +79,7 @@ U0 RiverMake()
|
||||
x+=dx; y+=dy;
|
||||
w=ClampI64(w+RandI32*2,10*MAX_U32,150*MAX_U32);
|
||||
}
|
||||
//Plan upper course of river
|
||||
//Plan upper course of river
|
||||
old_x=-1;old_y=-1;
|
||||
x=MAP_WIDTH<<32/2; y=MAP_HEIGHT<<32/2;
|
||||
dx=0; dy=-1<<32;
|
||||
@@ -154,12 +154,17 @@ U0 RiverDropsNext(CTask *mem_task)
|
||||
} else {
|
||||
do {
|
||||
if (RandU16&1 &&
|
||||
GrPeek(map_dc,r_x[tempr->index]+tempr->dx,r_y[tempr->index]+tempr->dy)==BLUE)
|
||||
GrPeek(map_dc,r_x[tempr->index]+tempr->dx,
|
||||
r_y[tempr->index]+tempr->dy)==BLUE)
|
||||
break;
|
||||
tempr->dx=ClampI64(tempr->dx+RandU16%3-1,-r_width[tempr->index]/2,r_width[tempr->index]/2);
|
||||
tempr->dy=ClampI64(tempr->dy+RandU16%3-1,-r_width[tempr->index]/2,r_width[tempr->index]/2);
|
||||
} while (GrPeek(map_dc,r_x[tempr->index]+tempr->dx,r_y[tempr->index]+tempr->dy)!=BLUE &&
|
||||
GrPeek(map_dc,r_x[tempr->index] ,r_y[tempr->index]) ==BLUE); //Might be reinitializing
|
||||
tempr->dx=ClampI64(tempr->dx+RandU16%3-1,-r_width[tempr->index]/2,
|
||||
r_width[tempr->index]/2);
|
||||
tempr->dy=ClampI64(tempr->dy+RandU16%3-1,-r_width[tempr->index]/2,
|
||||
r_width[tempr->index]/2);
|
||||
} while (GrPeek(map_dc,r_x[tempr->index]+tempr->dx,
|
||||
r_y[tempr->index]+tempr->dy)!=BLUE &&
|
||||
GrPeek(map_dc,r_x[tempr->index],
|
||||
r_y[tempr->index])==BLUE); //Might be reinitializing
|
||||
}
|
||||
tempr=tempr1;
|
||||
}
|
||||
@@ -192,8 +197,8 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
static Bool left=TRUE;
|
||||
F64 t;
|
||||
I64 i,
|
||||
cx=(MAP_WIDTH -task->pix_width)/2,
|
||||
cy=(MAP_HEIGHT-task->pix_height)/2;
|
||||
cx=(MAP_WIDTH -task->pix_width)/2,
|
||||
cy=(MAP_HEIGHT-task->pix_height)/2;
|
||||
if (task->scroll_x+cx<0)
|
||||
task->scroll_x=-cx;
|
||||
if (task->scroll_x+cx>MAP_WIDTH-task->pix_width)
|
||||
@@ -212,7 +217,7 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
if (!a[i].dead) {
|
||||
if (a[i].dx<0) {
|
||||
dc->flags|=DCF_JUST_MIRROR|DCF_SYMMETRY;
|
||||
GrSetSymmetry(dc,a[i].x.i32[1]-cx,0,a[i].x.i32[1]-cx,1);
|
||||
DCSymmetrySet(dc,a[i].x.i32[1]-cx,0,a[i].x.i32[1]-cx,1);
|
||||
}
|
||||
Sprite3(dc,a[i].x.i32[1]-cx,a[i].y.i32[1]-cy,0,a[i].ge->img);
|
||||
dc->flags&=~(DCF_JUST_MIRROR|DCF_SYMMETRY);
|
||||
@@ -224,11 +229,12 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
left=TRUE;
|
||||
if (left) {
|
||||
dc->flags|=DCF_JUST_MIRROR|DCF_SYMMETRY;
|
||||
GrSetSymmetry(dc,ip.pos.x-task->pix_left-task->scroll_x,0,ip.pos.x-task->pix_left-task->scroll_x,1);
|
||||
DCSymmetrySet(dc,ip.pos.x-task->pix_left-task->scroll_x,0,
|
||||
ip.pos.x-task->pix_left-task->scroll_x,1);
|
||||
}
|
||||
Sprite3(dc,
|
||||
ip.pos.x-task->pix_left-task->scroll_x,
|
||||
ip.pos.y-task->pix_top -task->scroll_y,0,rh_sprite[GE_HORSE].img);
|
||||
ip.pos.x-task->pix_left-task->scroll_x,
|
||||
ip.pos.y-task->pix_top -task->scroll_y,0,rh_sprite[GE_HORSE].img);
|
||||
dc->flags&=~(DCF_JUST_MIRROR|DCF_SYMMETRY);
|
||||
last_pos_x=ip.pos.x;
|
||||
|
||||
@@ -237,14 +243,15 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
t=tf-t0;
|
||||
if (Blink)
|
||||
GrPrint(dc,(task->pix_width-FONT_WIDTH*14)>>1-task->scroll_x,
|
||||
(task->pix_height-FONT_HEIGHT)>>1-task->scroll_y,
|
||||
"Game Completed");
|
||||
(task->pix_height-FONT_HEIGHT)>>1-task->scroll_y,
|
||||
"Game Completed");
|
||||
} else {
|
||||
dc->color=BLACK;
|
||||
t=tS-t0;
|
||||
}
|
||||
GrPrint(dc,-task->scroll_x,-task->scroll_y,"Outside:%03d Time:%7.2fs Best:%7.2fs",
|
||||
outside_cnt,t,best_score);
|
||||
GrPrint(dc,-task->scroll_x,-task->scroll_y,
|
||||
"Outside:%03d Time:%7.2fs Best:%7.2fs",
|
||||
outside_cnt,t,best_score);
|
||||
}
|
||||
|
||||
U0 BuddySelect(I64 i)
|
||||
@@ -253,8 +260,8 @@ U0 BuddySelect(I64 i)
|
||||
for (b=0;b<NUM_ANIMALS;b++) {
|
||||
if (b!=i && !a[b].dead) {
|
||||
score=RandU32%(512*512)+
|
||||
SqrI64(a[b].x.i32[1]-a[i].x.i32[1])+
|
||||
SqrI64(a[b].y.i32[1]-a[i].y.i32[1]);
|
||||
SqrI64(a[b].x.i32[1]-a[i].x.i32[1])+
|
||||
SqrI64(a[b].y.i32[1]-a[i].y.i32[1]);
|
||||
if (score<best_score) {
|
||||
best_score=score;
|
||||
best_b=b;
|
||||
@@ -267,13 +274,13 @@ U0 BuddySelect(I64 i)
|
||||
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;
|
||||
my_outside_cnt;
|
||||
F64 f,d,dx,dy,s,stress;
|
||||
Animal *tempa,*tempa1;
|
||||
while (TRUE) {
|
||||
max_speed=ClampU64(max_speed,MAX_U32/3,200*MAX_U32);
|
||||
cx=(MAP_WIDTH -parent->pix_width)/2,
|
||||
cy=(MAP_HEIGHT-parent->pix_height)/2;
|
||||
cy=(MAP_HEIGHT-parent->pix_height)/2;
|
||||
cursor_x=ip.pos.x+cx-parent->pix_left-parent->scroll_x;
|
||||
cursor_y=ip.pos.y+cy-parent->pix_top -parent->scroll_y;
|
||||
cnt=0;stress=0;
|
||||
@@ -293,14 +300,14 @@ U0 AnimateTask(CTask *parent)
|
||||
tempa->dy+=f*dy;
|
||||
}
|
||||
|
||||
//Reselect buddy about every NUM_ANIMALS*10ms=5.12 seconds
|
||||
//Reselect buddy about every NUM_ANIMALS*10ms=5.12 seconds
|
||||
tempa1=&a[tempa->buddy];
|
||||
if (tempa1->dead || i==updates%NUM_ANIMALS) {
|
||||
BuddySelect(i);
|
||||
tempa1=&a[tempa->buddy];
|
||||
}
|
||||
|
||||
//Move toward buddy
|
||||
//Move toward buddy
|
||||
ddx=tempa->x.i32[1]-tempa1->x.i32[1];
|
||||
ddy=tempa->y.i32[1]-tempa1->y.i32[1];
|
||||
if (dd=SqrI64(ddx)+SqrI64(ddy)) {
|
||||
@@ -314,31 +321,34 @@ U0 AnimateTask(CTask *parent)
|
||||
tempa->dy+=f*dy;
|
||||
}
|
||||
|
||||
//Make velocity similar to buddy
|
||||
//Make velocity similar to buddy
|
||||
tempa->dx+=0.1*(tempa1->dx-tempa->dx);
|
||||
tempa->dy+=0.1*(tempa1->dy-tempa->dy);
|
||||
|
||||
//Add random movement, limit speed and dampen speed
|
||||
//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);
|
||||
|
||||
//Slow in river
|
||||
//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,(tempa->x+tempa->dx)>>32,(tempa->y+tempa->dy)>>32)!=LTGRAY) {
|
||||
if (GrPeek(map_dc,(tempa->x+tempa->dx)>>32,(tempa->y+tempa->dy)>>32)
|
||||
!=LTGRAY) {
|
||||
tempa->x+=tempa->dx;
|
||||
tempa->y+=tempa->dy;
|
||||
}
|
||||
|
||||
//Keep on map
|
||||
if (!(MAP_BORDER-tempa->ge->min_x<=tempa->x.i32[1]<MAP_WIDTH-MAP_BORDER-tempa->ge->max_x)) {
|
||||
//Keep on map
|
||||
if (!(MAP_BORDER-tempa->ge->min_x
|
||||
<=tempa->x.i32[1]<MAP_WIDTH-MAP_BORDER-tempa->ge->max_x)) {
|
||||
tempa->x -=tempa->dx;
|
||||
tempa->dx=-tempa->dx;
|
||||
}
|
||||
if (!(MAP_BORDER-tempa->ge->min_y<=tempa->y.i32[1]<MAP_HEIGHT-MAP_BORDER-tempa->ge->max_y)) {
|
||||
if (!(MAP_BORDER-tempa->ge->min_y
|
||||
<=tempa->y.i32[1]<MAP_HEIGHT-MAP_BORDER-tempa->ge->max_y)) {
|
||||
tempa->y -=tempa->dy;
|
||||
tempa->dy=-tempa->dy;
|
||||
}
|
||||
@@ -384,10 +394,10 @@ U0 SongTask(I64)
|
||||
Fs->task_end_cb=&SndTaskEndCB;
|
||||
MusicSettingsRst;
|
||||
while (TRUE) {
|
||||
Play("3qC2etG3DCBDCECFqFCsADADqB");
|
||||
Play("C2etG3DCBDCECFqFCsADADqB");
|
||||
Play("2sG3A2G3AqG2etG3GDeBBqBFeBAqE");
|
||||
Play("2sG3A2G3AqG2etG3GDeBBqBFeBAqE");
|
||||
Play("3qC2etG3DCBDCECFqFCsADADqB");
|
||||
Play("C2etG3DCBDCECFqFCsADADqB");
|
||||
Play("2sG3A2G3AqG2etG3GDeBBqBFeBAqE");
|
||||
Play("2sG3A2G3AqG2etG3GDeBBqBFeBAqE");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,7 +426,8 @@ U0 ReInit()
|
||||
|
||||
map_dc->pen_width=MAP_BORDER;
|
||||
map_dc->color=RED;
|
||||
GrBorder(map_dc,MAP_BORDER/2,MAP_BORDER/2,MAP_WIDTH-(MAP_BORDER+1)/2,MAP_HEIGHT-(MAP_BORDER+1)/2);
|
||||
GrBorder(map_dc,MAP_BORDER/2,MAP_BORDER/2,
|
||||
MAP_WIDTH-(MAP_BORDER+1)/2,MAP_HEIGHT-(MAP_BORDER+1)/2);
|
||||
|
||||
for (i=river_lo;i<=river_hi;i++)
|
||||
RiverDropsNext(Fs);
|
||||
@@ -475,19 +486,20 @@ U0 RawHide()
|
||||
"upper-left corner if you scroll.\n\n"
|
||||
"Scroll with $$GREEN$${CTRL-Left Grab}$$FG$$.\n");
|
||||
MenuPush(
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Restart(,'\n');"
|
||||
"}"
|
||||
);
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Restart(,'\n');"
|
||||
"}"
|
||||
);
|
||||
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
|
||||
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS-WIF_SELF_BORDER-WIF_SELF_GRAB_SCROLL-WIF_FOCUS_TASK_MENU;
|
||||
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS
|
||||
-WIF_SELF_BORDER-WIF_SELF_GRAB_SCROLL-WIF_FOCUS_TASK_MENU;
|
||||
WinMax;
|
||||
AutoComplete;
|
||||
Preempt(OFF);
|
||||
Preempt;
|
||||
Init;
|
||||
Fs->animate_task=Spawn(&AnimateTask,Fs,"Animate",,Fs);
|
||||
DocCursor;
|
||||
@@ -495,7 +507,8 @@ U0 RawHide()
|
||||
Fs->draw_it=&DrawIt;
|
||||
try {
|
||||
while (TRUE) {
|
||||
msg_code=GetMsg(&a1,&a2,1<<MSG_KEY_DOWN+1<<MSG_IP_L_DOWN+1<<MSG_IP_R_DOWN);
|
||||
msg_code=GetMsg(&a1,&a2,
|
||||
1<<MSG_KEY_DOWN+1<<MSG_IP_L_DOWN+1<<MSG_IP_R_DOWN);
|
||||
switch (msg_code) {
|
||||
case MSG_IP_L_DOWN: //Doesn't do anything, yet.
|
||||
break;
|
||||
@@ -520,7 +533,7 @@ rh_done:
|
||||
MenuPop;
|
||||
SettingsPop;
|
||||
CleanUp;
|
||||
AcctRegWriteBranch("TempleOS/RawHide","F64 best_score=%5.4f;\n",best_score);
|
||||
RegWriteBranch("TempleOS/RawHide","F64 best_score=%5.4f;\n",best_score);
|
||||
}
|
||||
|
||||
RawHide;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -17,13 +17,13 @@ U0 StadiumGen()
|
||||
gr.fp_final_screen_update=NULL;
|
||||
|
||||
WinMgrSync(2,TRUE);
|
||||
dc2=DCCaptureScreen;
|
||||
dc2=DCScreenCapture;
|
||||
dc=DCExtract(dc2,0,FONT_HEIGHT,GR_WIDTH,GR_HEIGHT);
|
||||
DCDel(dc2);
|
||||
|
||||
GRAWrite("StadiumBG",dc);
|
||||
GRAWrite("StadiumBG",dc,DCSF_COMPRESSED|DCSF_PALETTE_GET);
|
||||
DCDel(dc);
|
||||
|
||||
|
||||
DocCursor(ON);
|
||||
gr.fp_final_screen_update=fp_old_update;
|
||||
DocClear;
|
||||
|
||||
Binary file not shown.
@@ -36,7 +36,7 @@ U0 DrawBoard(I64 player)
|
||||
|
||||
}
|
||||
//ip.pos.x,ip.pos.y are input pointer (mouse) x,y.
|
||||
//ip.lb is mouse left button
|
||||
//ip.lb is mouse left button
|
||||
if (player==1)
|
||||
DrawX(dc,ip.pos.x-Fs->pix_left,ip.pos.y-Fs->pix_top);
|
||||
else
|
||||
|
||||
+46
-33
@@ -1,7 +1,19 @@
|
||||
#define BORDER 16
|
||||
#define NUM_UNITS 64
|
||||
#define CIRCLE_RAD 8
|
||||
#define MOVE_CIRCLES 5
|
||||
U0 InitDefines()
|
||||
{
|
||||
I64 w=GR_WIDTH,h=GR_HEIGHT-FONT_HEIGHT,cols,rows,
|
||||
size=PopUpRangeI64(1,9,,"Size\n"),rad=16-size;
|
||||
if (size<0) throw;
|
||||
DefinePrint("NUM_UNITS","%d",4096/SqrI64(rad)&~1);
|
||||
DefinePrint("CIRCLE_RAD","%d",rad);
|
||||
DefinePrint("MOVE_CIRCLES","%d",40/rad);
|
||||
|
||||
cols=(w-8-rad)/(2*rad)&~1-1;
|
||||
DefinePrint("BORDER_X","%d",(w+rad-cols*2*rad)/2);
|
||||
|
||||
rows=(h-8)/(2*rad)&~1;
|
||||
DefinePrint("BORDER_Y","%d",(h-rows*2*rad)/2);
|
||||
|
||||
} InitDefines;
|
||||
|
||||
class Unit
|
||||
{
|
||||
@@ -16,11 +28,11 @@ Bool show_start;
|
||||
U0 S2Circle(I64 *_x,I64 *_y)
|
||||
{
|
||||
I64 i,j;
|
||||
j=(*_y-BORDER)/(CIRCLE_RAD*2);
|
||||
j=(*_y-BORDER_Y)/(CIRCLE_RAD*2);
|
||||
if (j&1)
|
||||
i=(*_x-CIRCLE_RAD-BORDER)/(CIRCLE_RAD*2);
|
||||
i=(*_x-CIRCLE_RAD-BORDER_X)/(CIRCLE_RAD*2);
|
||||
else
|
||||
i=(*_x-BORDER)/(CIRCLE_RAD*2);
|
||||
i=(*_x-BORDER_X)/(CIRCLE_RAD*2);
|
||||
*_y=j;
|
||||
*_x=i;
|
||||
}
|
||||
@@ -28,8 +40,8 @@ U0 S2Circle(I64 *_x,I64 *_y)
|
||||
U0 Circle2S(I64 *_x,I64 *_y)
|
||||
{
|
||||
I64 j=*_y,i=*_x;
|
||||
*_y=j*CIRCLE_RAD*2+CIRCLE_RAD+BORDER;
|
||||
*_x=i*CIRCLE_RAD*2+CIRCLE_RAD+BORDER;
|
||||
*_y=j*CIRCLE_RAD*2+CIRCLE_RAD+BORDER_Y;
|
||||
*_x=i*CIRCLE_RAD*2+CIRCLE_RAD+BORDER_X;
|
||||
if (j&1) *_x+=CIRCLE_RAD;
|
||||
}
|
||||
|
||||
@@ -80,7 +92,7 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
if ((num_alive[0]==1 || num_alive[1]==1) && Blink(4)) {
|
||||
dc->color=BLACK;
|
||||
GrPrint(dc,(task->pix_width-FONT_WIDTH*9)>>1,
|
||||
(task->pix_height-FONT_HEIGHT)>>1,"Game Over");
|
||||
(task->pix_height-FONT_HEIGHT)>>1,"Game Over");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +129,7 @@ U0 CheckForKills(I64 x1,I64 y1,I64 player)
|
||||
found=FALSE;
|
||||
for (j=0;j<NUM_UNITS;j++)
|
||||
if (u[j].alive && u[j].player!=player && !u[j].king &&
|
||||
!u[u[j].link].alive) {
|
||||
!u[u[j].link].alive) {
|
||||
found=TRUE;
|
||||
u[j].alive=FALSE;
|
||||
Snd(500);Sleep(100);Snd(0);Sleep(25);
|
||||
@@ -171,14 +183,14 @@ CDC *DrawHexMap(I64 *_w,I64 *_h)
|
||||
{
|
||||
CDC *dc=DCNew(*_w,*_h);
|
||||
I64 i,j,x,y;
|
||||
*_w=(dc->width-BORDER*2-CIRCLE_RAD)/(CIRCLE_RAD*2);
|
||||
*_h=(dc->height-BORDER*2)/(CIRCLE_RAD*2);
|
||||
*_w=(dc->width-BORDER_X*2-CIRCLE_RAD)/(CIRCLE_RAD*2);
|
||||
*_h=(dc->height-BORDER_Y*2)/(CIRCLE_RAD*2);
|
||||
DCFill(dc,WHITE);
|
||||
dc->color=LTGRAY;
|
||||
for (j=0;j<*_h;j++) {
|
||||
for (i=0;i<*_w;i++) {
|
||||
y=j*CIRCLE_RAD*2+BORDER+CIRCLE_RAD;
|
||||
x=i*CIRCLE_RAD*2+BORDER+CIRCLE_RAD;
|
||||
x=i*CIRCLE_RAD*2+BORDER_X+CIRCLE_RAD;
|
||||
y=j*CIRCLE_RAD*2+BORDER_Y+CIRCLE_RAD;
|
||||
if (j&1) x+=CIRCLE_RAD;
|
||||
S2W(&x,&y);
|
||||
GrCircle(dc,x,y,CIRCLE_RAD);
|
||||
@@ -191,30 +203,31 @@ CDC *DrawHexMap(I64 *_w,I64 *_h)
|
||||
|
||||
U0 Init()
|
||||
{
|
||||
I64 i,j,dd,best_dd,best,w=Fs->pix_width,h=Fs->pix_height;
|
||||
I64 i,j,j1,j2,dd,best_dd,best,w=Fs->pix_width,h=Fs->pix_height;
|
||||
map_dc=DrawHexMap(&w,&h);
|
||||
cur_player=0;
|
||||
for (i=0;i<NUM_UNITS/2;i++) {
|
||||
u[i].num=i;
|
||||
u[i+NUM_UNITS/2].num=i+NUM_UNITS/2;
|
||||
|
||||
u[i].y=RandU32%h;
|
||||
u[i].y=FloorI64(RandU32%h,CIRCLE_RAD*2)+CIRCLE_RAD;
|
||||
u[i+NUM_UNITS/2].y=h-1-u[i].y;
|
||||
j=u[i].y/(CIRCLE_RAD*2);
|
||||
u[i].y+=BORDER;
|
||||
u[i+NUM_UNITS/2].y+=BORDER;
|
||||
j1=u[i].y/(CIRCLE_RAD*2);
|
||||
j2=u[i+NUM_UNITS/2].y/(CIRCLE_RAD*2);
|
||||
u[i].y+=BORDER_Y;
|
||||
u[i+NUM_UNITS/2].y+=BORDER_Y;
|
||||
|
||||
if (!i)
|
||||
u[i].x=CIRCLE_RAD;
|
||||
else
|
||||
u[i].x=RandU32%((w-2*BORDER-CIRCLE_RAD*2)/2)+CIRCLE_RAD*2;
|
||||
u[i].x=FloorI64(RandU32%((w-CIRCLE_RAD*2*2)/2),CIRCLE_RAD*2)+CIRCLE_RAD;
|
||||
u[i+NUM_UNITS/2].x=w-1-u[i].x;
|
||||
if (j&1) {
|
||||
if (j1&1)
|
||||
u[i].x+=CIRCLE_RAD;
|
||||
if (j2&1)
|
||||
u[i+NUM_UNITS/2].x+=CIRCLE_RAD;
|
||||
}
|
||||
u[i].x+=BORDER;
|
||||
u[i+NUM_UNITS/2].x+=BORDER;
|
||||
u[i].x+=BORDER_X;
|
||||
u[i+NUM_UNITS/2].x+=BORDER_X;
|
||||
|
||||
S2W(&u[i].x,&u[i].y);
|
||||
S2W(&u[i+NUM_UNITS/2].x,&u[i+NUM_UNITS/2].y);
|
||||
@@ -243,7 +256,7 @@ U0 Init()
|
||||
for (j=0;j<NUM_UNITS/2;j++) {
|
||||
if (i!=j) {
|
||||
dd=SqrI64(u[i].x-u[j].x)+SqrI64(u[i].y-u[j].y);
|
||||
if (u[j].x<u[i].x && dd<best_dd) {
|
||||
if (u[j].x<=u[i].x && dd<best_dd) {
|
||||
best_dd=dd;
|
||||
best=j;
|
||||
}
|
||||
@@ -268,7 +281,7 @@ U0 TreeCheckers()
|
||||
Unit *tempu;
|
||||
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
Preempt(OFF);
|
||||
Preempt;
|
||||
MenuPush(
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
@@ -281,13 +294,12 @@ U0 TreeCheckers()
|
||||
WinMax;
|
||||
WinBorder;
|
||||
AutoComplete;
|
||||
Preempt(OFF);
|
||||
Preempt;
|
||||
DocCursor;
|
||||
DocClear;
|
||||
PopUpOk("Step on the link mid points.\n"
|
||||
"Make a computer player or\n"
|
||||
"modify the rules.\n");
|
||||
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS-WIF_SELF_BORDER-WIF_FOCUS_TASK_MENU;
|
||||
PopUpOk("Step on the link mid points.\n");
|
||||
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS
|
||||
-WIF_SELF_BORDER-WIF_FOCUS_TASK_MENU;
|
||||
try {
|
||||
cn_start:
|
||||
Init;
|
||||
@@ -295,7 +307,8 @@ cn_start:
|
||||
show_start=FALSE;
|
||||
Fs->draw_it=&DrawIt;
|
||||
while (TRUE) {
|
||||
msg_code=GetMsg(&a1,&a2,1<<MSG_KEY_DOWN+1<<MSG_IP_L_DOWN+1<<MSG_IP_L_UP+1<<MSG_IP_MOVE);
|
||||
msg_code=GetMsg(&a1,&a2,
|
||||
1<<MSG_KEY_DOWN+1<<MSG_IP_L_DOWN+1<<MSG_IP_L_UP+1<<MSG_IP_MOVE);
|
||||
switch (msg_code) {
|
||||
case MSG_KEY_DOWN:
|
||||
switch (a1) {
|
||||
|
||||
+48
-42
@@ -87,8 +87,8 @@
|
||||
|
||||
|
||||
|
||||
AcctRegSetDftEntry("TempleOS/Varoom","F64 best_score=9999;\n");
|
||||
AcctRegExeBranch("TempleOS/Varoom");
|
||||
RegSetDftEntry("TempleOS/Varoom","F64 best_score=9999;\n");
|
||||
RegExeBranch("TempleOS/Varoom");
|
||||
|
||||
F64 distance,t0,tf;
|
||||
Bool game_over;
|
||||
@@ -164,17 +164,17 @@ U0 InitTrack()
|
||||
I64 i;
|
||||
for (i=0;i<SLICES;i++) {
|
||||
InitTrackPoly(tempt++,DKGRAY,TRACK_INNER,TRACK_OUTER,
|
||||
i*2*ã/SLICES,(i+1)*2*ã/SLICES);
|
||||
i*2*ã/SLICES,(i+1)*2*ã/SLICES);
|
||||
if (i&1) {
|
||||
InitTrackPoly(tempt++,RED,TRACK_INNER-SHOULDER,TRACK_INNER,
|
||||
i*2*ã/SLICES,(i+1)*2*ã/SLICES);
|
||||
i*2*ã/SLICES,(i+1)*2*ã/SLICES);
|
||||
InitTrackPoly(tempt++,WHITE,TRACK_OUTER,TRACK_OUTER+SHOULDER,
|
||||
i*2*ã/SLICES,(i+1)*2*ã/SLICES);
|
||||
i*2*ã/SLICES,(i+1)*2*ã/SLICES);
|
||||
} else {
|
||||
InitTrackPoly(tempt++,WHITE,TRACK_INNER-SHOULDER,TRACK_INNER,
|
||||
i*2*ã/SLICES,(i+1)*2*ã/SLICES);
|
||||
i*2*ã/SLICES,(i+1)*2*ã/SLICES);
|
||||
InitTrackPoly(tempt++,RED,TRACK_OUTER,TRACK_OUTER+SHOULDER,
|
||||
i*2*ã/SLICES,(i+1)*2*ã/SLICES);
|
||||
i*2*ã/SLICES,(i+1)*2*ã/SLICES);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -187,9 +187,9 @@ U0 MPUpdateWin(CDC *dc2)
|
||||
{
|
||||
CTask *task=dc2->win_task;
|
||||
I64 i,j,x,y,z,lo,hi,
|
||||
w=task->pix_width,
|
||||
h=task->pix_height,r[16],
|
||||
cx=w>>1;
|
||||
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;
|
||||
Bool draw;
|
||||
@@ -197,9 +197,9 @@ U0 MPUpdateWin(CDC *dc2)
|
||||
TrackPoly *tempt;
|
||||
CDC *dc=DCAlias(gr.dc2,task);
|
||||
|
||||
GrIdentEqu(r);
|
||||
GrRotYEqu(r,ã-c[0].é);
|
||||
GrRotXEqu(r,75*ã/180-dip_é);
|
||||
Mat4x4IdentEqu(r);
|
||||
Mat4x4RotY(r,ã-c[0].é);
|
||||
Mat4x4RotX(r,75*ã/180-dip_é);
|
||||
|
||||
dc->depth_buf=dc2->depth_buf;
|
||||
|
||||
@@ -210,8 +210,10 @@ U0 MPUpdateWin(CDC *dc2)
|
||||
dc->color=tempt->c;
|
||||
draw=TRUE;
|
||||
for (j=0;j<4;j++) {
|
||||
x=tempt->p[j].x-c[0].p.x; y=tempt->p[j].y-c[0].p.y; z=tempt->p[j].z-c[0].p.z;
|
||||
GrRot(r,&x,&y,&z);
|
||||
x=tempt->p[j].x-c[0].p.x;
|
||||
y=tempt->p[j].y-c[0].p.y;
|
||||
z=tempt->p[j].z-c[0].p.z;
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
s=100.0/(AbsI64(z)+50);
|
||||
poly[j].y=s*y+h;
|
||||
if (z<-200 || !(-h<poly[j].y<2*h)) {
|
||||
@@ -228,15 +230,15 @@ U0 MPUpdateWin(CDC *dc2)
|
||||
dc->flags|=DCF_TRANSFORMATION;
|
||||
for (i=Gs->num;i<NUM_BUSHES;i+=mp_cnt) {
|
||||
x=b[i].p.x-c[0].p.x; y=b[i].p.y-c[0].p.y; z=b[i].p.z-c[0].p.z;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
if (z>0) {
|
||||
s=100.0/(AbsI64(z)+50);
|
||||
GrIdentEqu(dc->r);
|
||||
GrScaleEqu(dc->r,s*2);
|
||||
GrSetRotMat(dc,dc->r);
|
||||
Mat4x4IdentEqu(dc->r);
|
||||
Mat4x4Scale(dc->r,s*2);
|
||||
DCMat4x4Set(dc,dc->r);
|
||||
if (b[i].sym) {
|
||||
dc->flags|=DCF_SYMMETRY|DCF_JUST_MIRROR;
|
||||
GrSetSymmetry(dc,s*x+cx,s*y+h,s*x+cx,s*y+h+10);
|
||||
DCSymmetrySet(dc,s*x+cx,s*y+h,s*x+cx,s*y+h+10);
|
||||
}
|
||||
Sprite3B(dc,s*x+cx,s*y+h,z+GR_Z_ALL,b[i].img);
|
||||
dc->flags&=~(DCF_SYMMETRY|DCF_JUST_MIRROR);
|
||||
@@ -245,14 +247,14 @@ 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;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
if (z>0) {
|
||||
s=100.0/(AbsI64(z)+50);
|
||||
GrIdentEqu(dc->r);
|
||||
GrScaleEqu(dc->r,s*2);
|
||||
GrRotXEqu(dc->r,Dipé(tempc->p.x,tempc->p.z,-tempc->é));
|
||||
GrRotYEqu(dc->r,tempc->é-c[0].é);
|
||||
GrSetRotMat(dc,dc->r);
|
||||
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].é);
|
||||
DCMat4x4Set(dc,dc->r);
|
||||
Sprite3B(dc,s*x+cx,s*y+h,z+GR_Z_ALL,tempc->img);
|
||||
}
|
||||
}
|
||||
@@ -264,7 +266,7 @@ U0 MPUpdateWin(CDC *dc2)
|
||||
U0 VRTransform(CDC *dc,I64 *x,I64 *y,I64 *z)
|
||||
{
|
||||
I64 zz;
|
||||
GrRot(dc->r,x,y,z);
|
||||
Mat4x4MulXYZ(dc->r,x,y,z);
|
||||
zz=400+*z;
|
||||
if (zz<1) zz=1;
|
||||
*x=400* *x/zz;
|
||||
@@ -285,15 +287,15 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
dc->color=LTCYAN;
|
||||
GrRect(dc,0,0,w,HORIZON_DIP*Sin(dip_é)+FONT_HEIGHT*4.5);
|
||||
|
||||
GrIdentEqu(r);
|
||||
GrRotYEqu(r,ã-c[0].é);
|
||||
GrRotXEqu(r,75*ã/180-dip_é);
|
||||
Mat4x4IdentEqu(r);
|
||||
Mat4x4RotY(r,ã-c[0].é);
|
||||
Mat4x4RotX(r,75*ã/180-dip_é);
|
||||
|
||||
DCAllocDepthBuf(dc);
|
||||
DCDepthBufAlloc(dc);
|
||||
|
||||
//Sun
|
||||
x=c[0].p.x; y=0; z=1000000-c[0].p.z;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
s=100.0/(AbsI64(z)+50);
|
||||
if (y<0) {
|
||||
dc->color=BROWN;
|
||||
@@ -314,9 +316,9 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
è=0.5;
|
||||
else
|
||||
è=0;
|
||||
GrIdentEqu(r);
|
||||
GrRotYEqu(r,è);
|
||||
GrRotXEqu(r,0.4-8*dip_é); //Made this up
|
||||
Mat4x4IdentEqu(r);
|
||||
Mat4x4RotY(r,è);
|
||||
Mat4x4RotX(r,0.4-8*dip_é); //Made this up
|
||||
dc->transform=&VRTransform;
|
||||
dc->x=task->pix_width>>1;
|
||||
dc->y=task->pix_height-150;
|
||||
@@ -328,7 +330,8 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
GrRect(dc,w-64,h-64,64,64);
|
||||
dc->color=LTGREEN;
|
||||
for (i=0;i<NUM_BUSHES;i++)
|
||||
GrPlot(dc,w-64+64*(0x5000-b[i].p.x)/0xA000,h-64*(-b[i].p.z+0x5000)/0xA000);
|
||||
GrPlot(dc,w-64+64*(0x5000-b[i].p.x)/0xA000,
|
||||
h-64*(-b[i].p.z+0x5000)/0xA000);
|
||||
|
||||
dc->pen_width=2;
|
||||
for (i=0;i<NUM_CARS;i++) {
|
||||
@@ -336,7 +339,8 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
dc->color=LTPURPLE;
|
||||
else
|
||||
dc->color=LTCYAN;
|
||||
GrPlot3(dc,w-64+64*(0x5000-c[i].p.x)/0xA000,h-64*(-c[i].p.z+0x5000)/0xA000,0);
|
||||
GrPlot3(dc,w-64+64*(0x5000-c[i].p.x)/0xA000,
|
||||
h-64*(-c[i].p.z+0x5000)/0xA000,0);
|
||||
}
|
||||
|
||||
if (game_over) {
|
||||
@@ -354,7 +358,8 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
s=tS-t0;
|
||||
dc->color=BLACK;
|
||||
GrPrint(dc,0,0,"é:%0.1f %0.1f%% Time:%0.2f Best:%0.2f",
|
||||
180+180/ã*Arg(c[0].p.x,c[0].p.z),100.0*distance/(2*ã*TRACK_INNER),s,best_score);
|
||||
180+180/ã*Arg(c[0].p.x,c[0].p.z),
|
||||
100.0*distance/(2*ã*TRACK_INNER),s,best_score);
|
||||
}
|
||||
|
||||
U0 AnimateTask(I64)
|
||||
@@ -417,7 +422,7 @@ U0 Init()
|
||||
tempb->p.x=RandU32&0x7FFF-0x4000;
|
||||
tempb->p.z=RandU32&0x7FFF-0x4000;
|
||||
} while (TRACK_INNER-SHOULDER<=
|
||||
Sqrt(SqrI64(tempb->p.x)+SqrI64(tempb->p.z))<=TRACK_OUTER+SHOULDER);
|
||||
Sqrt(SqrI64(tempb->p.x)+SqrI64(tempb->p.z))<=TRACK_OUTER+SHOULDER);
|
||||
tempb->p.y=DipY(tempb->p.x,tempb->p.z);
|
||||
tempb->sym=RandU16&1;
|
||||
tempb->img=imgs[i&7];
|
||||
@@ -462,11 +467,12 @@ U0 Varoom()
|
||||
SettingsPush(,TSF_SAME_SONG); //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
try {
|
||||
Fs->text_attr=YELLOW<<4+BLUE;
|
||||
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS-WIF_SELF_GRAB_SCROLL-WIF_FOCUS_TASK_MENU;
|
||||
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS
|
||||
-WIF_SELF_GRAB_SCROLL-WIF_FOCUS_TASK_MENU;
|
||||
AutoComplete;
|
||||
WinMax;
|
||||
WinBorder;
|
||||
Preempt(OFF);
|
||||
Preempt;
|
||||
Init;
|
||||
DocCursor;
|
||||
DocClear;
|
||||
@@ -502,7 +508,7 @@ vr_done: //Don't goto out of try
|
||||
Fs->catch_except=TRUE;
|
||||
SettingsPop(,TSF_SAME_SONG);
|
||||
MenuPop;
|
||||
AcctRegWriteBranch("TempleOS/Varoom","F64 best_score=%5.4f;\n",best_score);
|
||||
RegWriteBranch("TempleOS/Varoom","F64 best_score=%5.4f;\n",best_score);
|
||||
}
|
||||
|
||||
Varoom;
|
||||
|
||||
+25
-21
@@ -1,5 +1,5 @@
|
||||
AcctRegSetDftEntry("TempleOS/Wenceslas","F64 best_score=9999;\n");
|
||||
AcctRegExeBranch("TempleOS/Wenceslas");
|
||||
RegSetDftEntry("TempleOS/Wenceslas","F64 best_score=9999;\n");
|
||||
RegExeBranch("TempleOS/Wenceslas");
|
||||
|
||||
#define BORDER 5
|
||||
#define KING_STEP 6
|
||||
@@ -8,7 +8,8 @@ AcctRegExeBranch("TempleOS/Wenceslas");
|
||||
|
||||
|
||||
|
||||
$SP,"<1>",BI=1$
|
||||
$SP,"<1>",BI=1$ //See $MA-X+PU,"::/Apps/GrModels",LM="Cd(\"::/Apps/GrModels\");Dir;View;\n"$ for making 3D men.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -127,7 +128,7 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
Step *tempst;
|
||||
Peasant *tempp;
|
||||
F64 tt;
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
Bool old_preempt=Preempt;
|
||||
|
||||
dc->pen_width=1;
|
||||
for (i=0;i<NUM_TREES;i++) {
|
||||
@@ -171,14 +172,14 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
tempst=tempst->next;
|
||||
}
|
||||
|
||||
DCAllocDepthBuf(dc);
|
||||
DCDepthBufAlloc(dc);
|
||||
dc->flags|=DCF_TRANSFORMATION;
|
||||
dc->pen_width=1;
|
||||
tempp=peasant_root.next;
|
||||
while (tempp!=&peasant_root) {
|
||||
GrIdentEqu(r);
|
||||
GrRotYEqu(r,tempp->é+ã/2);
|
||||
GrRotXEqu(r,ã/6);
|
||||
Mat4x4IdentEqu(r);
|
||||
Mat4x4RotY(r,tempp->é+ã/2);
|
||||
Mat4x4RotX(r,ã/6);
|
||||
if (tempp->stopped)
|
||||
SpriteMat3B(dc,tempp->x,tempp->y,GR_Z_ALL,peasant_imgs[0],r);
|
||||
else {
|
||||
@@ -193,9 +194,9 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
}
|
||||
|
||||
dc->pen_width=1;
|
||||
GrIdentEqu(r);
|
||||
GrRotYEqu(r,king_é+ã/2);
|
||||
GrRotXEqu(r,ã/6);
|
||||
Mat4x4IdentEqu(r);
|
||||
Mat4x4RotY(r,king_é+ã/2);
|
||||
Mat4x4RotX(r,ã/6);
|
||||
if (tS>king_timeout)
|
||||
SpriteMat3B(dc,king_x,king_y,GR_Z_ALL,king_imgs[0],r);
|
||||
else {
|
||||
@@ -268,7 +269,7 @@ U0 StepNew(CTask *task,I64 x,I64 y,F64
|
||||
U0 Init()
|
||||
{
|
||||
I64 i,min_x,max_x,min_y,max_y,
|
||||
w=Fs->pix_width,h=Fs->pix_height;
|
||||
w=Fs->pix_width,h=Fs->pix_height;
|
||||
Peasant *tempp;
|
||||
snow_x=0;
|
||||
snow_y=0;
|
||||
@@ -324,7 +325,7 @@ U0 Follow(CTask *,Peasant *tempp)
|
||||
F64 d,best_d=MAX_F64;
|
||||
while (temps!=&king_step_root) {
|
||||
if ((d=Sqr(temps->x-tempp->x)+Sqr(temps->y-tempp->y)) &&
|
||||
d<15*15) {
|
||||
d<15*15) {
|
||||
d+=1000*Sqr(tS-temps->t0);
|
||||
if (d<best_d) {
|
||||
best_d=d;
|
||||
@@ -378,7 +379,8 @@ U0 AnimateTask(I64)
|
||||
tempp->door_opened_t0=door_open_t0=tS;
|
||||
}
|
||||
for (i=0;i<NUM_TREES;i++) //Hang-out by fire
|
||||
if (trees[i].fire_frame_index && Sqr(tempp->x-trees[i].x)+Sqr(tempp->y-trees[i].y)<20*20) {
|
||||
if (trees[i].fire_frame_index &&
|
||||
Sqr(tempp->x-trees[i].x)+Sqr(tempp->y-trees[i].y)<20*20) {
|
||||
tempp->stopped=TRUE;
|
||||
break;
|
||||
}
|
||||
@@ -386,13 +388,15 @@ U0 AnimateTask(I64)
|
||||
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)) {
|
||||
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 (!animate_mS && animate_phase&1)
|
||||
StepNew(Fs->parent_task,tempp->x,tempp->y,tempp->é,animate_phase&2,FALSE);
|
||||
StepNew(Fs->parent_task,tempp->x,tempp->y,tempp->é,
|
||||
animate_phase&2,FALSE);
|
||||
not_stopped_cnt++;
|
||||
}
|
||||
}
|
||||
@@ -442,9 +446,9 @@ U0 SongTask(I64)
|
||||
music.tempo= 2.480;
|
||||
music.stacatto_factor= 0.902;
|
||||
while (TRUE) {
|
||||
Play("3eCCCDCC2qG3eA2G3ABqCC");
|
||||
Play("eCCCDCC2qG3eA2G3ABqCC");
|
||||
Play("eGFEDEDqCeA2G3ABqCC");
|
||||
Play("3eCCCDCC2qG3eA2G3ABqCC");
|
||||
Play("eCCCDCC2qG3eA2G3ABqCC");
|
||||
Play("eGFEDEDqCeA2G3ABqCC");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -469,7 +473,7 @@ U0 Wenceslas()
|
||||
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
WinMax;
|
||||
Preempt(OFF);
|
||||
Preempt;
|
||||
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
|
||||
|
||||
PopUpOk("
|
||||
@@ -588,7 +592,7 @@ ws_done:
|
||||
SettingsPop;
|
||||
MenuPop;
|
||||
CleanUp;
|
||||
AcctRegWriteBranch("TempleOS/Wenceslas","F64 best_score=%5.4f;\n",best_score);
|
||||
RegWriteBranch("TempleOS/Wenceslas","F64 best_score=%5.4f;\n",best_score);
|
||||
}
|
||||
|
||||
Wenceslas;
|
||||
|
||||
+18
-16
@@ -13,8 +13,8 @@ F64 collision_t;
|
||||
U0 DrawIt(CTask *task,CDC *dc)
|
||||
{
|
||||
I64 i,
|
||||
cx=task->pix_width>>1,
|
||||
cy=task->pix_height>>1;
|
||||
cx=task->pix_width>>1,
|
||||
cy=task->pix_height>>1;
|
||||
Bool snd_on=FALSE;
|
||||
dc->color=BLACK;
|
||||
GrPrint(dc,0,0,"Protect your base.");
|
||||
@@ -23,11 +23,11 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
GrRect(dc,cx-BASE_SIZE+2,cy-BASE_SIZE+2,BASE_SIZE*2-4,BASE_SIZE*2-4);
|
||||
dc->color=YELLOW;
|
||||
GrLine(dc,balls[0].x,balls[0].y,
|
||||
ip.pos.x-task->pix_left-task->scroll_x,
|
||||
ip.pos.y-task->pix_top-task->scroll_y);
|
||||
ip.pos.x-task->pix_left-task->scroll_x,
|
||||
ip.pos.y-task->pix_top-task->scroll_y);
|
||||
for (i=0;i<NUM_SPRINGS;i++)
|
||||
GrLine(dc,springs[i].end1->x,springs[i].end1->y,
|
||||
springs[i].end2->x,springs[i].end2->y);
|
||||
springs[i].end2->x,springs[i].end2->y);
|
||||
|
||||
dc->color=LTCYAN;
|
||||
GrCircle(dc,balls[0].x,balls[0].y,BALL_RADIUS);
|
||||
@@ -40,7 +40,7 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
GrCircle(dc,balls[i].x,balls[i].y,BALL_RADIUS);
|
||||
GrFloodFill(dc,balls[i].x,balls[i].y,TRUE);
|
||||
if (cx-BASE_SIZE-BALL_RADIUS<=balls[i].x<=cx+BASE_SIZE+BALL_RADIUS &&
|
||||
cy-BASE_SIZE-BALL_RADIUS<=balls[i].y<=cy+BASE_SIZE+BALL_RADIUS)
|
||||
cy-BASE_SIZE-BALL_RADIUS<=balls[i].y<=cy+BASE_SIZE+BALL_RADIUS)
|
||||
snd_on=TRUE;
|
||||
dc->color=BLACK;
|
||||
GrCircle(dc,balls[i].x,balls[i].y,BALL_RADIUS);
|
||||
@@ -58,15 +58,17 @@ U0 MyDerivative(CMathODE *ode,F64 t,COrder2D3 *,COrder2D3 *)
|
||||
CD3 p,p2;
|
||||
CTask *task=ode->win_task;
|
||||
|
||||
D3SubEqu(D3Equ(&p2,ip.pos.x-task->pix_left-task->scroll_x,ip.pos.y-task->pix_top-task->scroll_y,0),
|
||||
&balls[0].state->x);
|
||||
D3SubEqu(D3Equ(&p2,
|
||||
ip.pos.x-task->pix_left-task->scroll_x,
|
||||
ip.pos.y-task->pix_top-task->scroll_y,0),
|
||||
&balls[0].state->x);
|
||||
D3AddEqu(&balls[0].DstateDt->DxDt,D3MulEqu(&p2,STRETCH));
|
||||
|
||||
D3Equ(&p2,task->pix_width>>1,task->pix_height>>1,0);
|
||||
for (i=1;i<NUM_BALLS;i++) {
|
||||
D3Sub(&p2,&balls[i].state->x,&p);
|
||||
if (d=D3Norm(&p)) {
|
||||
//Gravity would be /(d*d*d), but that's too exponential.
|
||||
//Gravity would be /(d*d*d), but that's too exponential.
|
||||
D3MulEqu(&p,GRAVITY/d);
|
||||
D3AddEqu(&balls[i].DstateDt->DxDt,&p);
|
||||
}
|
||||
@@ -110,14 +112,14 @@ U0 Whap()
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
WinMax;
|
||||
AutoComplete;
|
||||
Preempt(OFF);
|
||||
Preempt;
|
||||
|
||||
MenuPush(
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
);
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
);
|
||||
ode->derivative=&MyDerivative;
|
||||
ode->drag_v2=0.002;
|
||||
ode->drag_v3=0.00001;
|
||||
@@ -126,7 +128,7 @@ U0 Whap()
|
||||
D3Equ(&balls[0].x,100,100,0);
|
||||
for (i=1;i<NUM_BALLS;i++)
|
||||
D3Equ(&balls[i].x,
|
||||
RandI16%500+Fs->pix_width>>1,RandI16%500+Fs->pix_height>>1,0);
|
||||
RandI16%500+Fs->pix_width>>1,RandI16%500+Fs->pix_height>>1,0);
|
||||
balls[0].x=ip.pos.x-Fs->pix_left-Fs->scroll_x;
|
||||
balls[0].y=ip.pos.y-Fs->pix_top-Fs->scroll_y;
|
||||
for (i=0;i<NUM_BALLS;i++) {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user