// 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,z, 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=RandRange(,GR_WIDTH-width); ToastThings[i].y=RandRange(,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; } } U0 ToastSS(CDC *dc, I64 cur_iter) { I64 i=0,j,spd,width=64,height=64,x=0,y=0,z=0,skip=0; if (!cur_iter) InitToast; DCClear(dc); i=30*cur_iter/GetFPS; i%=36; skip=30*cur_iter/GetFPS; for(j=0;j<NUM_TOAST_THINGS;j++) { if (!skip) spd=ToastThings[j].spd; else spd=0; 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=RandRange(-width,GR_WIDTH+width); ToastThings[j].y=RandRange(-height,GR_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,z,<5>); } else if ((i/(3-spd)+j)%6==1) { Sprite3(dc,x,y,z,<6>); } else if ((i/(3-spd)+j)%6==2) { Sprite3(dc,x,y,z,<7>); } else if ((i/(3-spd)+j)%6==3) { Sprite3(dc,x,y,z,<8>); } else if ((i/(3-spd)+j)%6==4) { Sprite3(dc,x,y,z,<7>); } else { Sprite3(dc,x,y,z,<6>); } } else if (ToastThings[j].type == 0) { Sprite3(dc,x,y,z,<1>); } else if (ToastThings[j].type == 1) { Sprite3(dc,x,y,z,<2>); } else if (ToastThings[j].type == 2) { Sprite3B(dc,x,y,z,<3>); } else if (ToastThings[j].type == 3) { Sprite3(dc,x,y,z,<4>); } } } } // Window manager tries to call this as // many times per second as the frame rate. // // Every time it is called it increments // ss_cnts starting with 0 // // Here we just use it once to copy the // current screen and spawn a task to // draw the screen saved version. gr.fp_draw_ss=&ToastSS;