// Some toast <1>/* Graphics Not Rendered in HTML */ <2>/* Graphics Not Rendered in HTML */ <3>/* Graphics Not Rendered in HTML */ <4>/* Graphics Not Rendered in HTML */ // ...and some toasters! <5>/* Graphics Not Rendered in HTML */ <6>/* Graphics Not Rendered in HTML */ <7>/* Graphics Not Rendered in HTML */ <8>/* Graphics Not Rendered in HTML */ #define NUM_TOAST_THINGS 24 // Keep less than 1/2 total #define NUM_TOASTERS 9 class ToastThing { I64 x,y, spd, type; }; ToastThing ToastThings[NUM_TOAST_THINGS]; U0 SpreadToastThings(I64 j) { I64 i, width=64, height=64; Bool spread=TRUE; while (spread) { spread=FALSE; for (i=0;i<NUM_TOAST_THINGS;i++) { while (((ToastThings[j].x-ToastThings[i].x)*(ToastThings[j].x-ToastThings[i].x) +(ToastThings[j].y-ToastThings[i].y)*(ToastThings[j].y-ToastThings[i].y))<64*64) { if (i==j) break; ToastThings[j].x+=width; ToastThings[j].y-=height; spread=TRUE; } } } } U0 InitToast() { I64 i=0,j,width=64,height=64; for (i=0;i<NUM_TOAST_THINGS;i++) { ToastThings[i].x=RandI64%(GR_WIDTH-width); ToastThings[i].y=RandI64%(GR_HEIGHT-height); ToastThings[i].spd=i%3+1; ToastThings[i].type=i%4; } for (i=0;i<NUM_TOAST_THINGS;i++) SpreadToastThings(i); for (i=0;i<NUM_TOASTERS;i++) { ToastThings[2*i].type=4; ToastThings[2*i].spd=i%3; } // Reset position of toast stuff for (j=0;j<NUM_TOAST_THINGS;j++) { while(ToastThings[j].x<GR_WIDTH+width&&ToastThings[j].y>-height) { ToastThings[j].x+=width; ToastThings[j].y-=height; } ToastThings[j].x+=j*width/2; ToastThings[j].y-=j*height/2; } } InitToast; I64 cur_iter=0; U0 DrawIt(CTask *,CDC *dc) { I64 i=0,j,spd,width=64,height=64,x=0,y=0,xdir=1,ydir=1; DCClear(dc); //TODO Toast Speed f(fps) i=cur_iter/2; i=i%36; for(j=0;j<NUM_TOAST_THINGS;j++) { spd=ToastThings[j].spd; x=ToastThings[j].x=ToastThings[j].x-(spd+1); y=ToastThings[j].y=ToastThings[j].y+(spd+1); if (x<-width || y>GR_HEIGHT+height) { // Reset position if flew off screen ToastThings[j].x=RandI64%(GR_WIDTH+width)-width; ToastThings[j].y=RandI64%(GR_HEIGHT+height)-height; while(ToastThings[j].x<GR_WIDTH+width&&ToastThings[j].y>-height) { ToastThings[j].x+=width; ToastThings[j].y-=height; } ToastThings[j].x+=width/2; ToastThings[j].y-=height/2; SpreadToastThings(j); } else { if (ToastThings[j].type>=4) { if ((i/(3-spd)+j)%6==0) { Sprite3(dc,x,y,0,<5>); } else if ((i/(3-spd)+j)%6==1) { Sprite3(dc,x,y,0,<6>); } else if ((i/(3-spd)+j)%6==2) { Sprite3(dc,x,y,0,<7>); } else if ((i/(3-spd)+j)%6==3) { Sprite3(dc,x,y,0,<8>); } else if ((i/(3-spd)+j)%6==4) { Sprite3(dc,x,y,0,<7>); } else { Sprite3(dc,x,y,0,<6>); } } else if (ToastThings[j].type == 0) { Sprite3(dc,x,y,0,<1>); } else if (ToastThings[j].type == 1) { Sprite3(dc,x,y,0,<2>); } else if (ToastThings[j].type == 2) { Sprite3(dc,x,y,0,<3>); } else if (ToastThings[j].type == 3) { Sprite3(dc,x,y,0,<4>); } } } cur_iter++; } U0 TempleToast() { SettingsPush; //See SettingsPush Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS- WIF_SELF_BORDER-WIF_FOCUS_TASK_MENU; Fs->text_attr=BLACK<<4+WHITE; //Current CTask is Fs segment register. AutoComplete; WinBorder; WinHorz(0,TEXT_COLS-1,); WinVert(0,TEXT_ROWS-1,); DocCursor; DocClear; ms.show=0; I64 arg1, arg2, msg_code; Fs->draw_it=&DrawIt; while (TRUE) { msg_code=GetMsg(&arg1,&arg2, 1<<MSG_KEY_DOWN+1<<MSG_MS_L_DOWN+1<<MSG_MS_L_UP+1<<MSG_MS_R_UP); break; } ms.show=1; SettingsPop; MenuPop; } TempleToast;