TempleOSCD_140715.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:46:09 +02:00
1 parent 7ef616a20e
commit 64f679eeb9
1095 files changed
+24814 -221011

No files matched your search

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+6 -14
View File
@@ -1,5 +1,4 @@
//This uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
//Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
AcctRegSetDftEntry("TempleOS/CastleFrankenstein","F64 best_score=9999;\n");
AcctRegExeBranch("TempleOS/CastleFrankenstein");
@@ -27,10 +26,8 @@ $SP,"<1>",BI=1$
#define MONSTER_SCALE 2.0
$SP,"<2>",BI=2$
@@ -78,7 +75,6 @@ $SP,"<1>",BI=1$
$SP,"<6>",BI=6$
@@ -87,8 +83,6 @@ $SP,"<1>",BI=1$
#define SCREEN_SCALE 512
#define PLOT_GRID_WIDTH 24
#define PLOT_GRID_HEIGHT 24
@@ -104,7 +98,7 @@ F64 man_
F64 t0,tf;
#define NUM_MONSTERS 16
#define NUM_MONSTERS 10
I64 monsters_left;
class Monster
{
@@ -136,7 +130,7 @@ Bool LOSPlot(U8 *,I64 x,I64 y,I64)
}
Bool LOS(I64 x1,I64 y1,I64 x2,I64 y2)
{ //Line of sight
{//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);
}
@@ -357,7 +351,6 @@ U0 DrawIt(CTask *task,CDC *dc)
dc->color=LTCYAN;
GrPlot3(dc,2*(man_xx/SCREEN_SCALE),2*(map_height-1-man_yy/SCREEN_SCALE),0);
if (tf) {
dc->color=LTRED;
if (Blink)
@@ -401,14 +394,13 @@ U0 Fire()
}
}
U0 Init()
{
I64 i,x,y;
I64 min_map_x,max_map_x,min_map_y,max_map_y;
CDC *dc;
DocClear;
"$$BG,BLACK$$"; NewLine(TEXT_ROWS/2);
"$$BG,BLACK$$%h*c",TEXT_ROWS/2,'\n';
SpriteExtents($IB,"<1>",BI=1$,&min_map_x,&max_map_x,&min_map_y,&max_map_y);
map_width =(max_map_x-min_map_x+1)/MAP_SCALE+2;
@@ -482,7 +474,7 @@ U0 CleanUp()
}
U0 SongTask(I64)
{ //Song by Terry A. Davis
{//Song by Terry A. Davis
Fs->task_end_cb=&SndTaskEndCB;
MusicSettingsRst;
while (TRUE) {
@@ -531,7 +523,7 @@ U0 CastleFrankenstein()
"Play {"
" Restart(,'\n');"
" Fwd(,,SC_CURSOR_UP);"
" Backward(,,SC_CURSOR_DOWN);"
" Bwd(,,SC_CURSOR_DOWN);"
" Left(,,SC_CURSOR_LEFT);"
" Right(,,SC_CURSOR_RIGHT);"
" Fire(,CH_SPACE);"
Binary file not shown.
+18 -21
View File
@@ -2,7 +2,6 @@
//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");
@@ -17,11 +16,9 @@ U0 SongTask(I64)
Play("hEDCARCDECR");
}
U0 DrawIt(CTask *task,CDC *)
U0 DrawIt(CTask *task,CDC *dc)
{
U8 buf[128];
SPrint(buf,"Error:%6.3f Time:%6.3f Score:%6.3f Best:%8.3f",avg_error,elapsed_time,score,best_score);
PlotWinStr(task,buf,BLACK<<4+WHITE,0,0);
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
@@ -37,7 +34,7 @@ Bool CTPlot(CDC *dc,I64 x,I64 y,I64)
U0 CircleTrace()
{
I64 msg_code,p1,p2,x1,y1;
I64 msg_code,a1,a2,x1,y1;
F64 rad,t0,total_distance;
CDC *dc=DCAlias;
@@ -48,40 +45,40 @@ U0 CircleTrace()
cx=Fs->pix_width/2;
cy=Fs->pix_height/2;
Fs->win_inhibit=WIG_TASK_DFT-WIF_FOCUS-WIF_BORDER;
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS-WIF_SELF_BORDER;
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
DCFill;
dc->color=ROP_XOR+BLACK^COLOR_TRANSPARENT;
dc->color=ROP_XOR+BLACK^TRANSPARENT;
GrCircle(dc,cx,cy,CIRCLE_RADIUS);
do {
msg_code=GetMsg(&p1,&p2,
msg_code=GetMsg(&a1,&a2,
1<<MSG_KEY_DOWN+1<<MSG_IP_L_DOWN);
switch (msg_code) {
case MSG_KEY_UP:
break;
case MSG_IP_L_DOWN:
DCFill;
dc->color=ROP_XOR+BLACK^COLOR_TRANSPARENT;
dc->color=ROP_XOR+BLACK^TRANSPARENT;
GrCircle(dc,cx,cy,CIRCLE_RADIUS);
dc->color=ROP_XOR+RED^COLOR_TRANSPARENT;
dc->color=ROP_XOR+RED^TRANSPARENT;
t0=tS;
total_distance=0.001;
total_error=0;
x1=p1; y1=p2;
x1=a1; y1=a2;
do {
msg_code=ScanMsg(&p1,&p2,
msg_code=ScanMsg(&a1,&a2,
1<<MSG_IP_L_UP+1<<MSG_IP_MOVE);
switch (msg_code) {
case MSG_IP_L_UP:
break;
case MSG_IP_MOVE:
if (x1!=p1 || y1!=p2) {
total_distance+=Sqrt(Sqr(x1-p1)+Sqr(y1-p2));
Line(dc,x1,y1,0,p1,p2,0,&CTPlot);
x1=p1;y1=p2;
if (x1!=a1 || y1!=a2) {
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
GrPlot(dc,x1,y1);
rad=Sqrt(Sqr(x1-cx)+Sqr(y1-cy));
@@ -93,7 +90,7 @@ U0 CircleTrace()
avg_error=total_error/total_distance;
score=elapsed_time*avg_error;
//This $LK,"Sleep",A="MN:Sleep"$()s until the next time the
//$LK,"Sleep",A="MN:Sleep"$()s until the next time the
//window mgr task runs. The
//window mgr calls the UpdateWin() routine
//and places msgs in the que, so there's
@@ -101,7 +98,7 @@ U0 CircleTrace()
WinMgrSync;
} while (msg_code!=MSG_IP_L_UP);
music_mute=TRUE; Sleep(200);
music.mute=TRUE; Sleep(200);
if (total_distance>0.95*CIRCUMFERENCE) {
if (score<best_score) {
Snd(2000);Sleep(50);Snd(0);Sleep(50);
@@ -114,10 +111,10 @@ U0 CircleTrace()
} else {
Snd(100);Sleep(1000);
}
Snd(0); Sleep(200); music_mute=FALSE;
Snd(0); Sleep(200); music.mute=FALSE;
break;
}
} while (msg_code!=MSG_KEY_DOWN || p1!=CH_SHIFT_ESC && p1!=CH_ESC);
} while (msg_code!=MSG_KEY_DOWN || a1!=CH_SHIFT_ESC && a1!=CH_ESC);
GetMsg(,,1<<MSG_KEY_UP);
SettingsPop;
DCFill;
Binary file not shown.
Binary file not shown.
+2 -2
View File
@@ -17,7 +17,7 @@ U0 PrintPattern(U8 *st)
I64 ch;
while (ch=*st++)
PrintDigit(ch);
NewLine;
'\n';
}
U0 Digits()
@@ -30,7 +30,7 @@ U0 Digits()
DocClear;
//Set default background and foreground
"$$WW,1$$$$BD,DKGRAY$$$$FD,WHITE$$"
"\nThis is a mem game. "
"\nThis is a memory game. "
"Try to remember the digits and enter them. "
"They are colored based on electrical "
"engineering color codes.\n";
+45 -29
View File
@@ -1,3 +1,6 @@
AcctRegSetDftEntry("TempleOS/DunGen","F64 best_score=9999;\n");
AcctRegExeBranch("TempleOS/DunGen");
//Set snap to 4 and width to 4
//if you edit this map.
@@ -20,26 +23,19 @@ $SP,"<2>",BI=2$
$SP,"<3>",BI=3$
$SP,"<4>",BI=4$ //This is a template you can copy and use to make a tile.
$SP,"<5>",BI=5$
$SP,"<6>",BI=6$
$SP,"<7>",BI=7$
$SP,"<8>",BI=8$
$SP,"<9>",BI=9$
@@ -48,10 +44,7 @@ $SP,"<10>",BI=10$
$SP,"<11>",BI=11$
$BG$
//These are indexed by color #.
$BG$//These are indexed by color #.
//See $LK,"COLORS",A="MN:RED"$.
U8 *tiles1[16]=
@@ -66,8 +59,6 @@ U8 *tiles2[16]=
NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL};
#define SCREEN_SCALE 24
#define SCREEN_WIDTH 24
#define SCREEN_HEIGHT 24
@@ -81,13 +72,16 @@ I64 man_x,man_y,man_dx,man_dy;
Bool man_attack;
F64 man_attack_t0;
#define NUM_MONSTERS 16
#define NUM_MONSTERS 10
I64 monsters_left;
class Monster
{
I64 x,y,dx,dy;
Bool dead,pad[7];
} monsters[NUM_MONSTERS];
F64 t0,tf;
#define LOS_SCALE 4
Bool LOSPlot(U8 *,I64 x,I64 y,I64)
@@ -99,17 +93,20 @@ Bool LOSPlot(U8 *,I64 x,I64 y,I64)
}
Bool LOS(I64 x1,I64 y1,I64 x2,I64 y2)
{ //Line of sight
{//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);
}
U0 DrawIt(CTask *task,CDC *dc)
{
CDC *dc_t=DCAlias(gr_dc2,task);
I64 i,x,y,xx,yy,x1,y1,z1,color;
CDC *dc_t=DCAlias(gr.dc2,task);
I64 i,x,y,xx,yy,x1,y1,z1,color,
cx=task->pix_width/2,
cy=task->pix_height/2;
CD3I32 poly[4];
U8 **_tiles;
F64 tt;
if (Blink(5))
_tiles=tiles1;
@@ -141,7 +138,7 @@ U0 DrawIt(CTask *task,CDC *dc)
z1=0;
GrTransform(dc_t,&x1,&y1,&z1);
Sprite3(dc,x1,y1,z1,_tiles[color]);
} else { //If no tile defined, do solid color.
} else {//If no tile defined, do solid color.
poly[0].x=x*SCREEN_SCALE;
poly[0].y=y*SCREEN_SCALE;
poly[0].z=0;
@@ -228,8 +225,18 @@ U0 DrawIt(CTask *task,CDC *dc)
Sprite3(dc,x1,y1,z1,$IB,"<2>",BI=2$);
DCDel(dc_t);
}
if (tf) {
dc->color=LTRED;
if (Blink)
GrPrint(dc,cx-(FONT_WIDTH*14)/2,cy-FONT_HEIGHT/2,"Game Completed");
tt=tf;
} else {
dc->color=LTGREEN;
tt=tS;
}
GrPrint(dc,0,0,"Enemy:%d Time:%3.2f Best:%3.2f",monsters_left,tt-t0,best_score);
}
U0 Attack()
{
@@ -238,12 +245,17 @@ U0 Attack()
Noise(100,300,1000);
for (i=0;i<NUM_MONSTERS;i++) {
if (!monsters[i].dead &&
man_x+man_dx==monsters[i].x && man_y+man_dy==monsters[i].y)
man_x+man_dx==monsters[i].x && man_y+man_dy==monsters[i].y) {
monsters[i].dead=TRUE;
if (!--monsters_left) {
tf=tS;
if (tf-t0<best_score)
best_score=tf-t0;
}
}
}
}
U0 Init()
{
I64 i,x,y,minx,maxx,miny,maxy;
@@ -260,6 +272,14 @@ U0 Init()
map[y*map_width+x]=GrPeek(dc,x*MAP_SCALE,y*MAP_SCALE);
DCDel(dc);
man_attack_t0=tS;
man_attack=FALSE;
man_x=0;
man_y=4;
man_dx=0;
man_dy=0;
screen_x=0;
screen_y=0;
for (i=0;i<NUM_MONSTERS;i++) {
monsters[i].dead=FALSE;
monsters[i].dx=0;
@@ -269,14 +289,9 @@ U0 Init()
monsters[i].y=RandU64%(map_height-2)+1;
} while (!map[(monsters[i].y)*map_width+monsters[i].x]);
}
man_attack_t0=tS;
man_attack=FALSE;
man_x=0;
man_y=4;
man_dx=0;
man_dy=0;
screen_x=0;
screen_y=0;
monsters_left=NUM_MONSTERS;
tf=0;
t0=tS;
}
U0 CleanUp()
@@ -428,6 +443,7 @@ dg_done:
PutExcept;
SettingsPop;
MenuPop;
AcctRegWriteBranch("TempleOS/DunGen","F64 best_score=%5.4f;\n",best_score);
CleanUp;
}
+58 -97
View File
@@ -1,15 +1,7 @@
//This uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
//Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
//This program can be AOT compiled to a .BIN.Z or JIT.
//If AOT compiling, override the filename extention warning.
#ifaot
#include "::/Kernel/AOT.HPP"
I64 best_score=0; //Doesn't work yet for AOT
#else
AcctRegSetDftEntry("TempleOS/EagleDive","I64 best_score=0;\n");
AcctRegExeBranch("TempleOS/EagleDive");
#endif
//Keep these power of two so shift is used instead of multiply
//to index arrays.
@@ -50,7 +42,6 @@ class Fish
$SP,"<1>",BI=1$
@@ -68,22 +59,17 @@ U0 CriticalSectionEnd()
LBtr(&critical_section_flag,0);
}
//These are $BK,1$NOT$BK,0$ deallocated after the program ends,
//but I did them this way for your benefit
//so 2D array indexing is not done by hand.
//You can type "EagleDive;" at the command line
//to rerun without new allocations.
//Normally, just spawn a popup task,
//run it and kill it using an icon.
#ifaot
#exe {OptOn(OPTf_GLBLS_ON_DATA_HEAP);};
#endif
/*These are $BK,1$NOT$BK,0$ deallocated after the program ends,
but I did them this way for your benefit
so 2D array indexing is not done by hand.
You can type "EagleDive;" at the command line
to rerun without new allocations.
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];
#ifaot
#exe {OptOff(OPTf_GLBLS_ON_DATA_HEAP);};
#endif
I64 num_panels;
Panel *panel_root;
@@ -105,27 +91,16 @@ class MPCtrl {
U0 FSTransform(CDC *dc,I64 *x,I64 *y,I64 *z)
{
I64 zz;
//I accidentally made the Z coordinate sign backward
//from the fill-poly depth buf scheme, so it is negated at the end.
//Negative Z coordinates are the ones we want plotted.
GrRot(dc->r,x,y,z);
//We don't want divide by zero or make too monstrous foreground objects.
//The foreground object boundary is kinda crappy looking when
//you point toward the ground.
*z=-*z;
zz=*z+50;
*z=zz=-*z;
if (zz>0) {
//The divide causes "foreshortening" which makes the distance go to a vanishing point.
*x = *x * DISPLAY_SCALE/ zz;
*x = *x * DISPLAY_SCALE/ zz; //Foreshortening
*y = *y * DISPLAY_SCALE/ zz;
}
*x+=dc->x;
*y =dc->y-*y;
}
U0 CalcNormals()
{
/*The idea is that there are two tris
@@ -157,7 +132,6 @@ It works pretty well. It combines
more than it should, but that's good
because it would result in too many
panels.
*/
I64 i,j,k,dz1,dz2;
for (j=0;j<MAP_HEIGHT-1;j++) {
@@ -331,23 +305,10 @@ U0 MPDoPanels(CTask *task)
LBtr(&mp.init_not_done_flags,Gs->num);
}
U0 InitMap()
U0 InitElevations()
{
//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.
I64 i,j,l,k1,k2,x,y,xx,yy;
I64 i,j,l,x,y,xx,yy,x1,y1,x2,y2;
MemSet(elevations,0,sizeof(elevations));
MemSet(panels,0,sizeof(panels));
for (i=0;i<MAP_WIDTH*MAP_HEIGHT/128;i++) {
x=RandU32%MAP_WIDTH;
y=RandU32%MAP_HEIGHT;
@@ -357,27 +318,44 @@ U0 InitMap()
if (!l && RandU16<MAX_U16/4)
l=RandU16%(j+1);
if (l) {
for (k1=-j;k1<=j;k1++)
for (k2=-j;k2<=j;k2++) {
xx=x+k2; yy=y+k1;
if (0<=xx<MAP_WIDTH &&
0<=yy<MAP_HEIGHT)
elevations[yy][xx]+=MAP_SCALE/2;
}
l--;
x1=ClampI64(x-j,0,MAP_WIDTH-1);
x2=ClampI64(x+j,0,MAP_WIDTH-1);
y1=ClampI64(y-j,0,MAP_HEIGHT-1);
y2=ClampI64(y+j,0,MAP_HEIGHT-1);
for (yy=y1;yy<y2;yy++)
for (xx=x1;xx<x2;xx++)
elevations[yy][xx]+=MAP_SCALE/2;
l--;
}
}
}
xx=x/(MAP_SCALE*COORDINATE_SCALE);
yy=y/(MAP_SCALE*COORDINATE_SCALE);
z+=elevations[yy][xx]*COORDINATE_SCALE;
for (j=0;j<MAP_HEIGHT;j++)
for (i=0;i<MAP_WIDTH;i++)
if (elevations[j][i]<WATER_ELEVATION*MAP_SCALE)
elevations[j][i]=WATER_ELEVATION*MAP_SCALE;
}
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.
*/
I64 i,x,y,xx,yy;
InitElevations;
MemSet(panels,0,sizeof(panels));
xx=x/(MAP_SCALE*COORDINATE_SCALE);
yy=y/(MAP_SCALE*COORDINATE_SCALE);
z+=elevations[yy][xx]*COORDINATE_SCALE;
CalcNormals;
@@ -392,7 +370,6 @@ U0 InitMap()
panels_processed_bitmap=MAlloc((num_panels+7)>>3);
}
CDC *main_dc;
U0 DrawIt(CTask *,CDC *dc)
@@ -402,8 +379,6 @@ U0 DrawIt(CTask *,CDC *dc)
}
/*
$SP,"<2>",BI=2$
@@ -423,7 +398,6 @@ $SP,"<2>",BI=2$
$SP,"<3>",BI=3$
@@ -462,14 +436,12 @@ and render the panel for each square, marking-it done.
The depth buf is not locked in the graphic routines
so we get some glitches.
*/
I64 update_jiffy_limit;
U0 MPDrawIt(CTask *task,CDC *dc)
{
//This is identical to the previous routine but is run by core#1
I64 j,strip_width,*s2w,x1,y1,z1, xx,yy,
xh,yh,zh,yh2,xh2,x1h,y1h,x1wa,y1wa,x1wb,y1wb,
x3,y3,z3,
@@ -530,7 +502,7 @@ U0 MPDrawIt(CTask *task,CDC *dc)
yy+=y3;
}
if (Gs->num&1) { //alternate left-right,right-left
if (Gs->num&1) {//alternate left-right,right-left
yh2=-yh;
xh2=-xh;
} else {
@@ -550,10 +522,10 @@ U0 MPDrawIt(CTask *task,CDC *dc)
//Take half steps to cover whole grid.
xh>>=1; yh>>=1;
xh2>>=1; yh2>>=1;
for (strip_width=0;sys_jiffies<update_jiffy_limit;strip_width++) {
for (strip_width=0;cnts.jiffies<update_jiffy_limit;strip_width++) {
x1h=x1wa;
y1h=y1wa;
for (j=0;j<strip_height && sys_jiffies<update_jiffy_limit;j++) {
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)) {
@@ -637,8 +609,8 @@ U0 DrawHorizon(CDC *dc)
MemSet(p,0,sizeof(p));
if (x2<x1) {
SwapU64(&x1,&x2);
SwapU64(&y1,&y2);
SwapI64(&x1,&x2);
SwapI64(&y1,&y2);
}
if (!x1 && x2==dc->width-1) {
p[0].x=0;
@@ -663,8 +635,8 @@ U0 DrawHorizon(CDC *dc)
GrFillPoly3(dc,4,p);
} else {
if (y2<y1) {
SwapU64(&x1,&x2);
SwapU64(&y1,&y2);
SwapI64(&x1,&x2);
SwapI64(&y1,&y2);
}
if (!y1 && y2==dc->height-1) {
p[0].x=0;
@@ -692,7 +664,6 @@ U0 DrawHorizon(CDC *dc)
dc->depth_buf=old_db;
}
U0 BSPEagleDive()
{
CDC *dc=DCAlias(main_dc,Fs);
@@ -702,7 +673,7 @@ U0 BSPEagleDive()
F64 min_strip_width;
Fish *tempf;
update_jiffy_limit=sys_jiffies+JIFFY_FREQ/40;
update_jiffy_limit=cnts.jiffies+JIFFY_FREQ/40;
MemSet(panels_processed_bitmap,0,(num_panels+7)>>3);
xx=x/(MAP_SCALE*COORDINATE_SCALE);
@@ -713,10 +684,10 @@ U0 BSPEagleDive()
dc->color=bkcolor=BLACK;
if (!game_over) {
GrRect(dc,0,0,dc->width,dc->height);
music_mute=TRUE;
music.mute=TRUE;
Beep;
game_over=TRUE;
music_mute=FALSE;
music.mute=FALSE;
}
} else
bkcolor=BLUE;
@@ -782,8 +753,7 @@ U0 BSPEagleDive()
#define ANIMATE_MS 10
U0 AnimateTask(I64)
{
//This just steadily moves the airplane fwd.
{//Steadily moves the airplane fwd.
I64 *s2w,x1,y1,z1;
F64 t0=tS,mS;
Fish *tempf,*tempf1;
@@ -815,9 +785,9 @@ U0 AnimateTask(I64)
best_score=game_score;
QueRem(tempf);
Free(tempf);
music_mute=TRUE;
music.mute=TRUE;
Snd(1000); Sleep(200); Snd(0);
music_mute=FALSE;
music.mute=FALSE;
}
tempf=tempf1;
}
@@ -852,14 +822,10 @@ U0 TaskEndCB()
}
U0 SongTask(I64)
{ //Song by Terry A. Davis
#ifaot
Fs->task_end_cb=HashVal(HashFind("SndTaskEndCB",Fs->hash_table,HTT_FUN));
#else
{//Song by Terry A. Davis
Fs->task_end_cb=&SndTaskEndCB;
#endif
MusicSettingsRst;
music_stacatto_factor=0.2;
music.stacatto_factor=0.2;
while (TRUE) {
Play("3eBDEDBDEDFEEDFEED");
Play("BDEDBDEDFEEDFEED");
@@ -882,8 +848,6 @@ U0 Init(I64 _mp_cnt)
InitMap;
DCAllocDepthBuf(main_dc);
Fs->win_max_refresh=30.0;
strip_height=128;
è =-90.0*ã/180.0;
é1= 0.0*ã/180.0;
@@ -929,9 +893,6 @@ U0 EagleDive(I64 _mp_cnt=MP_MAX_PROCESSORS)
F64 pp,tt1,tt2;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
//We really can't afford to run at 60Hz. This is how often VGA
//memory is updated, not related to actual hardware refresh rates.
WordStat;
MenuPush(
"File {"
@@ -955,7 +916,7 @@ U0 EagleDive(I64 _mp_cnt=MP_MAX_PROCESSORS)
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
try //in case <CTRL-ALT-C> is pressed.
try //in case <CTRL-ALT-c> is pressed.
do {
if (ScanKey(&ch,&sc)) {
pp=è; tt1=é1; tt2=é2;
Binary file not shown.
+141 -32
View File
@@ -3,7 +3,8 @@
F64 game_speed,
launch_unit_x1,launch_unit_y1,launch_unit_x2,launch_unit_y2,launch_t,
return_unit_x1,return_unit_y1,return_unit_x2,return_unit_y2,return_t,
set_é_unit_x1,set_é_unit_y1,set_é_unit_x2,set_é_unit_y2,set_é_t;
set_é_unit_x1,set_é_unit_y1,set_é_unit_x2,set_é_unit_y2,set_é_t,
next_noise;
CTask *main_task;
#define OT_CARRIER 0
@@ -16,6 +17,16 @@ CTask *main_task;
#define OF_RETURNING 4
#define OF_SHOOTING 8
#define FIRE_WIDTH 56
#define FIRE_HEIGHT 16
#define FIRE_X_SCALE 0.5
#define FIRE_Y_SCALE 0.5
#define FIRE_COLORS 16
U8 fire_colors[FIRE_COLORS]={
YELLOW,YELLOW,LTRED,YELLOW, BLACK,YELLOW,RED,YELLOW,
YELLOW,BLACK,YELLOW,LTRED, RED,YELLOW,DKGRAY,YELLOW};
class Obj
{
Obj *next,*last;
@@ -34,6 +45,7 @@ class Obj
death_time,next_action_time;
I32 torpedos,max_torpedos;
F64 torpedos_range;
U8 fire[(FIRE_WIDTH*FIRE_HEIGHT+7)/8];
} obj_root;
class Torpedo
@@ -55,7 +67,6 @@ class Squadron : Obj
I64 action,dead_mask,total_mask;
} *squadrons;
U0 SquadronIns(Obj *o,Obj *pred)
{
Obj *succ=pred->next_in_squadron;
@@ -118,7 +129,6 @@ U0 ObjDel(Obj *tempo)
}
}
}
$BG,1$
@@ -148,6 +158,7 @@ CSprite *imgs[NUM_PLAYERS][OT_NUM_TYPES]={{$IB,"<1>",BI=1$,$IB,"<2>",BI=2$,$IB,"
U0 DrawIt(CTask *task,CDC *dc)
{
I64 i,j,k;
F64 d,cur_time=tS;
Obj *tempo;
Torpedo *tempt;
@@ -164,6 +175,17 @@ U0 DrawIt(CTask *task,CDC *dc)
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);
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->é));
}
if (Blink) {
dc->color=BLACK;
GrLine(dc,tempo->x+5,tempo->y,tempo->x+5+10,tempo->y);
@@ -231,11 +253,11 @@ U0 DrawIt(CTask *task,CDC *dc)
if (!num_alive[1]) {
dc->color=LTGREEN;
GrPrint(dc,task->pix_width>>1 -(FONT_WIDTH*14)/2-task->scroll_x,
task->pix_height>>1-FONT_HEIGHT/2-task->scroll_y,"Game Completed");
task->pix_height>>1-FONT_HEIGHT/2-task->scroll_y,"Game Completed");
} else {
dc->color=LTRED;
GrPrint(dc,task->pix_width>>1 -(FONT_WIDTH*9)/2-task->scroll_x,
task->pix_height>>1-FONT_HEIGHT/2-task->scroll_y,"Game Over");
task->pix_height>>1-FONT_HEIGHT/2-task->scroll_y,"Game Over");
}
}
Preempt(old_preempt);
@@ -250,6 +272,7 @@ U0 Init()
QueInit(&obj_root);
QueInit(&torpedo_root);
next_noise=tS;
Fs->scroll_x=0;
Fs->scroll_y=0;
game_speed=1.0;
@@ -387,8 +410,8 @@ Squadron *SquadronLaunch(I64 player,F64 x=MAX_F64,F64 y=MAX_F64)
if (player==0) {
launch_unit_x1=tempo->x;
launch_unit_y1=tempo->y;
launch_unit_x2=ipx-main_task->pix_left-main_task->scroll_x;
launch_unit_y2=ipy-main_task->pix_top -main_task->scroll_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) {
@@ -403,7 +426,6 @@ Squadron *SquadronLaunch(I64 player,F64 x=MAX_F64,F64 y=MAX_F64)
return NULL;
}
Obj *ObjReturn(I64 player,F64 x,F64 y)
{
Obj *tempo;
@@ -456,8 +478,8 @@ Squadron *SquadronSet
if (player==0) {
set_é_unit_x1=tempo->x;
set_é_unit_y1=tempo->y;
set_é_unit_x2=ipx-main_task->pix_left-main_task->scroll_x;
set_é_unit_y2=ipy-main_task->pix_top -main_task->scroll_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) {
@@ -538,6 +560,44 @@ U0 AI(I64 player,F64 period)
}
}
U0 ShipDammage(Obj *tempo,F64 d)
{
I64 i,x=Rand*FIRE_WIDTH,y=Rand*FIRE_HEIGHT;
tempo->life_percent-=d;
while (d>0) {
if (!Bts(tempo->fire,y*FIRE_WIDTH+x))
d-=500.0/(FIRE_WIDTH*FIRE_HEIGHT);
else
d-=25.0/(FIRE_WIDTH*FIRE_HEIGHT);
i=RandI16&7;
x+=gr_x_offsets[i];
y+=gr_y_offsets[i];
while (x>=FIRE_WIDTH)
x-=FIRE_WIDTH;
while (x<0)
x+=FIRE_WIDTH;
while (y>=FIRE_HEIGHT)
y-=FIRE_HEIGHT;
while (y<0)
y+=FIRE_HEIGHT;
}
}
U0 ShipFix(Obj *tempo,F64 d)
{
tempo->life_percent+=d;
if (tempo->life_percent>=100.0) {
tempo->life_percent=100.0;
MemSet(tempo->fire,0,sizeof(Obj.fire));
return;
}
while (d>0)
if (Btr(tempo->fire,FIRE_WIDTH*FIRE_HEIGHT*Rand))
d-=400.0/(FIRE_WIDTH*FIRE_HEIGHT);
else
d-=20.0/(FIRE_WIDTH*FIRE_HEIGHT);
}
U0 Combat(F64 period)
{
F64 d;
@@ -566,11 +626,14 @@ U0 Combat(F64 period)
} else if (tempo->ship_guns>0 && d<tempo->ship_guns_range) {
tempo->flags|=OF_SHOOTING;
if (Rand<125.0*period) {
tempo1->life_percent-=tempo->ship_guns*Rand*period;
ShipDammage(tempo1,tempo->ship_guns*Rand*period);
if (Rand<10.0*period)
tempo1->fuel*=0.75*Rand+0.25;
}
Noise(100,75,200);
if (tS>next_noise) {
Noise(100,75,200);
next_noise=tS+0.1;
}
}
} else {
if (tempo->air_guns>0 && d<tempo->air_guns_range) {
@@ -580,7 +643,10 @@ U0 Combat(F64 period)
if (Rand<10.0*period)
tempo1->fuel*=0.75*Rand+0.25;
}
Noise(25,500,2000);
if (tS>next_noise) {
Noise(25,500,2000);
next_noise=tS+0.025;
}
}
}
}
@@ -606,11 +672,10 @@ U0 Combat(F64 period)
#define ANIMATE_FREQ 50
U0 AnimateTask(I64)
{ //Preemption is off after Spawn
{//Preemption is off after Spawn
Obj *tempo;
Torpedo *tempt,*tempt1;
F64 d,period;
I64 cnt=0;
while (TRUE) {
period=GAME_SPEED_SCALE*game_speed/ANIMATE_FREQ;
@@ -639,7 +704,7 @@ U0 AnimateTask(I64)
if (tS>tempt->timeout) {
tempo=tempt->target;
if (Rand<0.333333) {
tempo->life_percent-=150*Rand*Rand;
ShipDammage(tempo,150*Rand*Rand);
if (Rand<0.333333)
tempo->fuel*=0.75*Rand+0.25;
}
@@ -683,7 +748,7 @@ U0 AnimateTask(I64)
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)
tempo->life_percent=Min(100.0,tempo->life_percent+2.5*period);
ShipFix(tempo,2.5*period);
}
tempo=tempo->next;
}
@@ -694,21 +759,22 @@ U0 AnimateTask(I64)
}
}
U0 FlatTops()
{
I64 p1,p2;
I64 a1,a2;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
Fs->text_attr=BLUE<<4+WHITE;
WinMax;
WinBorder;
WordStat;
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),
WinBorder;
WordStat;
MenuPush(
"File {"
" Abort(,CH_SHIFT_ESC);"
@@ -720,18 +786,15 @@ U0 FlatTops()
" Slower(,'-');"
"}"
);
WinMax;
Fs->win_inhibit|=WIF_IP_L|WIF_IP_R;
Fs->win_inhibit|=WIF_SELF_IP_L|WIF_SELF_IP_R;
Init;
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
try {
while (TRUE)
switch(GetMsg(&p1,&p2,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 (p1) {
switch (a1) {
case '\n':
CleanUp;
Init;
@@ -748,13 +811,13 @@ U0 FlatTops()
}
break;
case MSG_IP_L_UP:
SquadronSeté(0,p1,p2);
SquadronSeté(0,a1,a2);
break;
case MSG_IP_R_UP:
SquadronLaunch(0,p1,p2);
SquadronLaunch(0,a1,a2);
break;
case MSG_IP_R_D_UP:
SquadronReturn(0,p1,p2);
SquadronReturn(0,a1,a2);
break;
}
nv_done:
@@ -767,8 +830,54 @@ nv_done:
}
FlatTops;
//Maybe use this in the future $SP,"<7>",BI=7$
r&úÿÿÿéÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ  ÿ ÿ ÿ ÿ ÿ ÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿr&úÿÿÿéÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ  ÿ ÿ ÿ ÿ ÿ ÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿb %üÿÿÿìÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿ ÿÿÿÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿb %üÿÿÿìÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿ ÿÿÿÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0
þÿÿÿ
ÿÿÿÿ 0
þÿÿÿ
ÿÿÿÿ 
ÿÿÿÿ ƒ 6,çÿÿÿ,}i(U(U7Ôþÿÿ7Ôþÿÿºÿÿÿºÿÿÿdâÿÿÿíþÿÿ2ÿÿÿ2ÿÿÿíþÿÿíþÿÿ2ÿÿÿ2ÿÿÿíþÿÿi,çÿÿÿöÿÿÿ,öÿÿÿ}öÿÿÿi(öÿÿÿU(öÿÿÿUöÿÿÿ7öÿÿÿÔþÿÿ7öÿÿÿÔþÿÿºÿÿÿöÿÿÿºÿÿÿöÿÿÿdâÿÿÿöÿÿÿiöÿÿÿ        





      


   ,ìÿÿÿ,(Ôþÿÿ#ÔþÿÿÄÿÿÿÎÿÿÿÞþÿÿÓÿÿÿâÿÿÿÞþÿÿâÿÿÿ#âÿÿÿÓÿÿÿâÿÿÿ'ñÿÿÿâÿÿÿ'âÿÿÿ   
    




+5 -6
View File
@@ -61,7 +61,7 @@ U0 Init()
{
I64 i,x=0;
DocClear;
"$$BG,DKGRAY$$"; NewLine((TEXT_ROWS-1)/2);
"$$BG,DKGRAY$$%h*c",(TEXT_ROWS-1)/2,'\n';
speed=0;
distance=0;
road_trend=0;
@@ -76,10 +76,9 @@ U0 Init()
crash=FALSE;
}
U0 Halogen()
{
I64 p1,p2,ch=0,sc=0;
I64 a1,a2,ch=0,sc=0;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
Fs->text_attr=BLACK<<4+WHITE;
MenuPush(
@@ -103,9 +102,9 @@ U0 Halogen()
Fs->draw_it=&DrawIt;
try {
while (TRUE) {
switch (ScanMsg(&p1,&p2,1<<MSG_KEY_DOWN|1<<MSG_KEY_UP)) {
switch (ScanMsg(&a1,&a2,1<<MSG_KEY_DOWN|1<<MSG_KEY_UP)) {
case MSG_KEY_DOWN:
ch=p1;sc=p2;
ch=a1;sc=a2;
switch (ch) {
case '\n':
Init;
@@ -116,7 +115,7 @@ U0 Halogen()
}
break;
case MSG_KEY_UP:
ch=p1;sc=p2;
ch=a1;sc=a2;
if (!ch)
switch (sc.u8[0]) {
case SC_CURSOR_RIGHT:
+21 -25
View File
@@ -9,7 +9,6 @@ class MySpring:CSpring
CMathODE *ode=NULL;
U0 DrawIt(CTask *task,CDC *dc)
{
Bool old_suspend;
@@ -34,13 +33,10 @@ U0 DrawIt(CTask *task,CDC *dc)
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.
{//The forces due to springs and drag are
//automatically handled by the ode code.
//We can add new forces here.
F64 d,dd;
CD3 p;
MyMass *tempm1,*tempm2;
@@ -50,7 +46,7 @@ U0 MyDerivative(CMathODE *ode,F64,COrder2D3 *,COrder2D3 *)
tempm2=tempm1->next;
while (tempm2!=&ode->next_mass) {
D3Sub(&tempm2->state->x,&tempm1->state->x,&p);
dd=D3SqrNorm(&p);
dd=D3NormSqr(&p);
if (dd<=Sqr(tempm1->radius+tempm2->radius)) {
d=Sqrt(dd)+0.0001;
dd=10.0*Sqr(Sqr(Sqr(tempm1->radius+tempm2->radius)-dd));
@@ -106,7 +102,7 @@ U0 CleanUp()
U0 MassSpringDemo()
{
I64 msg_code,p1,p2;
I64 msg_code,a1,a2;
MyMass *tempm1=NULL,*tempm2=NULL;
PopUpOk("Left-Click to place mas\n"
@@ -116,20 +112,20 @@ U0 MassSpringDemo()
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
WinMax;
//This Preempt() eliminates a lot of hassles.
//The concern is about changing
//que links while the winmgr task
//is updating the ode or screen.
/*Preempt(OFF) eliminates a lot of hassles.
The concern is about changing
que links while the winmgr task
is updating the ode or screen.
//The Window mgr suspends this
//task while updating the ode. It
//will not be interrupted and with this
//preempt, we will not be interrupted.
//There is little downside to Preempt()
//since we will yield during GetMsg().
The Window mgr suspends this
task while updating the ode. It
will not be interrupted and with this
preempt, we will not be interrupted.
There is little downside to Preempt()
since we will yield during GetMsg().
*/
Preempt(OFF);
Fs->win_inhibit|=WIG_DBL_CLICK;
WordStat;
@@ -150,22 +146,22 @@ U0 MassSpringDemo()
try {
while (TRUE) {
msg_code=GetMsg(&p1,&p2,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(p1,p2);
PlaceMass(a1,a2);
break;
case MSG_IP_R_DOWN:
tempm1=MassFind(ode,p1,p2);
tempm1=MassFind(ode,a1,a2);
tempm2=NULL;
break;
case MSG_IP_R_UP:
if (tempm1 && (tempm2=MassFind(ode,p1,p2)) && tempm1!=tempm2)
if (tempm1 && (tempm2=MassFind(ode,a1,a2)) && tempm1!=tempm2)
PlaceSpring(tempm1,tempm2);
tempm1=tempm2=NULL;
break;
case MSG_KEY_DOWN:
switch (p1) {
switch (a1) {
case '\n':
CleanUp;
Init;
+18 -17
View File
@@ -1,28 +1,29 @@
//See $LK,"ExtScreenCodes",A="FA:::/Adam/Gr/GrScreen.CPP,ExtScreenCodes"$
//See $LK,"TextBase Layer",A="HI:TextBase Layer"$.
#define ATTR (BLACK<<12+WHITE<<8)
U32 text[TEXT_ROWS][TEXT_COLS];
U0 DrawIt(CTask *task,CDC *)
{
MemCpy(gr_text_base+TEXT_COLS,text,(TEXT_ROWS-1)*TEXT_COLS*sizeof(U32));
{ //$LK,"gr.text_base",A="MN:CGrGlbls"$ gets clear 60fps, 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++)
// PlotWinU8(task,text[j][i],i,j);
// TextChar(task,,i,j,text[j][i]);
PlotWinStr(task,"Draw a maze with left button.",ATTR>>8,0,0);
PlotWinStr(task,"Solve maze starting at right click.",ATTR>>8,0,1);
TextPrint(task,0,0,ATTR>>8,"Draw a maze with left button.");
TextPrint(task,0,1,ATTR>>8,"Solve maze starting at right click.");
}
#define STK_SIZE 2048
//We would put these as local vars
//In SolveMaze() except the system stk size
//is limited. The heap is the normal TempleOS
//technique, but it's a pain in this case.
//in SolveMaze() but the system stk size
//is limited, so it's a bad habit. The heap
//is the normal TempleOS technique, but
//it's a pain in this case.
I64 stk_ptr,
stk_x [STK_SIZE],
stk_y [STK_SIZE],
@@ -50,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];
@@ -68,7 +69,7 @@ U0 SolveMaze(I64 x,I64 y)
if (stk_ptr==STK_SIZE) return;
Sleep(100);
if (ScanChar)
ThrowBreak; //CTRL-ALT-C
ThrowBreak; //<CTRL-ALT-c>
}
}
}
@@ -84,18 +85,18 @@ U0 Maze()
DocCursor;
DocClear;
Fs->draw_it=&DrawIt;
Fs->win_inhibit=WIG_TASK_DFT-WIF_FOCUS-WIF_BORDER;
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS-WIF_SELF_BORDER;
try
do {
MemSet(text,0,sizeof(text));
while (!(ch=ScanChar)) {
//Input Ptr (mouse) text x,y coordinates.
x=iptx-Fs->win_left-Fs->scroll_x/FONT_WIDTH;
y=ipty-Fs->win_top-Fs->scroll_y/FONT_HEIGHT;
if (ip_lb&&!win_grab_scroll)
//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)
text[y][x]=CH_SPACE+ATTRF_INVERT+ATTR;
if (ip_rb&&!win_grab_scroll) {
if (ip.rb&&!winmgr.grab_scroll) {
text[y][x]='*'+ATTR;
SolveMaze(x,y);
ch=GetChar;
+4 -6
View File
@@ -7,7 +7,6 @@ class Drop
I32 x,y;
} drops[NUM_DROPS];
CDC *cur_dc;
U0 DrawFrame(CTask *task,CDC *dc)
@@ -22,7 +21,7 @@ U0 DrawFrame(CTask *task,CDC *dc)
dc->color=LTRED;
GrLine(dc,cx-100,cy-100,cx,cy);
GrLine(dc,cx+100,cy-100,cx,cy);
if (Bt(key_down_bitmap,sc_1)) {
if (Bt(kbd.down_bitmap,sc_1)) {
dc->color=WHITE;
GrRect(dc,cx-2,cy-2,5,5);
}
@@ -35,7 +34,7 @@ U0 DrawFrame(CTask *task,CDC *dc)
dc->color=LTRED;
GrLine(dc,cx-200,cy,cx,cy+100);
GrLine(dc,cx+200,cy,cx,cy+100);
if (Bt(key_down_bitmap,sc_2)) {
if (Bt(kbd.down_bitmap,sc_2)) {
dc->color=WHITE;
GrRect(dc,cx-2,cy+100-2,5,5);
}
@@ -72,7 +71,6 @@ U0 DrawIt(CTask *task,CDC *dc)
UpdateCurBase(task,dc);
}
U0 AnimateTask(I64)
{
I64 i,j,cur_drop=0,c1,c2,x0,y0,x1,y1,w,h;
@@ -165,8 +163,8 @@ U0 RainDrops()
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
WinMax;
cur_dc=DCNew(GR_WIDTH,GR_HEIGHT);
sc_1=A2ScanCode('1');
sc_2=A2ScanCode('2');
sc_1=Char2ScanCode('1');
sc_2=Char2ScanCode('2');
Init;
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
DocCursor;
+22 -33
View File
@@ -1,4 +1,4 @@
//This uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
//Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
AcctRegSetDftEntry("TempleOS/RawHide","F64 best_score=9999;\n");
AcctRegExeBranch("TempleOS/RawHide");
@@ -10,8 +10,7 @@ F64 t0,tf;
#define MAP_BORDER 3
CDC *dc2;
$BG,10$
#define GE_COW 0
$BG,10$#define GE_COW 0
$SP,"<1>",BI=1$
@@ -25,16 +24,12 @@ $SP,"<2>",BI=2$
$SP,"<3>",BI=3$
#define GE_NUM 3
$BG$
class RHCSprite
{
U8 *img;
I64 min_x,max_x,min_y,max_y;
} rh_sprite[GE_NUM];
#define NUM_ANIMALS 128
class Animal
@@ -46,8 +41,7 @@ class Animal
Bool dead,pad[2];
} *a;
// ************************************
//************************************
#define COURSE_LEN (MAP_HEIGHT*2)
I32 *rx,*ry,*rw;
I64 river_lo,river_hi;
@@ -123,8 +117,7 @@ U0 RiverDel()
Free(rw);
}
// ************************************
//************************************
class RiverDrop
{
RiverDrop *next,*last;
@@ -186,10 +179,10 @@ U0 RiverDropsDraw(CDC *dc,I64 cx,I64 cy)
LBtr(&rd_lock,0);
}
// ************************************
//************************************
U0 DrawIt(CTask *task,CDC *dc)
{
static I64 last_ipx=0;
static I64 last_pos_x=0;
static Bool left=TRUE;
F64 t;
I64 i,
@@ -219,20 +212,19 @@ U0 DrawIt(CTask *task,CDC *dc)
dc->flags&=~(DCF_JUST_MIRROR|DCF_SYMMETRY);
}
if (ipx-last_ipx>0)
if (ip.pos.x-last_pos_x>0)
left=FALSE;
else if (ipx-last_ipx<0)
else if (ip.pos.x-last_pos_x<0)
left=TRUE;
if (left) {
dc->flags|=DCF_JUST_MIRROR|DCF_SYMMETRY;
GrSetSymmetry(dc,ipx-task->pix_left-task->scroll_x,0,ipx-task->pix_left-task->scroll_x,1);
GrSetSymmetry(dc,ip.pos.x-task->pix_left-task->scroll_x,0,ip.pos.x-task->pix_left-task->scroll_x,1);
}
Sprite3(dc,
ipx-task->pix_left-task->scroll_x,
ipy-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_ipx=ipx;
last_pos_x=ip.pos.x;
if (tf) {
dc->color=RED;
@@ -248,7 +240,6 @@ U0 DrawIt(CTask *task,CDC *dc)
GrPrint(dc,-task->scroll_x,-task->scroll_y,"Time:%7.2fs Best:%7.2fs",t,best_score);
}
U0 BuddySelect(I64 i)
{
I64 b,best_b=i,score,best_score=MAX_I64;
@@ -276,8 +267,8 @@ U0 AnimateTask(CTask *parent)
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;
cursor_x=ipx+cx-parent->pix_left-parent->scroll_x;
cursor_y=ipy+cy-parent->pix_top -parent->scroll_y;
cursor_x=ip.pos.x+cx-parent->pix_left-parent->scroll_x;
cursor_y=ip.pos.y+cy-parent->pix_top -parent->scroll_y;
min_x=max_x=min_y=max_y=cnt=0;
stress=0;
for (i=0;i<NUM_ANIMALS;i++) {
@@ -320,7 +311,6 @@ U0 AnimateTask(CTask *parent)
tempa->dx+=0.1*(tempa1->dx-tempa->dx);
tempa->dy+=0.1*(tempa1->dy-tempa->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);
@@ -362,13 +352,13 @@ U0 AnimateTask(CTask *parent)
if (!tf && (max_x-min_x)>>32<GR_WIDTH && (max_y-min_y)>>32<GR_HEIGHT) {
tf=tS;
music_mute=TRUE;
music.mute=TRUE;
Snd(2000);Sleep(200);Snd(0);Sleep(100);
if (tf-t0<best_score) {
best_score=tf-t0;
Snd(2000);Sleep(200);Snd(0);Sleep(100);
}
music_mute=FALSE;
music.mute=FALSE;
}
updates++;
@@ -388,7 +378,7 @@ U0 AnimateTask(CTask *parent)
}
U0 SongTask(I64)
{ //Randomly generated (by God :-)
{//Randomly generated (by God :-)
Fs->task_end_cb=&SndTaskEndCB;
MusicSettingsRst;
while (TRUE) {
@@ -399,7 +389,6 @@ U0 SongTask(I64)
}
}
U0 ReInit()
{
I64 i;
@@ -412,7 +401,7 @@ U0 ReInit()
dc2->pen_width=MAP_BORDER;
dc2->color=RED;
GrLineRect4(dc2,MAP_BORDER/2,MAP_BORDER/2,MAP_WIDTH-(MAP_BORDER+1)/2,MAP_HEIGHT-(MAP_BORDER+1)/2);
GrBorder(dc2,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);
@@ -463,7 +452,7 @@ U0 CleanUp()
U0 RawHide()
{
I64 msg_code,p1,p2;
I64 msg_code,a1,a2;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
PopUpOk(
"Coral the cattle into an area\n"
@@ -480,7 +469,7 @@ U0 RawHide()
"}"
);
Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs);
Fs->win_inhibit=WIG_TASK_DFT-WIF_FOCUS-WIF_BORDER-WIF_GRAB_SCROLL-WIF_MENU;
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS-WIF_SELF_BORDER-WIF_SELF_GRAB_SCROLL-WIF_FOCUS_TASK_MENU;
WinMax;
WordStat;
Preempt(OFF);
@@ -491,14 +480,14 @@ U0 RawHide()
Fs->draw_it=&DrawIt;
try {
while (TRUE) {
msg_code=GetMsg(&p1,&p2,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;
case MSG_IP_R_DOWN: //Doesn't do anything, yet.
break;
case MSG_KEY_DOWN:
switch (p1) {
switch (a1) {
case '\n':
ReInit;
break;
Binary file not shown.
Binary file not shown.
+4 -19
View File
@@ -11,22 +11,14 @@ class MySpring:CSpring
{
I64 type;
};
$BG,11$
$SP,"<1>",BI=1$
$SP,"<2>",BI=2$
$SP,"<3>",BI=3$
$BG$
@@ -42,8 +34,7 @@ $BG$
$SP,"<4>",BI=4,BP="::/Demo/Graphics/Camp.CPP.Z,Mountain"$ //Pointer to sprite in Camp.CPP.Z file
$SP,"<4>",BI=4,BP="::/Demo/Graphics/Mountain.CPP.Z,Mountain"$ //Pointer to sprite in $LK,"Mountain.CPP",A="FI:::/Demo/Graphics/Mountain.CPP"$ file
#define HOSE_RADIUS 3
#define LINK_SIZE 6
@@ -58,7 +49,6 @@ F64 nozzle_
CMathODE *ode=NULL;
F64 start_up_timeout;
U0 DrawIt(CTask *task,CDC *dc)
{
Bool old_suspend,first;
@@ -167,16 +157,12 @@ U0 DrawIt(CTask *task,CDC *dc)
Suspend(task,old_suspend);
}
U0 MyDerivative(CMathODE *ode,F64 t,COrder2D3 *state,COrder2D3 *DstateDt)
{
//The forces due to springs and drag are
{//The forces due to springs and drag are
//automatically handled by the
//ode code. We can add new forces
//here.
nounusedwarn t,state,DstateDt;
// F64 d,dd;
// CD3 p;
MyMass *tempm1,*tempm2;
nounusedwarn tempm2;
@@ -244,8 +230,7 @@ U0 HoseNew()
}
U0 AnimateTask(I64)
{
//Preempt is off by default for new task
{//Preempt is off by default for new task
MyMass *tempm,*tempm1;
F64 dx,dy;
while (TRUE) {
@@ -310,7 +295,7 @@ U0 MoveNozzleTaskY(I64 sign)
U0 Init()
{
DocClear;
"$$BG,LTCYAN$$"; NewLine(GROUND_Y/FONT_HEIGHT);
"$$BG,LTCYAN$$%h*c",ToI64(GROUND_Y/FONT_HEIGHT),'\n';
//Allow hose to settle.
start_up_timeout=tS+0.5;
Binary file not shown.
+3 -4
View File
@@ -1,6 +1,5 @@
//Generate "Stadium.GRA.Z" from "Stadium.TXT.Z"
U0 StadiumGen()
{
U0 (*fp_old_update)(CDC *dc);
@@ -13,8 +12,8 @@ U0 StadiumGen()
Type("::/Demo/Games/Stadium/Stadium.TXT");
"$$CM,0,%d$$",TEXT_ROWS-3;
DocCursor(OFF);
fp_old_update=fp_final_screen_update; //hide mouse cursor
fp_final_screen_update=NULL;
fp_old_update=gr.fp_final_screen_update; //hide mouse cursor
gr.fp_final_screen_update=NULL;
WinMgrSync(2,TRUE);
dc2=DCCaptureScreen;
@@ -25,7 +24,7 @@ U0 StadiumGen()
DCDel(dc);
DocCursor(ON);
fp_final_screen_update=fp_old_update;
gr.fp_final_screen_update=fp_old_update;
DocClear;
}
Binary file not shown.
+9 -14
View File
@@ -35,20 +35,15 @@ U0 DrawBoard(I64 player)
break;
}
/*
ipx,ipy are input pointer (mouse) x,y.
ip_lb is mouse left button
*/
//ip.pos.x,ip.pos.y are input pointer (mouse) x,y.
//ip.lb is mouse left button
if (player==1)
DrawX(dc,ipx-Fs->pix_left,ipy-Fs->pix_top);
DrawX(dc,ip.pos.x-Fs->pix_left,ip.pos.y-Fs->pix_top);
else
DrawO(dc,ipx-Fs->pix_left,ipy-Fs->pix_top);
DrawO(dc,ip.pos.x-Fs->pix_left,ip.pos.y-Fs->pix_top);
DCDel(dc);
}
U0 TakeTurn(I64 player)
{
I64 i,x=0,y=0;
@@ -57,16 +52,16 @@ U0 TakeTurn(I64 player)
Beep(500);
else
Beep(1000);
while (!ip_lb) {
while (!ip.lb) {
DrawBoard(player);
WinMgrSync;
}
while (ip_lb) {
while (ip.lb) {
DrawBoard(player);
WinMgrSync;
}
x=ipx-Fs->pix_left;
y=ipy-Fs->pix_top;
x=ip.pos.x-Fs->pix_left;
y=ip.pos.y-Fs->pix_top;
i=(x-100)/100+(y-100)/100*3;
}
board[i]=player;
@@ -118,7 +113,7 @@ U0 TicTacToe()
{
WinMax; //Maximize window
DocClear; //Clear window text.
"$$GREEN$$CTRL-ALT-C$$FG$$ to exit.\n";
"$$GREEN$$CTRL-ALT-c$$FG$$ to exit.\n";
try
while (TRUE)
DoGame;
+5 -12
View File
@@ -1,4 +1,3 @@
@@ -8,7 +7,6 @@
$SP,"<2>",BI=2$
@@ -17,8 +15,6 @@
$SP,"<3>",BI=3$
@@ -50,7 +46,6 @@
$SP,"<5>",BI=5$
@@ -92,7 +87,6 @@
AcctRegSetDftEntry("TempleOS/Varoom","F64 best_score=9999;\n");
AcctRegExeBranch("TempleOS/Varoom");
@@ -201,7 +195,7 @@ U0 MPUpdateWin(CDC *dc2)
Bool draw;
CD3I32 poly[4];
TrackPoly *tempt;
CDC *dc=DCAlias(gr_dc2,task);
CDC *dc=DCAlias(gr.dc2,task);
GrIdentEqu(r);
GrRotYEqu(r,ã-c[0].é);
@@ -314,9 +308,9 @@ U0 DrawIt(CTask *task,CDC *dc)
while (mp_not_done_flags)
Yield;
if (Bt(key_down_bitmap,SC_CURSOR_LEFT))
if (Bt(kbd.down_bitmap,SC_CURSOR_LEFT))
è=-0.5;
else if (Bt(key_down_bitmap,SC_CURSOR_RIGHT))
else if (Bt(kbd.down_bitmap,SC_CURSOR_RIGHT))
è=0.5;
else
è=0;
@@ -363,7 +357,6 @@ U0 DrawIt(CTask *task,CDC *dc)
180+180/ã*Arg(c[0].p.x,c[0].p.z),100.0*distance/(2*ã*TRACK_INNER),s,best_score);
}
U0 AnimateTask(I64)
{
Car *tempc;
@@ -388,7 +381,7 @@ U0 AnimateTask(I64)
R2P(&m,&a,c[0].p.x,c[0].p.z);
if (!game_over && TRACK_INNER<=m<=TRACK_OUTER) {
for (i=1;i<NUM_CARS;i++)
if (D3I32SqrDist(&c[i].p,&c[0].p)<CAR_LENGTH*CAR_LENGTH>>1) {
if (D3I32DistSqr(&c[i].p,&c[0].p)<CAR_LENGTH*CAR_LENGTH>>1) {
game_over=TRUE;
Noise(500,50,100);
Sleep(500);
@@ -469,7 +462,7 @@ U0 Varoom()
SettingsPush(Fs,TSF_SAME_SONG); //See $LK,"SettingsPush",A="MN:SettingsPush"$
try {
Fs->text_attr=YELLOW<<4+BLUE;
Fs->win_inhibit=WIG_TASK_DFT-WIF_FOCUS-WIF_GRAB_SCROLL-WIF_MENU;
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS-WIF_SELF_GRAB_SCROLL-WIF_FOCUS_TASK_MENU;
WordStat;
WinMax;
WinBorder;
+8 -17
View File
@@ -19,7 +19,6 @@ AcctRegExeBranch("TempleOS/Wenceslas");
@@ -35,7 +34,6 @@ AcctRegExeBranch("TempleOS/Wenceslas");
$SP,"<5>",BI=5$
@@ -55,8 +53,6 @@ AcctRegExeBranch("TempleOS/Wenceslas");
$SP,"<6>",BI=6$
@@ -64,13 +60,8 @@ AcctRegExeBranch("TempleOS/Wenceslas");
$SP,"<7>",BI=7$
#define NUM_FLAKES 0x8000
class Flake
{
@@ -114,7 +105,7 @@ U0 DrawIt(CTask *task,CDC *dc)
dc->pen_width=1;
for (i=0;i<NUM_TREES;i++) {
if (trees[i].y<=h/2) { //Draw trees behind house
if (trees[i].y<=h/2) {//Draw trees behind house
if (trees[i].fire_frame_index) {
if (trees[i].fire_frame_index++&1)
img=$IB,"<4>",BI=4$;
@@ -131,7 +122,7 @@ U0 DrawIt(CTask *task,CDC *dc)
Sprite3(dc,w/2,h/2,0,$IB,"<7>",BI=7$);
for (i=0;i<NUM_TREES;i++) {
if (trees[i].y>h/2) { //Draw trees in front of house
if (trees[i].y>h/2) {//Draw trees in front of house
if (trees[i].fire_frame_index) {
if (trees[i].fire_frame_index++&1)
img=$IB,"<4>",BI=4$;
@@ -287,7 +278,7 @@ U0 Follow(CTask *,Peasant *tempp)
}
U0 AnimateTask(I64)
{//preempt off by default after Spawned
{//Preempt off by default after spawned.
Step *temps,*temps1;
Peasant *tempp;
I64 i,animate_cnt=0,w,h;
@@ -351,13 +342,13 @@ U0 AnimateTask(I64)
}
if (!not_stopped_cnt && !tf) {
tf=tS;
music_mute=TRUE;
music.mute=TRUE;
Snd(2000);Sleep(200);Snd(0);Sleep(100);
if (tf-t0<best_score) {
best_score=tf-t0;
Snd(2000);Sleep(200);Snd(0);Sleep(100);
}
music_mute=FALSE;
music.mute=FALSE;
}
snow_x+=RandU16%3-1;
@@ -379,8 +370,8 @@ U0 SongTask(I64)
{
Fs->task_end_cb=&SndTaskEndCB;
MusicSettingsRst;
music_tempo= 2.480;
music_stacatto_factor= 0.902;
music.tempo= 2.480;
music.stacatto_factor= 0.902;
while (TRUE) {
Play("3eCCCDCC2qG3eA2G3ABqCC");
Play("eCCCDCC2qG3eA2G3ABqCC");
@@ -464,7 +455,7 @@ Shall yourselves find blessing
PopUpOk("
$$PURPLE$$$$TX+CX,\"Winceslas Game\"$$$$FG$$
Start fires by pressing $$GREEN$$<SPACE BAR>$$FG$$
Start fires by pressing $$GREEN$$<SPACE>$$FG$$
on trees. (Yule logs)
Lead peasants to fires.
+6 -8
View File
@@ -23,8 +23,8 @@ 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,
ipx-task->pix_left-task->scroll_x,
ipy-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);
@@ -51,7 +51,6 @@ U0 DrawIt(CTask *task,CDC *dc)
Snd(0);
}
U0 MyDerivative(CMathODE *ode,F64 t,COrder2D3 *,COrder2D3 *)
{
I64 i,j;
@@ -59,7 +58,7 @@ U0 MyDerivative(CMathODE *ode,F64 t,COrder2D3 *,COrder2D3 *)
CD3 p,p2;
CTask *task=ode->win_task;
D3SubEqu(D3Equ(&p2,ipx-task->pix_left-task->scroll_x,ipy-task->pix_top-task->scroll_y,0),
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));
@@ -76,7 +75,7 @@ U0 MyDerivative(CMathODE *ode,F64 t,COrder2D3 *,COrder2D3 *)
for (i=0;i<NUM_BALLS;i++)
for (j=i+1;j<NUM_BALLS;j++) {
D3Sub(&balls[j].state->x,&balls[i].state->x,&p);
dd=D3SqrNorm(&p);
dd=D3NormSqr(&p);
if (dd<=(2*BALL_RADIUS)*(2*BALL_RADIUS)) {
if (t-collision_t>0.05) {
Noise(50,5000,6000);
@@ -103,7 +102,6 @@ U0 MyDerivative(CMathODE *ode,F64 t,COrder2D3 *,COrder2D3 *)
balls[0].DstateDt->DyDt-=Sqr(Sqr(Sqr((d+BALL_RADIUS)-task->pix_height)));
}
U0 Whap()
{
I64 i;
@@ -129,8 +127,8 @@ U0 Whap()
for (i=1;i<NUM_BALLS;i++)
D3Equ(&balls[i].x,
RandI16%500+Fs->pix_width>>1,RandI16%500+Fs->pix_height>>1,0);
balls[0].x=ipx-Fs->pix_left-Fs->scroll_x;
balls[0].y=ipy-Fs->pix_top-Fs->scroll_y;
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++) {
balls[i].mass=1.0;
balls[i].drag_profile_factor=1.0;
Binary file not shown.
Binary file not shown.