Files
TempleOS-Rijn/SparrowOS/Apps/AfterEgypt/Horeb.CPP
T
2018-09-08 21:45:28 +02:00

279 lines
13 KiB
C++
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
$SP,"<1>",1$
$SP,"<2>",2$
$SP,"<3>",3$
$SP,"<4>",4$
//See $LK,"::/SparrowOS/Doc/Acknowledgements.TXT.Z","FI:::/SparrowOS/Doc/Acknowledgements.TXT.Z"$ (8).
$SP,"",5$
F64 é,vx,vz;
Bool horeb_done;
#define NUM_OBJS 256
#define NUM_WEIGHED_IMGS 64
U8 *imgs[NUM_WEIGHED_IMGS]=
{$IB,"<1>",1$,$IB,"<1>",1$,$IB,"<2>",2$,$IB,"<2>",2$,$IB,"<3>",3$,$IB,"<4>",4$,$IB,"<4>",4$,$IB,"<4>",4$,
$IB,"<1>",1$,$IB,"<1>",1$,$IB,"<2>",2$,$IB,"<2>",2$,$IB,"<3>",3$,$IB,"<4>",4$,$IB,"<4>",4$,$IB,"<4>",4$,
$IB,"<1>",1$,$IB,"<1>",1$,$IB,"<2>",2$,$IB,"<2>",2$,$IB,"<3>",3$,$IB,"<4>",4$,$IB,"<4>",4$,$IB,"<4>",4$,
$IB,"<1>",1$,$IB,"<1>",1$,$IB,"<2>",2$,$IB,"<2>",2$,$IB,"<3>",3$,$IB,"<4>",4$,$IB,"<4>",4$,$IB,"<4>",4$,
$IB,"<1>",1$,$IB,"<1>",1$,$IB,"<2>",2$,$IB,"<2>",2$,$IB,"<3>",3$,$IB,"<4>",4$,$IB,"<4>",4$,$IB,"<4>",4$,
$IB,"<1>",1$,$IB,"<1>",1$,$IB,"<2>",2$,$IB,"<2>",2$,$IB,"<3>",3$,$IB,"<4>",4$,$IB,"<4>",4$,$IB,"<4>",4$,
$IB,"<1>",1$,$IB,"<1>",1$,$IB,"<2>",2$,$IB,"<2>",2$,$IB,"<3>",3$,$IB,"<4>",4$,$IB,"<4>",4$,$IB,"<4>",4$,
$IB,"<1>",1$,$IB,"<1>",1$,$IB,"<2>",2$,$IB,"<2>",2$,$IB,"<3>",3$,$IB,"<4>",4$,$IB,"<4>",4$,$IB,"<5>",5$};
class Obj
{
I32 x,y,z;
I64 x1,y1,z1;
Bool sym,pad[3];
U8 *img;
} objs[NUM_OBJS];
I64 ObjCompare(Obj *o1,Obj *o2)
{
return o2->z1-o1->z1;
}
U0 DrawHoreb(CTask *task,CDC *dc)
{
I64 i,j,x,y,z,
w=task->win_pixel_width,
h=task->win_pixel_height,r[16],
cx=w>>1,cy=h>>1;
F64 s,m,a,x1,y1,x2,y2;
Obj *o_sort[NUM_OBJS],*tempo;
GrIdentEqu(r);
GrRotYEqu(r,-é);
GrRotXEqu(r,77*ă/180);
//Sun
x=vx; y=0; z=1000000+vz;
GrRot(r,&x,&y,&z);
s=100.0/(AbsI64(z)+50);
if (y<0) {
dc->color=BROWN;
GrCircle(dc,s*x+cx,15,15);
dc->color=YELLOW;
GrFloodFill(dc,s*x+cx,15);
}
for (i=0;i<NUM_OBJS;i++) {
tempo=&objs[i];
o_sort[i]=tempo;
tempo->x1=tempo->x+vx; tempo->y1=tempo->y; tempo->z1=tempo->z+vz;
GrRot(r,&tempo->x1,&tempo->y1,&tempo->z1);
}
QSortI64(o_sort,NUM_OBJS,&ObjCompare);
for (i=0;i<NUM_OBJS;i++) {
tempo=o_sort[i];
if (tempo->z1<0) break;
s=100.0/(AbsI64(tempo->z1)+50);
GrIdentEqu(dc->r);
GrScaleMatEqu(dc->r,s*2);
GrSetRotMat(dc,dc->r);
dc->flags|=DCF_TRANSFORMATION;
if (tempo->sym) {
dc->flags|=DCF_SYMMETRY|DCF_JUST_MIRROR;
GrSetSymmetry(dc,s*tempo->x1+cx,s*tempo->y1+h,s*tempo->x1+cx,s*tempo->y1+h+10);
}
CSpritePlot3b(dc,s*tempo->x1+cx,s*tempo->y1+h,0,tempo->img);
dc->flags&=~(DCF_SYMMETRY|DCF_JUST_MIRROR);
if (o_sort[i]==objs) { //draw burning bush
dc->x=s*tempo->x1+cx;
dc->y=s*tempo->y1+h;
dc->z=0;
dc->pen_width=1;
dc->color=win_updates&15;
for (j=0;j<45;j++) {
m=Sqr(Rand); a=2*ă*Rand;
P2R(&x1,&y1,m,a);
m=Sqr(Rand); a=2*ă*Rand;
P2R(&x2,&y2,m,a);
GrLine3(dc,20*x1,20*y1-25,0,20*x2,20*y2-25,0);
}
if (SqrI64(s*tempo->x1)+SqrI64(s*tempo->y1)<300*300)
horeb_done=TRUE;
}
}
if (Blink(,tP(task))) {
dc->color=LTRED;
GrPutS(dc,cx-21*FONT_WIDTH/2,cy-FONT_HEIGHT/2,"Find the Burning Bush.");
}
}
U0 Init()
{
Obj *tempo;
I64 i;
for (i=0;i<NUM_OBJS;i++) {
tempo=&objs[i];
tempo->x=RandU32&0x1FFF-0x1000;
tempo->y=0;
tempo->z=RandU32&0x1FFF-0x1000;
tempo->sym=RandU16&1;
tempo->img=imgs[i%NUM_WEIGHED_IMGS];
}
vx=0; vz=0; é=0;
horeb_done=FALSE;
}
#define ANIMATE_STEPS 10
U0 AnimateéTask(F64 a)
{
I64 i;
for (i=0;i<ANIMATE_STEPS;i++) {
é+=a/ANIMATE_STEPS;
Sleep(10);
}
}
U0 AnimateVTask(F64 v)
{
I64 i;
for (i=0;i<ANIMATE_STEPS;i++) {
vx+=v/ANIMATE_STEPS*Sin(é);
vz+=v/ANIMATE_STEPS*Cos(é);
Sleep(10);
}
}
U0 Horeb()
{
I64 ch,sc;
MenuPush(
"File {"
" Abort(,CH_SHIFT_ESC);"
" Exit(,CH_ESC);"
"}"
"Play {"
" Restart(,CH_NEW_LINE);"
" Fwd(,,SC_CURSOR_UP);"
" Backward(,,SC_CURSOR_DOWN);"
" Left(,,SC_CURSOR_LEFT);"
" Right(,,SC_CURSOR_RIGHT);"
"}"
);
SettingsPush(Fs,TSF_SAME_SONG); //See $LK,"SettingsPush","MN:SettingsPush"$
try {
Fs->win_inhibit=WIF_ALL-WIF_GRAB_SCROLL-WIF_MENU;
WordStat;
WinMax;
WinBorder;
Preempt(OFF);
"$$CL$$$$BG,LTCYAN$$";
NewLine(6);
"$$BG,YELLOW$$";
NewLine(30);
PutBibleVerse("Exodus,3:1",21);
Init;
Fs->draw_it=&DrawHoreb;
while (!horeb_done) {
while (ScanKey(&ch,&sc))
switch (ch) {
case 0:
switch (sc.u8[0]) {
case SC_CURSOR_LEFT:
Spawn(&AnimateéTask,(-ă/100)(I64),"Animate é",Fs);
break;
case SC_CURSOR_RIGHT:
Spawn(&AnimateéTask,( ă/100)(I64),"Animate é",Fs);
break;
case SC_CURSOR_UP:
Spawn(&AnimateVTask,(-40.0 )(I64),"Animate V",Fs);
break;
case SC_CURSOR_DOWN:
Spawn(&AnimateVTask,( 40.0 )(I64),"Animate V",Fs);
break;
}
break;
case CH_NEW_LINE:
Init;
break;
case CH_SHIFT_ESC:
case CH_ESC:
goto hr_done;
}
WinMgrSync;
}
hr_done: //Don't goto out of try
} catch
Fs->catch_except=TRUE;
SettingsPop(Fs,TSF_SAME_SONG);
DocClear;
"$$BG$$";
MenuPop;
}
//This is so I can use this file stand alone
//or as a component of a program.
#if IncludeDepth<2
Horeb;
#endif
öţ˙˙˙č˙˙˙ô˙˙˙ę˙˙˙ţ˙˙˙î˙˙˙ú˙˙˙č˙˙˙ř˙˙˙ú˙˙˙ô˙˙˙ô˙˙˙ě˙˙˙â˙˙˙ú˙˙˙č˙˙˙ŕ˙˙˙
ě˙˙˙î˙˙˙ŕ˙˙˙ü˙˙˙î˙˙˙ř˙˙˙â˙˙˙ř˙˙˙ö˙˙˙ú˙˙˙ţ˙˙˙ú˙˙˙ü˙˙˙Ü˙˙˙ú˙˙˙đ˙˙˙ú˙˙˙ä˙˙˙ă ć˙˙˙ö˙˙˙ä˙˙˙ě˙˙˙ě˙˙˙ć˙˙˙ü˙˙˙ ä˙˙˙Ö˙˙˙Ö˙˙˙ć˙˙˙ć˙˙˙"ŕ˙˙˙ę˙˙˙$ä˙˙˙ě˙˙˙$ć˙˙˙ä˙˙˙ú˙˙˙ä˙˙˙ú˙˙˙ć˙˙˙ü˙˙˙ć˙˙˙ü˙˙˙î˙˙˙ú˙˙˙ ę˙˙˙"Ü˙˙˙&ć˙˙˙ä˙˙˙ ŕ˙˙˙
ţ˙˙˙ ü˙˙˙ ü˙˙˙đ˙˙˙ę˙˙˙ ř˙˙˙ ř˙˙˙č˙˙˙č˙˙˙ţ˙˙˙ţ˙˙˙î˙˙˙ě˙˙˙ţ˙˙˙ţ˙˙˙î˙˙˙
ö˙˙˙ ě˙˙˙ę˙˙˙đ˙˙˙đ˙˙˙ä˙˙˙â˙˙˙đ˙˙˙đ˙˙˙ę˙˙˙ę˙˙˙ú˙˙˙ ö˙˙˙”ú˙˙˙Ä˙˙˙ú˙˙˙Ä˙˙˙ř˙˙˙ú˙˙˙ü˙˙˙Â˙˙˙ü˙˙˙ú˙˙˙Ä˙˙˙ć˙˙˙¤˙˙˙ü˙˙˙Â˙˙˙ä˙˙˙¤˙˙˙ř˙˙˙Ľ˙˙˙ú˙˙˙†˙˙˙Ä˙˙˙ü˙˙˙„˙˙˙ţ˙˙˙ş˙˙˙
Ś˙˙˙
Ś˙˙˙ü˙˙˙¸˙˙˙¦˙˙˙š˙˙˙š˙˙˙z˙˙˙z˙˙˙„˙˙˙†˙˙˙ž˙˙˙ž˙˙˙v˙˙˙v˙˙˙ţ˙˙˙`˙˙˙ţ˙˙˙`˙˙˙ě˙˙˙„˙˙˙ě˙˙˙„˙˙˙ö˙˙˙¬˙˙˙ö˙˙˙¬˙˙˙â˙˙˙ž˙˙˙â˙˙˙ž˙˙˙Ř˙˙˙¨˙˙˙Ř˙˙˙¨˙˙˙î˙˙˙ş˙˙˙î˙˙˙ş˙˙˙ň˙˙˙ş˙˙˙ô˙˙˙¸˙˙˙ú˙˙˙¸˙˙˙
–˙˙˙�˙˙˙„˙˙˙Š˙˙˙ţ˙˙˙Ž˙˙˙ţ˙˙˙j˙˙˙ţ˙˙˙j˙˙˙ô˙˙˙‚˙˙˙ô˙˙˙‚˙˙˙ř˙˙˙ś˙˙˙ô˙˙˙´˙˙˙î˙˙˙¦˙˙˙č˙˙˙˛˙˙˙Ţ˙˙˙¦˙˙˙
ś˙˙˙–˙˙˙ř˙˙˙€˙˙˙h˙˙˙�˙˙˙€˙˙˙ţ˙˙˙~˙˙˙n˙˙˙~˙˙˙’˙˙˙
ś˙˙˙¨˙˙˙ö˙˙˙˛˙˙˙đ˙˙˙‚˙˙˙đ˙˙˙‚˙˙˙ú˙˙˙j˙˙˙ę˙˙˙´˙˙˙Ţ˙˙˙ ˙˙˙*XIÎ˙˙˙·˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙