File size: 2,276 Bytes
806d4b5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
/* You "Adam include" this because you want the wallpaper
routine to stay in mem even if this task is killed.
<CTRL-t> to see the hidden text needed for sprite elements.
<CTRL-r> to add a sprite to a document.
*/
<1>/* Graphics Not Rendered in HTML */
<2>/* Graphics Not Rendered in HTML */
<3>/* Graphics Not Rendered in HTML */
<4>/* Graphics Not Rendered in HTML */
<5>/* Graphics Not Rendered in HTML */
<6>/* Graphics Not Rendered in HTML */
<7>/* Graphics Not Rendered in HTML */
<8>/* Graphics Not Rendered in HTML */
<9>/* Graphics Not Rendered in HTML */
#define TYPES_OF_CRITTERS 3
#define FRAMES_PER_CRITTER 4
U8 *imgs[TYPES_OF_CRITTERS][FRAMES_PER_CRITTER]={
{<1>,<2>,<3>,<2>},
{<4>,<5>,<6>,<5>},
{<7>,<8>,<9>,<8>}
};
#define CRITTERS_NUM 16
class Critter
{
I64 x,y,dx,dy,type;
F64 t_offset;
} wall_crits[CRITTERS_NUM];
U0 (*old_wall_paper)(CTask *task);
U0 WallPaperFish(CTask *task)
{
I64 i,j,x,y;
CDC *dc=DCAlias(gr.dc2,task);
Critter *c=wall_crits;
task->text_attr=CYAN<<4+WHITE;
dc->color=BROWN;
for (i=0;i<GR_HEIGHT;i+=20) {
j=16*Tri(tS*10,20);
GrLine(dc,0,GR_HEIGHT-i-j,GR_HEIGHT-i-j,GR_HEIGHT);
}
for (i=0;i<CRITTERS_NUM;i++,c++) {
j=(tS*4+c->t_offset)%FRAMES_PER_CRITTER;
x=c->x>>16%GR_WIDTH;
if (x<0) x+=GR_WIDTH;
y=c->y>>16%GR_HEIGHT;
if (y<0) y+=GR_HEIGHT;
if (c->dx<0) {
dc->flags|=DCF_SYMMETRY|DCF_JUST_MIRROR;
DCSymmetrySet(dc,x,y-1,x,y+1);
} else
dc->flags&=~(DCF_SYMMETRY|DCF_JUST_MIRROR);
Sprite3(dc,x,y,0,imgs[c->type][j]);
c->x+=c->dx; c->y+=c->dy;
}
DCDel(dc);
//Uncomment the following if you wish.
//old_wall_paper(task);
}
U0 WallInit()
{
I64 i;
Critter *c;
if (Fs!=adam_task) {
"Must be Adam Included with SHIFT-F5.\n"
"(Would crash when code mem was freed.)\n";
return;
}
old_wall_paper=gr.fp_wall_paper;
c=wall_crits;
for (i=0;i<CRITTERS_NUM;i++,c++) {
c->x=(RandU16%GR_WIDTH)<<16;
c->y=(RandU16%GR_HEIGHT)<<16;
c->type=RandU16%TYPES_OF_CRITTERS;
c->dx=RandI16;
if (c->dx<0)
c->dx-=0x4000;
else
c->dx+=0x4000;
c->dy=RandI16;
c->t_offset=Rand*FRAMES_PER_CRITTER;
}
gr.fp_wall_paper=&WallPaperFish;
}
WallInit;
|