TempleOSCD_150216.ISO
This commit is contained in:
1 parent
64f679eeb9
commit
401601816c
531 files changed
+23341
-22071
No files matched your search
+206
-110
@@ -2,16 +2,35 @@ AcctRegSetDftEntry("TempleOS/Wenceslas","F64 best_score=9999;\n");
|
||||
AcctRegExeBranch("TempleOS/Wenceslas");
|
||||
|
||||
#define BORDER 5
|
||||
#define KING_STEP 4
|
||||
|
||||
|
||||
|
||||
$SP,"<1>",BI=1$
|
||||
#define KING_STEP 6
|
||||
|
||||
|
||||
|
||||
|
||||
$SP,"<2>",BI=2$
|
||||
|
||||
$SP,"<1>",BI=1$
|
||||
|
||||
|
||||
|
||||
$SP,"<2>",BI=2$
|
||||
|
||||
|
||||
|
||||
$SP,"<3>",BI=3$
|
||||
|
||||
|
||||
|
||||
$SP,"<4>",BI=4$
|
||||
|
||||
|
||||
|
||||
$SP,"<5>",BI=5$
|
||||
|
||||
|
||||
|
||||
$SP,"<6>",BI=6$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -22,19 +41,19 @@ AcctRegExeBranch("TempleOS/Wenceslas");
|
||||
|
||||
|
||||
|
||||
$SP,"<3>",BI=3$
|
||||
$SP,"<7>",BI=7$
|
||||
|
||||
|
||||
|
||||
|
||||
$SP,"<4>",BI=4$
|
||||
$SP,"<8>",BI=8$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$SP,"<5>",BI=5$
|
||||
$SP,"<9>",BI=9$
|
||||
|
||||
|
||||
|
||||
@@ -53,14 +72,18 @@ AcctRegExeBranch("TempleOS/Wenceslas");
|
||||
|
||||
|
||||
|
||||
$SP,"<6>",BI=6$
|
||||
$SP,"<10>",BI=10$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$SP,"<7>",BI=7$
|
||||
$SP,"<11>",BI=11$
|
||||
|
||||
|
||||
CSprite *king_imgs[4]={$IB,"<2>",BI=2$,$IB,"<1>",BI=1$,$IB,"<2>",BI=2$,$IB,"<3>",BI=3$};
|
||||
CSprite *peasant_imgs[4]={$IB,"<5>",BI=5$,$IB,"<4>",BI=4$,$IB,"<5>",BI=5$,$IB,"<6>",BI=6$};
|
||||
|
||||
#define NUM_FLAKES 0x8000
|
||||
class Flake
|
||||
@@ -76,10 +99,12 @@ class Tree
|
||||
} trees[NUM_TREES];
|
||||
|
||||
I64 snow_x,snow_y;
|
||||
I64 king_x,king_y,not_stopped_cnt;
|
||||
F64 king_é,t0,tf,door_open_t0;
|
||||
I64 king_x,king_y,king_mS,king_phase,
|
||||
not_stopped_cnt;
|
||||
F64 king_timeout,king_é,t0,tf,door_open_t0;
|
||||
I64 animate_mS,animate_phase;
|
||||
|
||||
#define NUM_PEASANTS 16
|
||||
#define NUM_PEASANTS 10
|
||||
class Peasant
|
||||
{
|
||||
Peasant *next,*last;
|
||||
@@ -98,7 +123,8 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
{
|
||||
I64 r[16],i,w=task->pix_width,h=task->pix_height;
|
||||
U8 *img;
|
||||
Step *temps;
|
||||
CSprite *temps;
|
||||
Step *tempst;
|
||||
Peasant *tempp;
|
||||
F64 tt;
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
@@ -108,43 +134,45 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
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$;
|
||||
img=$IB,"<8>",BI=8$;
|
||||
else
|
||||
img=$IB,"<5>",BI=5$;
|
||||
img=$IB,"<9>",BI=9$;
|
||||
} else
|
||||
img=$IB,"<3>",BI=3$;
|
||||
img=$IB,"<7>",BI=7$;
|
||||
Sprite3(dc,trees[i].x,trees[i].y,0,img);
|
||||
}
|
||||
}
|
||||
|
||||
Sprite3(dc,w/2,h/2,0,$IB,"<6>",BI=6$);
|
||||
Sprite3(dc,w/2,h/2,0,$IB,"<10>",BI=10$);
|
||||
if (tS<door_open_t0+1.0)
|
||||
Sprite3(dc,w/2,h/2,0,$IB,"<7>",BI=7$);
|
||||
Sprite3(dc,w/2,h/2,0,$IB,"<11>",BI=11$);
|
||||
|
||||
for (i=0;i<NUM_TREES;i++) {
|
||||
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$;
|
||||
img=$IB,"<8>",BI=8$;
|
||||
else
|
||||
img=$IB,"<5>",BI=5$;
|
||||
img=$IB,"<9>",BI=9$;
|
||||
} else
|
||||
img=$IB,"<3>",BI=3$;
|
||||
img=$IB,"<7>",BI=7$;
|
||||
Sprite3(dc,trees[i].x,trees[i].y,0,img);
|
||||
}
|
||||
}
|
||||
|
||||
temps=step_root.next;
|
||||
while (temps!=&step_root) {
|
||||
if (tS-temps->t0<2.0)
|
||||
tempst=step_root.next;
|
||||
while (tempst!=&step_root) {
|
||||
if (tS-tempst->t0<2.0)
|
||||
dc->color=DKGRAY;
|
||||
else
|
||||
dc->color=LTGRAY;
|
||||
dc->pen_width=2;
|
||||
GrPlot3(dc,temps->x,temps->y,0);
|
||||
temps=temps->next;
|
||||
dc->pen_width=4;
|
||||
GrPlot3(dc,tempst->x,tempst->y,0);
|
||||
tempst=tempst->next;
|
||||
}
|
||||
|
||||
DCAllocDepthBuf(dc);
|
||||
dc->flags|=DCF_TRANSFORMATION;
|
||||
dc->pen_width=1;
|
||||
tempp=peasant_root.next;
|
||||
while (tempp!=&peasant_root) {
|
||||
@@ -152,25 +180,39 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
GrRotYEqu(r,tempp->é+ã/2);
|
||||
GrRotXEqu(r,ã/6);
|
||||
if (tempp->stopped)
|
||||
dc->color=LTCYAN;
|
||||
else
|
||||
dc->color=CYAN;
|
||||
SpriteMat3B(dc,tempp->x,tempp->y,0,$IB,"<2>",BI=2$,r);
|
||||
SpriteMat3B(dc,tempp->x,tempp->y,GR_Z_ALL,peasant_imgs[0],r);
|
||||
else {
|
||||
temps=SpriteInterpolate(
|
||||
peasant_imgs[ animate_phase &3],
|
||||
peasant_imgs[(animate_phase+1)&3],
|
||||
Saw(animate_mS/250.0,1.0));
|
||||
SpriteMat3B(dc,tempp->x,tempp->y,GR_Z_ALL,temps,r);
|
||||
Free(temps);
|
||||
}
|
||||
tempp=tempp->next;
|
||||
}
|
||||
|
||||
|
||||
dc->pen_width=1;
|
||||
GrIdentEqu(r);
|
||||
GrRotYEqu(r,king_é+ã/2);
|
||||
GrRotXEqu(r,ã/6);
|
||||
SpriteMat3B(dc,king_x,king_y,0,$IB,"<1>",BI=1$,r);
|
||||
if (tS>king_timeout)
|
||||
SpriteMat3B(dc,king_x,king_y,GR_Z_ALL,king_imgs[0],r);
|
||||
else {
|
||||
temps=SpriteInterpolate(
|
||||
king_imgs[ king_phase &3],
|
||||
king_imgs[(king_phase+1)&3],
|
||||
Saw(king_mS/250.0,1.0));
|
||||
SpriteMat3B(dc,king_x,king_y,GR_Z_ALL,temps,r);
|
||||
Free(temps);
|
||||
}
|
||||
|
||||
dc->pen_width=1;
|
||||
dc->color=WHITE;
|
||||
for (i=0;i<NUM_FLAKES;i++)
|
||||
GrPlot(dc,(flakes[i].x+snow_x)%task->pix_width,
|
||||
(flakes[i].y+snow_y)%task->pix_height);
|
||||
|
||||
(flakes[i].y+snow_y)%task->pix_height);
|
||||
|
||||
if (tf) {
|
||||
dc->color=LTRED;
|
||||
if (Blink)
|
||||
@@ -181,12 +223,12 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
}
|
||||
dc->color=LTBLUE;
|
||||
GrPrint(dc,0,0,"Freezing Peasants:%d Time:%3.2f Best:%3.2f",
|
||||
not_stopped_cnt,tt-t0,best_score);
|
||||
not_stopped_cnt,tt-t0,best_score);
|
||||
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
|
||||
U0 StepNew(CTask *task,I64 x,I64 y,F64 é,Bool king)
|
||||
U0 StepNew(CTask *task,I64 x,I64 y,F64 é,Bool left_right,Bool king)
|
||||
{
|
||||
Step *temps;
|
||||
|
||||
@@ -198,17 +240,29 @@ U0 StepNew(CTask *task,I64 x,I64 y,F64
|
||||
QueIns(temps,king_step_root.last);
|
||||
}
|
||||
|
||||
temps=MAlloc(sizeof(Step),task);
|
||||
temps->x=x-3.5*Sin(é)+1.0*Cos(é);
|
||||
temps->y=y+3.5*Cos(é)+1.0*Sin(é);
|
||||
temps->t0=tS;
|
||||
QueIns(temps,step_root.last);
|
||||
|
||||
temps=MAlloc(sizeof(Step),task);
|
||||
temps->x=x+3.5*Sin(é)-1.0*Cos(é);
|
||||
temps->y=y-3.5*Cos(é)-1.0*Sin(é);
|
||||
temps->t0=tS;
|
||||
QueIns(temps,step_root.last);
|
||||
if (left_right) {
|
||||
temps=MAlloc(sizeof(Step),task);
|
||||
temps->x=x-3.5*Sin(é)+2.0*Cos(é);
|
||||
temps->y=y+3.5*Cos(é)+2.0*Sin(é);
|
||||
temps->t0=tS;
|
||||
QueIns(temps,step_root.last);
|
||||
temps=MAlloc(sizeof(Step),task);
|
||||
temps->x=x-3.5*Sin(é)+5.0*Cos(é);
|
||||
temps->y=y+3.5*Cos(é)+5.0*Sin(é);
|
||||
temps->t0=tS;
|
||||
QueIns(temps,step_root.last);
|
||||
} else {
|
||||
temps=MAlloc(sizeof(Step),task);
|
||||
temps->x=x+3.5*Sin(é)+0.0*Cos(é);
|
||||
temps->y=y-3.5*Cos(é)+0.0*Sin(é);
|
||||
temps->t0=tS;
|
||||
QueIns(temps,step_root.last);
|
||||
temps=MAlloc(sizeof(Step),task);
|
||||
temps->x=x+3.5*Sin(é)+3.0*Cos(é);
|
||||
temps->y=y-3.5*Cos(é)+3.0*Sin(é);
|
||||
temps->t0=tS;
|
||||
QueIns(temps,step_root.last);
|
||||
}
|
||||
}
|
||||
|
||||
U0 Init()
|
||||
@@ -223,7 +277,7 @@ U0 Init()
|
||||
flakes[i].y=RandU16;
|
||||
}
|
||||
|
||||
SpriteExtents($IB,"<3>",BI=3$,&min_x,&max_x,&min_y,&max_y);
|
||||
SpriteExtents($IB,"<7>",BI=7$,&min_x,&max_x,&min_y,&max_y);
|
||||
for (i=0;i<NUM_TREES;i++) {
|
||||
trees[i].x=RandU16%(w-2*BORDER-(max_x-min_x+1))+BORDER-min_x;
|
||||
trees[i].y=RandU16%(h-2*BORDER-(max_y-min_y+1))+BORDER-min_y;
|
||||
@@ -233,7 +287,7 @@ U0 Init()
|
||||
QueInit(&step_root);
|
||||
QueInit(&king_step_root);
|
||||
|
||||
SpriteExtents($IB,"<1>",BI=1$,&min_x,&max_x,&min_y,&max_y);
|
||||
SpriteExtents($IB,"<12>",BI=12$,&min_x,&max_x,&min_y,&max_y);
|
||||
QueInit(&peasant_root);
|
||||
for (i=0;i<NUM_PEASANTS;i++) {
|
||||
tempp=MAlloc(sizeof(Peasant));
|
||||
@@ -244,7 +298,11 @@ U0 Init()
|
||||
tempp->stopped=FALSE;
|
||||
QueIns(tempp,peasant_root.last);
|
||||
}
|
||||
|
||||
animate_phase=0;
|
||||
animate_mS=0;
|
||||
king_phase=0;
|
||||
king_mS=0;
|
||||
king_timeout=0;
|
||||
king_x=w/2;
|
||||
king_y=h/2;
|
||||
king_é=-ã/2;
|
||||
@@ -281,7 +339,7 @@ U0 AnimateTask(I64)
|
||||
{//Preempt off by default after spawned.
|
||||
Step *temps,*temps1;
|
||||
Peasant *tempp;
|
||||
I64 i,animate_cnt=0,w,h;
|
||||
I64 i,w,h;
|
||||
while (TRUE) {
|
||||
w=Fs->parent_task->pix_width;
|
||||
h=Fs->parent_task->pix_height;
|
||||
@@ -289,7 +347,7 @@ U0 AnimateTask(I64)
|
||||
temps=step_root.next;
|
||||
while (temps!=&step_root) {
|
||||
temps1=temps->next;
|
||||
if (tS-temps->t0>4.0) {
|
||||
if (tS-temps->t0>5.0) {
|
||||
QueRem(temps);
|
||||
Free(temps);
|
||||
}
|
||||
@@ -299,7 +357,7 @@ U0 AnimateTask(I64)
|
||||
temps=king_step_root.next;
|
||||
while (temps!=&king_step_root) {
|
||||
temps1=temps->next;
|
||||
if (tS-temps->t0>4.0) {
|
||||
if (tS-temps->t0>3.0) {
|
||||
QueRem(temps);
|
||||
Free(temps);
|
||||
}
|
||||
@@ -333,8 +391,8 @@ U0 AnimateTask(I64)
|
||||
tempp->x+=3*Cos(tempp->é)/100;
|
||||
tempp->y+=3*Sin(tempp->é)/100;
|
||||
}
|
||||
if (!(animate_cnt&511))
|
||||
StepNew(Fs->parent_task,tempp->x,tempp->y,tempp->é,FALSE);
|
||||
if (!animate_mS && animate_phase&1)
|
||||
StepNew(Fs->parent_task,tempp->x,tempp->y,tempp->é,animate_phase&2,FALSE);
|
||||
not_stopped_cnt++;
|
||||
}
|
||||
}
|
||||
@@ -354,7 +412,18 @@ U0 AnimateTask(I64)
|
||||
snow_x+=RandU16%3-1;
|
||||
snow_y+=1-SignI64(RandU16&3);
|
||||
Sleep(1);
|
||||
animate_cnt++;
|
||||
animate_mS++;
|
||||
if (animate_mS>=250) {
|
||||
animate_mS=0;
|
||||
animate_phase=(animate_phase+1)&3;
|
||||
}
|
||||
if (tS<king_timeout) {
|
||||
king_mS++;
|
||||
if (king_mS>=250) {
|
||||
king_mS=0;
|
||||
king_phase|=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,19 +453,19 @@ U0 Wenceslas()
|
||||
I64 sc;
|
||||
|
||||
MenuPush(
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Restart(,'\n');"
|
||||
" BurnTree(,CH_SPACE);"
|
||||
" Up(,,SC_CURSOR_UP);"
|
||||
" Down(,,SC_CURSOR_DOWN);"
|
||||
" Left(,,SC_CURSOR_LEFT);"
|
||||
" Right(,,SC_CURSOR_RIGHT);"
|
||||
"}"
|
||||
);
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Play {"
|
||||
" Restart(,'\n');"
|
||||
" BurnTree(,CH_SPACE);"
|
||||
" Up(,,SC_CURSOR_UP);"
|
||||
" Down(,,SC_CURSOR_DOWN);"
|
||||
" Left(,,SC_CURSOR_LEFT);"
|
||||
" Right(,,SC_CURSOR_RIGHT);"
|
||||
"}"
|
||||
);
|
||||
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
WinMax;
|
||||
@@ -432,7 +501,7 @@ Through the rude wind's wild lament
|
||||
And the bitter weather
|
||||
|
||||
");
|
||||
PopUpOk("
|
||||
PopUpOk("
|
||||
\"Sire, the night is darker now
|
||||
And the wind blows stronger
|
||||
Fails my heart, I know not how,
|
||||
@@ -452,7 +521,7 @@ Ye who now will bless the poor
|
||||
Shall yourselves find blessing
|
||||
|
||||
");
|
||||
PopUpOk("
|
||||
PopUpOk("
|
||||
$$PURPLE$$$$TX+CX,\"Winceslas Game\"$$$$FG$$
|
||||
|
||||
Start fires by pressing $$GREEN$$<SPACE>$$FG$$
|
||||
@@ -463,7 +532,7 @@ Lead peasants to fires.
|
||||
|
||||
Init;
|
||||
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
|
||||
WordStat;
|
||||
AutoComplete;
|
||||
|
||||
DocCursor;
|
||||
DocClear;
|
||||
@@ -483,29 +552,32 @@ Lead peasants to fires.
|
||||
break;
|
||||
case 0:
|
||||
switch (sc.u8[0]) {
|
||||
case SC_CURSOR_RIGHT:
|
||||
if (king_x+KING_STEP<Fs->pix_width-BORDER)
|
||||
king_x+=KING_STEP;
|
||||
king_é=0;
|
||||
StepNew(Fs,king_x,king_y,king_é,TRUE);
|
||||
break;
|
||||
case SC_CURSOR_LEFT:
|
||||
if (king_x-KING_STEP>=BORDER)
|
||||
king_x-=KING_STEP;
|
||||
king_é=ã;
|
||||
StepNew(Fs,king_x,king_y,king_é,TRUE);
|
||||
break;
|
||||
case SC_CURSOR_DOWN:
|
||||
if (king_y+KING_STEP<Fs->pix_height-BORDER)
|
||||
king_y+=KING_STEP;
|
||||
king_é=-ã/2;
|
||||
StepNew(Fs,king_x,king_y,king_é,TRUE);
|
||||
break;
|
||||
case SC_CURSOR_UP:
|
||||
if (king_y-KING_STEP>=BORDER)
|
||||
king_y-=KING_STEP;
|
||||
king_é=ã/2;
|
||||
StepNew(Fs,king_x,king_y,king_é,TRUE);
|
||||
sub_switch_start:
|
||||
case SC_CURSOR_RIGHT:
|
||||
if (king_x+KING_STEP<Fs->pix_width-BORDER)
|
||||
king_x+=KING_STEP;
|
||||
king_é=0;
|
||||
break;
|
||||
case SC_CURSOR_LEFT:
|
||||
if (king_x-KING_STEP>=BORDER)
|
||||
king_x-=KING_STEP;
|
||||
king_é=ã;
|
||||
break;
|
||||
case SC_CURSOR_DOWN:
|
||||
if (king_y+KING_STEP<Fs->pix_height-BORDER)
|
||||
king_y+=KING_STEP;
|
||||
king_é=-ã/2;
|
||||
break;
|
||||
case SC_CURSOR_UP:
|
||||
if (king_y-KING_STEP>=BORDER)
|
||||
king_y-=KING_STEP;
|
||||
king_é=ã/2;
|
||||
break;
|
||||
sub_switch_end:
|
||||
king_mS=0;
|
||||
king_phase=(king_phase+2)&2;
|
||||
StepNew(Fs,king_x,king_y,king_é,king_phase&2,TRUE);
|
||||
king_timeout=tS+0.5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -520,7 +592,7 @@ ws_done:
|
||||
}
|
||||
|
||||
Wenceslas;
|
||||
| ||||