CD001^^ZZTempleOS RedSeaCD001EL TORITO SPECIFICATIONCD001^^ZZTempleOS RedSeaџCD001TempleOS.ЧUЊˆˆX ZDzКЩI UЊџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ.ZDzКЩI ..ZDzКЩI Animate.HC\д)<=ЅЩI Golf.HCq<=ЅЩI GroovyPt1.HC~Л<=ЅЩI Mouse.HCŠˆ<=ЅЩI Skeletal.HC˜ <=ЅЩI _2d.HCŸq7<=ЅЩI Porn.ISO.CЛv<=ЅЩI #ifndef TOON_PORN #define TOON_PORN"What the fuck nroot" #include "Skeletal.HC"; class CAnimation { //Use obj->ident=='Obj' or obj->ident=='Bone' union { C2DObject *obj; CBone *bone; }; #define ANIMT_MOVE 1 #define ANIMT_SPRITE 2 #define ANIMT_SWEEP 3 #define ANIMT_NOISE 4 //Sprites will randomly be selected as particles #define ANIMT_PARTICLE 5 #define ANIMT_PARTICLES 6 #define ANIMT_ROTX 7 #define ANIMT_ROTY 8 #define ANIMT_ROTZ 9 #define ANIMT_SCALE 10 I64 type; CD3 start; CD3 end; F64 spread_angle; U8 **sprites; I64 sprite_cnt,burst_cnt; F64 start_angle; F64 end_angle; F64 time; F64 freq; //Set to 0 for 1 run for all of *time* //Private F64 start_tS; CTask *anim_task; Bool done; }; CTask *mem_task=Fs; CAnimation *AnimationBurstParticlesFromObject(F64 time,I64 amt,C2DObject *obj,F64 x2,F64 y2,F64 spread=pi/6,...) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->time=time; anim->type=ANIMT_PARTICLES; anim->obj=obj; anim->end.x=x2; anim->end.y=y2; anim->burst_cnt=amt; anim->spread_angle=spread; anim->sprites=CAlloc(argc*8,mem_task); MemCpy(anim->sprites,argv,argc*8); anim->sprite_cnt=argc; return anim; } CAnimation *AnimationShotParticlesFromObject(F64 time,F64 freq=10,C2DObject *obj,F64 x2,F64 y2,F64 spread=pi/6,...) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->time=time; anim->type=ANIMT_PARTICLE; anim->obj=obj; anim->end.x=x2; anim->end.y=y2; anim->spread_angle=spread; anim->freq=freq; anim->sprites=CAlloc(argc*8,mem_task); MemCpy(anim->sprites,argv,argc*8); anim->sprite_cnt=argc; return anim; } CAnimation *AnimationNoiseSound(F64 time,I64 low,I64 hi) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->time=time; anim->type=ANIMT_NOISE; anim->start.x=low; anim->end.x=hi; return anim; } CAnimation *AnimationSweepSound(F64 time,I64 low,I64 hi) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->time=time; anim->type=ANIMT_SWEEP; anim->start.x=low; anim->end.x=hi; return anim; } CAnimation *AnimationScale(C2DObject *ob,F64 time,F64 low,F64 hi) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->time=time; anim->type=ANIMT_SCALE; anim->start.x=low; anim->end.x=hi; anim->obj=ob; return anim; } CAnimation *AnimationXRot(C2DObject *obj,F64 time=0,F64 ea=0) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->obj=obj; anim->type=ANIMT_ROTX; if(obj->ident=='Obj') { anim->start_angle=obj->rotx; } else if(obj->ident=='Bone') { //TODO } anim->end_angle=ea; anim->time=time; anim->freq=0; return anim; } CAnimation *AnimationZRot(C2DObject *obj,F64 time=0,F64 ea=0) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->obj=obj; anim->type=ANIMT_ROTZ; if(obj->ident=='Obj') { anim->start_angle=obj->rot; } else if(obj->ident=='Bone') { //TODO } anim->end_angle=ea; anim->time=time; anim->freq=0; return anim; } CAnimation *AnimationYRot(C2DObject *obj,F64 time=0,F64 ea=0) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->obj=obj; anim->type=ANIMT_ROTY; if(obj->ident=='Obj') { anim->start_angle=obj->roty; } else if(obj->ident=='Bone') { //TODO } anim->end_angle=ea; anim->time=time; anim->freq=0; return anim; } CAnimation *AnimationMove(C2DObject *obj,F64 time=0,F64 x,F64 y,F64 sa=0,F64 ea=0) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->obj=obj; anim->type=ANIMT_MOVE; if(obj->ident=='Obj') { anim->start.x=obj->x; anim->start.y=obj->y; } else if(obj->ident=='Bone') { anim->start.x=obj(CBone*)->x; anim->start.y=obj(CBone*)->y; } anim->end.x=x; anim->end.y=y; anim->start_angle=sa; anim->end_angle=ea; anim->time=time; anim->freq=0; return anim; } CAnimation *AnimationMove3D(C2DObject *obj,F64 time=0,F64 x,F64 y,F64 z) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->obj=obj; anim->type=ANIMT_MOVE; if(obj->ident=='Obj') { anim->start.x=obj->x; anim->start.y=obj->y; anim->start.z=obj->z; } else if(obj->ident=='Bone') { anim->start.x=obj(CBone*)->x; anim->start.y=obj(CBone*)->y; anim->start.z=obj(CBone*)->z; } anim->end.x=x; anim->end.y=y; anim->end.z=z; anim->time=time; anim->freq=0; return anim; } //Vargs are sprites to animate CAnimation *AnimationWalkCycle(C2DObject *obj,F64 time=0,F64 freq,...) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->type=ANIMT_SPRITE; anim->obj=obj; anim->freq=freq; anim->time=time; anim->sprites=CAlloc(argc*8); MemCpy(anim->sprites,argv,argc*8); anim->sprite_cnt=argc; return anim; } U0 AnimTask(CAnimation *a) { a->start_tS=tS; F64 en=a->time+a->start_tS,per,x,y,next_particle=tS; I64 idx,idx2; U8 **frames=a->sprites,*spr; U8 final_run=FALSE; F64 dist,an,dx,dy,dz; C2DObject *obj=a->obj,*particle; C2DObject *bone=a->obj; C2DObject *particles[0x100]; C2DWorld *w; CD3 particle_movements[0x100],tmp_cd2,*movement; Bool first=TRUE; static CD3 gravity={0,30*8,0}; MemSetI64(particles,NULL,0x100); I64 particle_cnt=0; while(TRUE) { if(enstart_tS)/a->time; switch(a->type) { case ANIMT_PARTICLES: for(idx=0;idxburst_cnt&&particle_cnt<0x100&&first;idx++) { dx=a->end.x; dy=a->end.y; dist=Sqrt(Sqr(dy)+Sqr(dx)); an=Arg(dx,dy); if(obj->ident=='Obj') { x=obj->x; y=obj->y; w=obj->world; } else if(obj->ident=='Bone') { x=obj(CBone*)->obj->x; y=obj(CBone*)->obj->y; w=obj(CBone*)->obj->world; } an+=(Rand-Rand)*a->spread_angle; particle_movements[particle_cnt].x=dist*Cos(an); particle_movements[particle_cnt].y=dist*Sin(an); spr=a->sprites[RandU16%a->sprite_cnt]; if(w) { if(particles[particle_cnt]) C2DObjectDel(particles[particle_cnt]); particles[particle_cnt]=particle=C2DObjectNewFromSprite(spr); AddObjectToWorld(particle,w); particle->x=x; particle->y=y; particle->rot=an; particle_cnt++; } } first=FALSE; goto update_particles; case ANIMT_PARTICLE: if(next_particle<=tS&&particle_cnt<0x100) { dx=a->end.x; dy=a->end.y; dist=Sqrt(Sqr(dy)+Sqr(dx)); an=Arg(dx,dy); if(obj->ident=='Obj') { x=obj->x; y=obj->y; w=obj->world; } else if(obj->ident=='Bone') { x=obj(CBone*)->obj->x; y=obj(CBone*)->obj->y; w=obj(CBone*)->obj->world; } an+=(Rand-Rand)*a->spread_angle; particle_movements[particle_cnt].x=dist*Cos(an); particle_movements[particle_cnt].y=dist*Sin(an); spr=a->sprites[RandU16%a->sprite_cnt]; if(w) { if(particles[particle_cnt]) C2DObjectDel(particles[particle_cnt]); particles[particle_cnt]=particle=C2DObjectNewFromSprite(spr); AddObjectToWorld(particle,w); particle->x=x; particle->y=y; particle->rot=an; particle_cnt++; } next_particle=1./(a->freq)+tS; } update_particles: for(idx=0;idx!=particle_cnt;idx++) { if(particle=particles[idx]) { movement=&particle_movements[idx]; dx=movement->x; dy=movement->y; movement->z=0; particle->rot=Arg(dx,dy); particle->x+=dx*1./winmgr.fps; particle->y+=dy*1./winmgr.fps; movement->y+=gravity.y*1/winmgr.fps; tmp_cd2.z=0; } } if(final_run==1) { a->done=TRUE; //Wait 2 seconds for all particles to disappear(hopefuly) en=2.+tS; final_run++; Refresh; goto update_particles; } else if(final_run==2 ) { if(tS>en) break; Refresh; goto update_particles; } break; case ANIMT_MOVE: dx=a->end.x-a->start.x; dy=a->end.y-a->start.y; dz=a->end.z-a->start.z; dist=Sqrt(Sqr(dy)+Sqr(dx)); an=Arg(dx,dy); if(obj->ident=='Obj') { if(dx) obj->x=a->start.x+dist*per*Cos(an); if(dy) obj->y=a->start.y+dist*per*Sin(an); if(dz) obj->z=a->start.z+per*dz; if(a->start_angle!=a->end_angle) obj->rot=per*(a->end_angle-a->start_angle)+a->start_angle; } else if(obj->ident=='Bone') { if(dx) obj(CBone*)->x=a->start.x+dist*per*Cos(an); if(dy) obj(CBone*)->y=a->start.y+dist*per*Sin(an); if(dz) obj(CBone*)->y=a->start.z+dz*per; if(a->start_angle!=a->end_angle) obj(CBone*)->rot=per*(a->end_angle-a->start_angle)+a->start_angle; } break; case ANIMT_SWEEP: Sweep(1000*a->time,a->start.x,a->end.x); Sleep(1000*a->time); goto fin; case ANIMT_NOISE: Noise(1000*a->time,a->start.x,a->end.x); Sleep(1000*a->time); goto fin; case ANIMT_SPRITE: idx=ToI64(per*a->time*a->freq); idx2=idx+1; idx%=a->sprite_cnt; idx2%=a->sprite_cnt; dx=per*a->time*a->freq%1.; spr=SpriteInterpolate(dx,frames[idx],frames[idx2]); if(obj->ident=='Bone') { C2DObjectSetGraphicsFromSprite(obj(CBone*)->obj,spr); } else if(obj->ident=='Obj') { C2DObjectSetGraphicsFromSprite(obj,spr); } Free(spr); break; case ANIMT_ROTX: an=per*(a->end_angle-a->start_angle)+a->start_angle; if(obj->ident=='Bone') { //TODO } else if(obj->ident=='Obj') { obj->rotx=an; } break; case ANIMT_ROTY: an=per*(a->end_angle-a->start_angle)+a->start_angle; if(obj->ident=='Bone') { //TODO } else if(obj->ident=='Obj') { obj->roty=an; } break; case ANIMT_SCALE: an=per*(a->end.x-a->start.x)+a->start.x; if(obj->ident=='Bone') { obj(CBone*)->obj->scale=an; } else if(obj->ident=='Obj') { obj->scale=an; } break; case ANIMT_ROTZ: an=per*(a->end_angle-a->start_angle)+a->start_angle; if(obj->ident=='Bone') { //TODO } else if(obj->ident=='Obj') { obj->rot=an; } break; } if(final_run) break; Refresh; } fin: a->done=TRUE; for(idx=0;idx!=particle_cnt;idx++) if(particle=particles[idx$WW,1$]) { C2DObjectDel(particle); } } U0 AnimScene(...) { I64 idx; F64 total=0; Bool all_done=FALSE; CAnimation *anim; for(idx=0;idx!=argc;idx++) { anim=argv[idx]; anim->anim_task=Spawn(&AnimTask,anim,,,Fs); total=Max(anim->time,total); } for(idx=0;idx!=argc;idx++) { anim=argv[idx]; if(!anim->time) anim->time=total; } Sleep(total*1000); while(!all_done) { all_done=TRUE; for(idx=0;idx!=argc;idx++) { anim=argv[idx]; if(!anim->done) all_done=FALSE; } Refresh; } } #endif $SP,"<1>",BI=1$ $SP,"<2>",BI=2$ $SP,"<3>",BI=3$ $SP,"<4>",BI=4$ $SP,"<5>",BI=5$ $SP,"<6>",BI=6$ $SP,"<7>",BI=7$ $SP,"<8>",BI=8$ $SP,"<9>",BI=9$ $SP,"<10>",BI=10$ $SP,"dummy",BI=11$ #define SCRN_SCALE 512 U0 DCTransform(CDC *dc,I64 *x,I64 *y,I64 *z) { I64 zz; Mat4x4MulXYZ(dc->r,x,y,z); zz=SCRN_SCALE/3+*z; if (zz<1) zz=1; *x=SCRN_SCALE/2* *x/zz; *y=SCRN_SCALE/2* *y/zz; *x+=dc->x; *y+=dc->y; *z+=dc->z; } #include "Animate"; C2DWorld *w=C2DWorldNew(WHITE); C2DObject *golf_stick=C2DObjectNewFromSprite($IB,"<1>",BI=1$); C2DObject *balls=C2DObjectNewFromSprite($IB,"<4>",BI=4$); C2DObject *dick=C2DObjectNewFromSprite($IB,"<5>",BI=5$); C2DObject *ball=C2DObjectNewFromSprite($IB,"<6>",BI=6$); C2DObject *guy=C2DObjectNewFromSprite($IB,"<7>",BI=7$); C2DObject *cum=C2DObjectNewFromSprite($IB,"<9>",BI=9$); C2DObject *shit=C2DObjectNewFromSprite($IB,"<10>",BI=10$); C2DObject *dummy=C2DObjectNewFromSprite($IB,"<11>",BI=11$); golf_stick->flags|=C2DOBJF_MESH; AddObjectToWorld(golf_stick,w); AddObjectToWorld(balls,w); AddObjectToWorld(dick,w); AddObjectToWorld(ball,w); U0 DrawIt(CTask *t,CDC *dc) { DrawWorld(t,w); GrBlot(dc,0,0,w->scrn); } U0 SongTask(I64) { Fs->task_end_cb=&SndTaskEndCB; music.mute=0; MusicSettingsRst; while (TRUE) { Play("$FG$$BG$5M6/8e.Gs4G5C4B5C4B5G4G5G4Gq5Get4G5CFsG4G5G4G"); } } U0 Movie() { I64 cnt; w->scrn->transform=&DCTransform; golf_stick->z=700; Fs->draw_it=&DrawIt; Spawn(&SongTask,,,,Fs); WinMax; golf_stick->scale=2.4; balls->x=310; balls->y=300; balls->z=700; dick->x=310; dick->y=300; dick->z=700; ball->x=340; ball->y=165; ball->z=700; golf_stick->x=-1000; golf_stick->roty=pi/3.5; //Scene 1 AnimScene( AnimationMove3D(golf_stick,1.,400,300,golf_stick->z) ); AnimScene( AnimationXRot(golf_stick,1,-pi/2), ); AnimScene( AnimationSweepSound(.1,50,70), AnimationXRot(golf_stick,.1,0), ); AnimScene( AnimationScale(balls,.1,1.,1./10.), AnimationMove(balls,.3,GR_WIDTH,0), AnimationXRot(golf_stick,.05,pi/4), ); // Scene 2 C2DObjectDel(golf_stick); C2DObjectDel(balls); C2DObjectDel(dick); C2DObjectDel(ball); balls=C2DObjectNewFromSprite($IB,"<4>",BI=4$); AddObjectToWorld(balls,w); balls->x=-100; balls->y=GR_HEIGHT/2; AnimScene( AnimationMove(balls,.5,GR_WIDTH,GR_HEIGHT/2,0,8*pi) ); balls->x=GR_WIDTH/2; balls->y=GR_HEIGHT/2+100; balls->rot=0; guy->x=GR_WIDTH/2-100; guy->y=100; guy->priority=-1; AddObjectToWorld(guy,w); AnimScene( ); AnimScene( AnimationSweepSound(1.,100,40), AnimationWalkCycle(guy,1.,1.1,$IB,"<7>",BI=7$,$IB,"<8>",BI=8$), AnimationMove(balls,1,GR_WIDTH/2,GR_HEIGHT/2), AnimationZRot(balls,1,16*pi) ); C2DObjectDel(balls); AddObjectToWorld(cum,w); cum->x=guy->x; cum->y=guy->y; cum->priority=1; AnimScene( AnimationNoiseSound(.5,30,40) ); Sleep(1000); dummy->x=250; dummy->y=270; AddObjectToWorld(dummy,w); for(cnt=0;cnt!=10;cnt++) { AnimScene( AnimationNoiseSound(.1,40,60), AnimationBurstParticlesFromObject(.1,1,dummy,150*3,-128*2,pi/8,$IB,"<10>",BI=10$) ); } Exit; } Movie; 22Ш}Шsм2м-Ш-Ш}с7Œв7-м7-Ш7ћџџџ72ћџџџ7-Ш7000 0 0 0 0  0  0 0 0  0 0           ­ ќџџџьџџџюџџџщџџџпџџџрџџџбџџџоџџџМџџџцџџџИџџџёџџџЛџџџТџџџУџџџ МџџџЗџџџМџџџ'гџџџ.№џџџ$џџџџ  ќџџџъџџџшџџџїџџџ !!ёџџџ#Эџџџ!™џџџ.˜џџџ0џџџ-‚џџџ)xџџџ'xџџџsџџџsџџџuџџџzџџџ‚џџџvџџџrџџџsџџџzџџџќџџџ‚џџџљџџџџџџњџџџ“џџџќџџџ“џџџ–џџџ рџџџњџџџчџџџ їџџџчџџџ ёџџџ ˜џџџ —џџџ‹џџџ#Ыџџџ3иџџџ  эџџџ ўџџџьџџџ цџџџщџџџ нџџџдџџџ ыџџџжџџџ$ кџџџI’ иџџџQ’$! Хџџџ  Тџџџ ќџџџЩџџџл0l эџџџСџџџ цџџџЖџџџ ѓџџџЏџџџ јџџџБџџџ$ Гџџџ Дџџџ Іџџџ жџџџУџџџˆ єџџџїџџџоџџџмџџџУџџџЃџџџФџџџДџџџ)Мџџџ@дџџџ0эџџџ#чџџџ7§џџџ9  ѓџџџѕџџџ иџџџˆ єџџџїџџџЛџџџшџџџУџџџЫџџџФџџџДџџџ)Мџџџ@йџџџ&пџџџ4ѓџџџ>љџџџђџџџ ѓџџџѕџџџ иџџџј7A? 9‚:Ш!ф :ЦJм ]›8š0-&Q'L&' )M($I“d’$щц­нj›$%& ,(Œ‚ XыйЖ}’L€ ™}лф 9Z+€ј;@? =>Ч%у >ХNл aš<œ™4,!%U&P%& )Q'$I“d’$щц­нj›$%& ,#'Œ‚ XыйЖ}’L€ ™}лф =Y3 8@њџџџ4 №џџџ/ўџџџ8 E§џџџZz"n5p>‡Y‚Odkl„esH7{$o&tbW B№џџџS4 б §џџџ(170)*5.D5J4i"i"s.z/…'Š%‹€m`?93 ) ' ! >" U w e U! 6  ." #include "Animate.HC"; //0123456789abcdef //0$SP,"<1>",BI=1$ //1 //2 //3 //4 //5 //6 //8$SP,"<2>",BI=2$ //9 //a //b //c //d //e //f //0123456789abcdef0123456789a //0$SP,"<3>",BI=3$$ER$ //1 //2 //3 //4 //5 //6 //7 //8$SP,"<4>",BI=4$ //9 //a //b //c //d //e //f //0123456789abcdef0123456789a //0$SP,"<5>",BI=5$ //1 //2 //3 //4 //5 //6 //7 //8 //9 //a //b //c //d //e //f //Sting // $SP,"<6>",BI=6$ //0123456789abcdef0123456789a //0$SP,"<7>",BI=7$ //1 //2 //3 //4 //5 //6 //7 //8 //9 //a //b //c //d //e //f //0123456789abcdef0123456789a //0$SP,"<8>",BI=8$ //1 //2 //3 //4 //5 //6 //7 //8 //9 //a //b //c //d //e //f //0123456789abcdef0123456789a //0 $SP,"<9>",BI=9$ //1 //2 //3 //4 //5 //6 //7 //8 //9 //a //b //c //d //e //f //0123456789abcdef0123456789a //0 $SP,"<10>",BI=10$ //1 //2 //3 //4 //5 //6 //7 //8 //9 //a //b //c //d //e //f $SP,"<11>",BI=11$ C2DWorld *w=C2DWorldNew(BLACK); C2DObject *s_head=C2DObjectNewFromSprite($IB,"<1>",BI=1$); C2DObject *s_body=C2DObjectNewFromSprite($IB,"<3>",BI=3$); C2DObject *s_tail=C2DObjectNewFromSprite($IB,"<5>",BI=5$); C2DObject *dick=C2DObjectNewFromSprite($IB,"<7>",BI=7$); C2DObject *claw_top=C2DObjectNewFromSprite($IB,"<9>",BI=9$); C2DObject *claw_bottom=C2DObjectNewFromSprite($IB,"<10>",BI=10$); CBone *claw_top_b=BoneNew(claw_top); CBone *claw_bottom_b=BoneNew(claw_bottom); CBone *s_head_b=BoneNew(s_head); CBone *s_tail_b=BoneNew(s_tail); CBone *s_body_b=BoneNew(s_body); claw_bottom_b->x=-80; QueIns(claw_bottom_b,&claw_top_b->child_bones); QueIns(claw_top_b,&s_body_b->child_bones); QueIns(s_tail_b,&s_body_b->child_bones); QueIns(s_head_b,&s_body_b->child_bones); AddObjectToWorld(s_body,w); AddObjectToWorld(s_head,w); AddObjectToWorld(s_tail,w); AddObjectToWorld(dick,w); AddObjectToWorld(claw_top,w); AddObjectToWorld(claw_bottom,w); claw_top->priority=-1; claw_bottom_b->rot=-pi/2; s_tail_b->x=0x10*8; dick->y=190; dick->x=80; U0 DrawIt(CTask *t,CDC *dc) { BoneUpdate(s_body_b); DrawWorld(t,w); GrBlot(dc,0,0,w->scrn); } F64 Lerp(F64 t,F64 a,F64 b) { return t*(b-a)+a; } U0 SongTask(I64) { Fs->task_end_cb=&SndTaskEndCB; music.mute=0; MusicSettingsRst; while (TRUE) { Play("$FG$$BG$5M6/8e.Gs4G5C4B5C4B5G4G5G4Gq5Get4G5CFsG4G5G4G"); } } U0 Movie() { F64 st_start_tS=tS; Fs->draw_it=&DrawIt; Spawn(&SongTask,,,,Fs); WinMax; w->background_color=TRANSPARENT; I64 part=0; U8 *spr; FlushMsgs; s_body_b->y=258; s_body_b->x=GR_WIDTH; AnimScene( AnimationMove(s_body_b,3.,250,258), AnimationWalkCycle(s_body_b,,6,$IB,"<3>",BI=3$,$IB,"<4>",BI=4$) ); AnimScene( AnimationSweepSound(1/8.,100,10), AnimationMove(claw_bottom_b,1/8.,claw_bottom_b->x,claw_bottom_b->y,-pi/2,0), AnimationWalkCycle(s_tail,,8.,$IB,"<5>",BI=5$,$IB,"<6>",BI=6$) ); AnimScene( AnimationWalkCycle(s_head,1,1,$IB,"<1>",BI=1$,$IB,"<2>",BI=2$) ); for(part=0;part!=5;part++) AnimScene( AnimationNoiseSound(.3,40,60), AnimationBurstParticlesFromObject(.3,5,s_body_b,150*10,128,pi/4,$IB,"<11>",BI=11$) ); Fs->draw_it=0; } Movie; Ќцџџџ.>ЗЃYFй•Пќџџџыџџџ яџџџоџџџ яџџџоџџџлЖm! лџџџ юџџџоџџџжџџџѓџџџщџџџ ьџџџѕџџџѕџџџєџџџЫ ўџџџˆ  #9 9G1B: RO+U7 gr0bC €.A //->^ ћџџџ іџџџцџџџлџџџЭџџџЪџџџіџџџЫџџџэџџџЬџџџюџџџЫџџџфџџџЬџџџ^  ќџџџьџџџсџџџНџџџЎџџџћџџџКџџџтџџџСџџџтџџџОџџџ#џџџзџџџš ,@AяџџџJяџџџRѕџџџTіџџџWџџџџWJ WYSJEA  !'!4+?:?<@G9X6Y,]"\ZQIGPYўџџџ_ќџџџ\ђџџџRяџџџCюџџџ5ћџџџќџџџўџџџўџџџ ? ? Iјџџџ(Ы ўџџџ!   9 9@!</ RO+UH ge'`0 ‰A}"lB *' 2x ўџџџ CCіџџџHјџџџOџџџџRT TCPTTP%H*A%B>< =X&S*b)q#x~~xrrsїџџџzэџџџшџџџ€лџџџtкџџџ`тџџџWюџџџTќџџџU§џџџўџџџ %  F й =џџџяџџџ,џџџџџџџ,џџџ @џџџ#Lџџџ Wџџџfџџџrџџџ|џџџ €џџџ”џџџ—џџџЉџџџИџџџњџџџЛџџџџџџџВџџџєџџџЅџџџьџџџŒџџџцџџџyџџџуџџџRџџџцџџџ>џџџчџџџ;џџџѓџџџџџџ№џџџ б џџџћџџџˆџџџ ‰џџџ”џџџ%Їџџџ(Еџџџ)аџџџ&шџџџ ѕџџџќџџџўџџџяџџџќџџџсџџџнџџџдџџџћџџџЫџџџУџџџМџџџЖџџџџџџџЋџџџЂџџџўџџџžџџџ џџџ§џџџдџџџЌцџџџ-!>ЗЃYFй•Пќџџџыџџџ яџџџоџџџ яџџџоџџџлЖm! лџџџ юџџџоџџџжџџџѓџџџщџџџ ьџџџѕџџџєџџџ " `лЖmлАmumзЖ]л6I’4Iђ$I’$I’$IŠЩџїmпЗm›Ї$‰’DIЂD‰ЂH’$yоїџŸфyпП›%ŠЂ(ŠЂI”$%J˜„I$й†mи†m`‚ лж­›зvоЖnлАmлЖm`@€ ‚dнЖyлЖmнМ­[НКuлжu]з, ? b n = *  ^ #include "Animate.HC"; $SP,"<1>",BI=1$ $SP,"<2>",BI=2$ $SP,"<3>",BI=3$ $SP,"<4>",BI=4$ $SP,"<5>",BI=5$ $SP,"<6>",BI=6$ $SP,"<7>",BI=7$ $SP,"<8>",BI=8$ $SP,"<9>",BI=9$ $SP,"<10>",BI=10$ $SP,"<11>",BI=11$ U0 SongTask(I64) { Fs->task_end_cb=&SndTaskEndCB; music.mute=0; MusicSettingsRst; while (TRUE) { Play("$FG$$BG$5M6/8e.Gs4G5C4B5C4B5G4G5G4Gq5Get4G5CFsG4G5G4G"); } } C2DWorld *w=C2DWorldNew(WHITE); C2DObject *mouse=C2DObjectNewFromSprite($IB,"<1>",BI=1$); C2DObject *wall=C2DObjectNewFromSprite($ER$$IB,"<5>",BI=5$); C2DObject *hole=C2DObjectNewFromSprite($ER$$IB,"<4>",BI=4$); C2DObject *trap=C2DObjectNewFromSprite($IB,"<6>",BI=6$); C2DObject *dick=C2DObjectNewFromSprite($IB,"<9>",BI=9$); AddObjectToWorld(wall,w); AddObjectToWorld(mouse,w); AddObjectToWorld(hole,w); AddObjectToWorld(trap,w); U0 DrawIt(CTask *t,CDC *dc) { DrawWorld(t,w); GrBlot(dc,0,0,w->scrn); } U0 Movie() { F64 st_start_tS=tS; Fs->draw_it=&DrawIt; Spawn(&SongTask,,,,Fs); WinMax; WinBorder(0); w->background_color=TRANSPARENT; I64 part=0; U8 *spr; FlushMsgs; trap->y=-400; trap->x=320; mouse->y=270; mouse->x=0; wall->x=300; wall->y=270; hole->x=300; hole->y=275; AnimScene( AnimationMove(mouse,1.4,500,270), AnimationWalkCycle(mouse,,6,$IB,"<1>",BI=1$,$IB,"<2>",BI=2$) ); AnimScene( AnimationMove(trap,.4,trap->x,470) ); dick->x=-200; dick->y=trap->y-100; dick->rot=pi/2; AddObjectToWorld(dick,w); AnimScene( AnimationMove(dick,1,trap->x*.8,dick->y) ); AnimScene( AnimationMove(dick,.1,trap->x*.8,dick->y+80), AnimationSweepSound(.3,10,80), AnimationZRot(dick,.1,0), AnimationWalkCycle(dick,.5,1/.5,$IB,"<9>",BI=9$,$IB,"<10>",BI=10$), AnimationWalkCycle(trap,.15,1/.15*2,$IB,"<6>",BI=6$,$IB,"<7>",BI=7$,$IB,"<8>",BI=8$) ); mouse->flipped=TRUE; AnimScene( AnimationWalkCycle(mouse,1/2.,2,$IB,"<1>",BI=1$,$IB,"<3>",BI=3$), AnimationNoiseSound(.3,40,60), AnimationBurstParticlesFromObject(.3,5,mouse,-1000,-128,pi/5,$IB,"<11>",BI=11$) ); for(part=0;part!=5;part++) AnimScene( AnimationNoiseSound(.3,40,60), AnimationBurstParticlesFromObject(.3,5,mouse,-2000,-128,pi/3,$IB,"<11>",BI=11$) ); Fs->draw_it=0; }; Movie;–N26 $D^0g <K<XIU _Jacpd rApOƒQ/ћџџџЅ$" ‹yљџџџ— А ЧњџџџС‘-Ѓ/Й-™ ,RЅржШ?Д  Г ˜ ЅX: Л‰–N26 $D#X1W <K<eLe _JaVmU rAr_†^/ Ѓ" ‰wѓџџџ• ЎХєџџџП'Ё)З'—,RЅржШ?Вџџџџ Б –ЃX: Й‡ І l5вœв8ЯСВЈ– ‘‘vџџџ{$џџџf0 аš‹rЊ< ™Аџџџ– ЅњџџџЇ€Ь˜а0ЫНЃјџџџЗS ЃїџџџНцџџџIйџџџšоџџџЃS†•Ю™ќDL й%1у іОЋџџџіџџџеџџџ2 е№ўџџџ:лџџџL шџџџ ‘нѕџџџБНџџџ]Ыџџџ |ўџџџ|ѕџџџїџџџpјџџџoыџџџvьџџџaъџџџ`сџџџfрџџџlнџџџ]тџџџUлџџџUдџџџ_Щџџџ pюџџџ#їџџџьџџџL й%1у іОЋџџџіџџџеџџџ2 е№ўџџџ:лџџџL шџџџ ‘ЂДџџџgxџџџ]Ыџџџ |ўџџџ|ѕџџџїџџџpјџџџoыџџџvьџџџaъџџџ`сџџџfрџџџlнџџџ]тџџџUлџџџUдџџџ_Щџџџ pюџџџ#їџџџьџџџL й%1у іОЋџџџіџџџеџџџ2 е№ўџџџ:лџџџL шџџџ ‘$лџџџ]Ыџџџ |ўџџџ|ѕџџџїџџџpјџџџoыџџџvьџџџaъџџџ`сџџџfрџџџlнџџџ]тџџџUлџџџUдџџџ_Щџџџ pюџџџ#їџџџьџџџ e -7(A4`8q,zz_јџџџYїџџџzџџџџ†їџџџ–чџџџ‘Шџџџ‚ПџџџdНџџџIПџџџAтџџџ"уџџџ"cџџџ .(џџџџ ўџџџџџџџџџџџaџџџ"aџџџ9dџџџ7Sџџџ29џџџ"*џџџ$џџџ;џџџ$џџџџџџџџџџџџџљџџџ џџџѓџџџ%џџџьџџџ4џџџъџџџ9џџџшџџџDџџџхџџџLџџџфџџџUџџџуџџџ`џџџbџџџЭџџџ ќџџџSџџџџ Uaпџџџ@A€I$IЂ(Š”(Fa’$I’$I mRџџџџ"I’$)Š$I’$}џўmћЖMлЖmгіmкџлЗЭџчyžчy’$y’$) LTлЖmыкжЕmлЖmпОmзnЛmѓЖЭл6oл6oы ?mйџџџLТР0I’$R$I’D’$Р&’"I’ЄH 8@ўџџџи€mлЖmЕ]лЕ]лЕнЕ]лЖлv e <M&T*a&puqўџџџ_јџџџYїџџџsєџџџэџџџŽрџџџŒШџџџwУџџџcЬџџџQгџџџAтџџџ"уџџџ"cџџџ <(џџџџ ўџџџџџџџџџџџaџџџ"aџџџ9dџџџ7Sџџџ29џџџ"*џџџ$џџџ;џџџ$џџџџџџџџџџџџџљџџџ џџџѓџџџ%џџџьџџџ4џџџъџџџ9џџџшџџџDџџџхџџџLџџџфџџџUџџџуџџџ`џџџbџџџЭџџџ ќџџџSџџџџ Uaпџџџ@A€I$IЂ(Š”(Fa’$I’$I mRџџџџ"I’$)Š$I’$}џўmћЖMлЖmгіmкџлЗЭџчyžчy’$y’$) LTлЖmыкжЕmлЖmпОmзnЛmѓЖЭл6oл6oы ?mйџџџLТР0I’$R$I’D’$Р&’"I’ЄH 8@ўџџџи€mлЖmЕ]лЕ]лЕнЕ]лЖлv " `лЖmлАmumзЖ]л6I’4Iђ$I’$I’$IŠЩџїmпЗm›Ї$‰’DIЂD‰ЂH’$yоїџŸфyпП›%ŠЂ(ŠЂI”$%J˜„I$й†mи†m`‚ лж­›зvоЖnлАmлЖm`@€ ‚dнЖyлЖmнМ­[НКuлжu]з, ? b n = *  ^ –N26 $D#X1W <K<eLe _JaVmU rAr_†^/ Ѓ" ‰wѓџџџ• ЎХєџџџП'Ѕ?З'—,RЅржШ?Вџџџџ Џ –ЃX: Й‡ #ifndef SKELETAL #define SKELETAL #include "_2d.HC"; class CBone:CQue { U64 ident; C2DObject *obj; //Bone takes rotation from rot #define BONE_M_NORMAL 0 //Bone points to point_x,point_y motherfucker(point_rot_off is added to rot) #define BONE_M_POINT_TO 1 I64 mode; #define BONE_F_FLIP 1 I64 flags; F64 x,y,z,length; F64 point_x,point_y,point_rot_off; F64 rot; CQue child_bones; }; CBone *BoneNew(C2DObject *obj,CTask *mem_task=NULL) { CBone *b=CAlloc(sizeof CBone,mem_task); b->ident='Bone'; b->obj=obj; QueInit(&b->child_bones); return b; } U0 BoneSetFlip(CBone *bone,Bool on=TRUE) { if(!on) {bone->obj->flipped=TRUE;bone->flags|=BONE_F_FLIP;} else {bone->flags&=~BONE_F_FLIP;bone->obj->flipped=FALSE;} CBone *head=&bone->child_bones,*cur; for(cur=head->next;cur!=head;cur=cur->next) BoneSetFlip(cur,on); } F64 FlipAngle(F64 a) { return (pi-a)+pi; } U0 BoneUpdate(CBone *bone,CBone *parent=NULL) { CBone *head,*cur; F64 dist,ang,flip=1; if(parent&&parent->flags&BONE_F_FLIP) flip=-1; if(!parent) { bone->obj->x=bone->x; bone->obj->y=bone->y; bone->obj->rot=bone->rot; bone->obj->flipped=!!(bone->flags&BONE_F_FLIP); } else { switch(bone->mode) { start: bone->obj->x=parent->obj->x; bone->obj->y=parent->obj->y; dist=Sqrt(Sqr(bone->x)+Sqr(bone->y)); ang=Arg(flip*bone->x,bone->y); bone->obj->x+=dist*Cos(parent->obj->rot+ang); bone->obj->y+=dist*Sin(parent->obj->rot+ang); case BONE_M_NORMAL: if(!(bone->flags&BONE_F_FLIP)) bone->obj->rot=bone->rot+parent->obj->rot; else bone->obj->rot=FlipAngle(bone->rot)+parent->obj->rot; break; case BONE_M_POINT_TO: if(!(bone->flags&BONE_F_FLIP)) bone->obj->rot=Arg(bone->point_x-bone->obj->x,bone->point_y-bone->obj->y)+bone->point_rot_off; else bone->obj->rot=FlipAngle(Arg(-(bone->point_x-bone->obj->x),bone->point_y-bone->obj->y)+bone->point_rot_off); break; end:; } } head=&bone->child_bones; for(cur=head->next;cur!=head;cur=cur->next) { BoneUpdate(cur,bone); } } #if __CMD_LINE__ C2DWorld *w=C2DWorldNew(BLACK); CDC*rect1=DCNew(200,50); CDC*rect2=DCNew(100,50); DCFill(rect1,YELLOW); DCFill(rect2,CYAN); CDC*sq=DCNew(50,50); DCFill(sq,RED); C2DObject *arm=C2DObjectNewFromDC(rect1); C2DObject *arm2=C2DObjectNewFromDC(rect2); C2DObject *hand=C2DObjectNewFromDC(sq); C2DObjectMoveCenter(arm,0,25); C2DObjectMoveCenter(arm2,0,25); C2DObjectMoveCenter(hand,0,0); CBone *arm_bone=BoneNew(arm); CBone *arm_bone2=BoneNew(arm2); arm_bone->x=0,arm_bone->y=0; arm_bone2->x=200,arm_bone2->y=25; CBone *hand_bone=BoneNew(hand); hand_bone->x=100; hand_bone->y=0; QueIns(arm_bone2,&arm_bone->child_bones); QueIns(hand_bone,&arm_bone2->child_bones); AddObjectToWorld(arm,w); AddObjectToWorld(arm2,w); AddObjectToWorld(hand,w); //Recursive U0 DrawIt(CTask *t,CDC *dc) { DrawWorld(Fs,w); GrBlot(dc,0,0,w->scrn); } FlushMsgs; WinMax; U0 Foo() { Fs->draw_it=&DrawIt; while(!ScanKey) { arm_bone->x=GR_WIDTH/2; arm_bone->y=GR_HEIGHT/2; arm_bone->rot=tS; arm_bone2->rot=tS*3; arm_bone2->mode=BONE_M_POINT_TO; arm_bone->point_x=0; arm_bone->point_y=0; BoneUpdate(arm_bone); BoneSetFlip(arm_bone,Blink(.5)); Refresh; } Exit; }; Foo; #endif #endif#ifndef ENGINE_2D #define ENGINE_2D //2 dimensional object extern class C2DWorld; class C2DObject:CQue { U64 ident; //See replace_color/with_color #define C2DOBJF_REPLACE_COLOR 1 #define C2DOBJF_MESH 2 I64 flags; union { CDC *graphics; U8 *sprite; }; F64 x,y,z; F64 center_x,center_y; F64 center_z; F64 rot; F64 rotx,roty; F64 scale; F64 priority; F64 width,height; //This matrix includes all transofrmations U64 *mat; Bool flipped; Bool is_sprite; U8 replace_color; U8 with_color; U8 pad[4]; CTask *mem_task; I64 user_data,lock; U8 name[STR_LEN]; //Private I64 _blot_at_x,_blot_at_y; CDC *_blot_dc; C2DWorld *world; }; CTask *mem_task=Fs; class C2DWorld { I64 background_color; CDC *scrn; CQue objects; I64 in_draw; }; C2DWorld *C2DWorldNew(I64 background_color=BLACK) { C2DWorld *ret=CAlloc(sizeof C2DWorld); QueInit(&ret->objects); ret->scrn=DCNew(GR_WIDTH,GR_HEIGHT); ret->background_color=background_color; DCDepthBufAlloc(ret->scrn); return ret; } U0 C2DObjectUpdateMat(C2DObject *obj) { //This sets us to the identity matrix Mat4x4IdentEqu(obj->mat); //1: move center of graphics to (0,0) //2: rotate //3: scale //4: move to (x,y) // // Move center to 0,0 // Becasue rotations are rotated around (0,0) // Mat4x4TranslationAdd(obj->mat, -obj->center_x, //Use negative cordnates to move towards 0,0 -obj->center_y, -obj->center_z); // //Flip the image by rotationg around the Y axis // if(obj->flipped) Mat4x4RotY(obj->mat,pi); // // We need to rotate around the center // Mat4x4RotX(obj->mat,obj->rotx); Mat4x4RotY(obj->mat,obj->roty); Mat4x4RotZ(obj->mat,obj->rot); // // Scale the image // Mat4x4Scale(obj->mat,obj->scale); // // Now we move // Mat4x4TranslationAdd(obj->mat,obj->x,obj->y,obj->z); } C2DObject *C2DObjectNewFromSprite(U8 *sprite) { I64 min_x,max_x,min_y,max_y; C2DObject *new=CAlloc(sizeof(C2DObject),mem_task); new->ident='Obj'; new->mem_task=mem_task; SpriteExtents(sprite,&min_x,&max_x,&min_y,&max_y); new->width=max_x-min_x; new->height=max_y-min_y; new->sprite=CAlloc(SpriteSize(sprite),mem_task); MemCpy(new->sprite,sprite,SpriteSize(sprite)); new->is_sprite=TRUE; new->mat=Mat4x4IdentNew(mem_task); new->scale=1; QueInit(new); return new; } U0 C2DObjectSetGraphicsFromSprite(C2DObject *obj,U8 *sprite) { I64 min_x,max_x,min_y,max_y; if(!obj->is_sprite) DCDel(obj->graphics); if(obj->sprite) Free(obj->sprite); obj->sprite=CAlloc(SpriteSize(sprite),obj->mem_task); MemCpy(obj->sprite,sprite,SpriteSize(sprite)); sprite=obj->sprite; SpriteExtents(sprite,&min_x,&max_x,&min_y,&max_y); obj->width=max_x-min_x; obj->center_x=0; obj->center_y=0; obj->sprite=sprite; obj->is_sprite=TRUE; C2DObjectUpdateMat(obj); } C2DObject *C2DObjectNewFromDC(CDC*img) { C2DObject *new=CAlloc(sizeof C2DObject,mem_task); new->ident='Obj'; new->mem_task=mem_task; new->graphics=DCCopy(img,mem_task); new->center_x=img->width/2 ; new->center_y=img->height/2; new->width=img->width; new->height=img->height; new->mat=Mat4x4IdentNew(mem_task); new->scale=1; QueInit(new); return new; } U0 C2DObjectMoveCenter(C2DObject *obj,F64 x,F64 y) { obj->center_x=x,obj->center_y=y; C2DObjectUpdateMat(obj); } U0 C2DObjectMove(C2DObject *obj,F64 x,F64 y) { obj->x=x,obj->y=y; C2DObjectUpdateMat(obj); } U0 C2DObjectRotate(C2DObject *obj,F64 rot=0) { obj->rot=rot; C2DObjectUpdateMat(obj); } U0 C2DObjectScale(C2DObject *obj,F64 s) { obj->scale=s; C2DObjectUpdateMat(obj); } U0 C2DObjectSetGraphics(C2DObject *obj,CDC *gr) { if(!obj->is_sprite) DCDel(obj->graphics); obj->graphics=DCCopy(gr,obj->mem_task); obj->center_x=gr->width/2 ; obj->center_y=gr->height/2; obj->width=gr->width; obj->height=gr->height; C2DObjectUpdateMat(obj); } U0 PrepareForBlot(C2DObject *obj) { I64 dummy,min_x,min_y,max_x,max_y; CDC *sprite_dc; CD2I64 a,b,c,d; C2DObjectUpdateMat(obj); if(!obj->is_sprite) ; //GrBlot3(to,0,0,depth_offset,obj->graphics); else if(!(obj->flags&C2DOBJF_MESH)) { SpriteExtents(obj->sprite,&a.x,&b.x,&a.y,&b.y); c.x=a.x; c.y=b.y; d.x=b.x; d.y=a.y; Mat4x4MulXYZ(obj->mat,&a.x,&a.y,&dummy); Mat4x4MulXYZ(obj->mat,&b.x,&b.y,&dummy); Mat4x4MulXYZ(obj->mat,&c.x,&c.y,&dummy); Mat4x4MulXYZ(obj->mat,&d.x,&d.y,&dummy); min_x=MinI64(a.x,b.x); min_x=MinI64(min_x,c.x); min_x=MinI64(min_x,d.x); min_y=MinI64(a.y,b.y); min_y=MinI64(min_y,c.y); min_y=MinI64(min_y,d.y); max_x=MaxI64(a.x,b.x); max_x=MaxI64(max_x,c.x); max_x=MaxI64(max_x,d.x); max_y=MaxI64(a.y,b.y); max_y=MaxI64(max_y,c.y); max_y=MaxI64(max_y,d.y); sprite_dc=DCNew( Clamp(max_x-min_x+1,1,GR_WIDTH), Clamp(max_y-min_y+1,1,GR_HEIGHT)); DCFill(sprite_dc); Sprite3Mat4x4B(sprite_dc,-min_x,-min_y,0,obj->sprite,obj->mat); //Compute center c.x=0,c.y=0; Mat4x4MulXYZ(obj->mat,&c.x,&c.y,&dummy); obj->_blot_at_x=c.x-(c.x-min_x); obj->_blot_at_y=c.y-(c.y-min_y); obj->_blot_dc=sprite_dc; } } U0 C2DObjectRemoveFromWorld(C2DObject *obj) { QueRem(obj); QueInit(obj); } U0 C2DObjectDel(C2DObject *obj) { QueRem(obj); if(!obj->is_sprite) DCDel(obj->graphics); Free(obj->mat); Free(obj); } U0 C2DWorldDel(C2DWorld *world) { C2DObject *cur,*next; I64 idx; while(LBts(&world->in_draw,0)) Sleep(1); for(cur=world->objects.next;cur!=&world->objects;) { next=cur->next; C2DObjectDel(cur); cur=next; } Free(world);; } U0 AddObjectToWorld(C2DObject *obj,C2DWorld *world) { while(LBts(&world->in_draw,0)) Yield; C2DObject *head=&world->objects,*cur=head->next; if(!obj->priority) obj->priority=QueCnt(head); while(cur!=head) { if(obj->prioritypriority) { QueInsRev(obj,cur); goto fin; } cur=cur->next; } obj->world=world; QueIns(obj,head->last); fin: LBtr(&world->in_draw,0); } class CMPDrawItNugget { CDC *to; C2DWorld *world; I64 start,end; CMPDrawItNugget *last,*next; I64 ready_to_merge; I64 merged; CTask *parent; I64 done; }; U0 MPDrawIt(CMPDrawItNugget *nugget) { C2DObject *head=&nugget->world->objects,*cur=head->next; I64 old_flags; U8 *old_mat; if(!nugget->to) { nugget->to=DCNew( nugget->world->scrn->width, nugget->world->scrn->height, nugget->world->scrn->mem_task); DCFill(nugget->to,TRANSPARENT); } I64 i; for(i=0;iend&&cur!=head;i++) { if(nugget->start<=i) { PrepareForBlot(cur); if(cur->flags&C2DOBJF_MESH) { C2DObjectUpdateMat(cur); Sprite3Mat4x4B(nugget->to,0,0,0,cur->sprite,cur->mat); } else if(!cur->is_sprite) { old_flags=nugget->to->flags; old_mat=nugget->to->r; nugget->to->flags|=DCF_TRANSFORMATION; nugget->to->r=cur->mat; if(cur->graphics) { if(cur->flags&C2DOBJF_REPLACE_COLOR) DCColorChg(cur->graphics,cur->replace_color,cur->with_color); GrBlot3(nugget->to,0,0,0,cur->graphics); } nugget->to->r=old_mat; nugget->to->flags=old_flags; } else { if(cur->flags&C2DOBJF_REPLACE_COLOR) DCColorChg(cur->_blot_dc,cur->replace_color,cur->with_color); GrBlot(nugget->to,cur->_blot_at_x,cur->_blot_at_y,cur->_blot_dc); DCDel(cur->_blot_dc); cur->_blot_dc=NULL; } } cur=cur->next; } nugget->parent->wake_jiffy=0; LBts(&nugget->done,0); } I64 PrioritySort(C2DObject *a,C2DObject *b) { if(b->priority>a->priority) return 1; if(b->prioritypriority) return -1; return 0; } U0 WorldSortByPriority(C2DWorld *w) { I64 cnt=QueCnt(&w->objects),i; C2DObject **sorted=MAlloc(8*cnt); C2DObject *head=&w->objects,*cur=head->next; for(cnt=0;cur!=head;cnt++) { sorted[cnt]=cur; cur=cur->next; } QSortI64(sorted,cnt,&PrioritySort); QueInit(&w->objects); for(i=0;i!=cnt;i++) { QueIns(sorted[i],&w->objects); } Free(sorted); } U0 DrawWorld(CTask *t,C2DWorld *world) { if(!t) t=Fs; LBts(&world->in_draw,0); I64 i,core_cnt,i2=0,cap; I64 old_flags,*old_mat; CMPDrawItNugget nuggets[mp_cnt]; MemSet(nuggets,0,sizeof(CMPDrawItNugget)*mp_cnt); world->scrn->color=world->background_color; DCDepthBufRst(world->scrn); DCFill(world->scrn,TRANSPARENT); TextRect(t->win_left,t->win_right,t->win_top,t->win_bottom,world->background_color<<12); //head points to the head of the CQue C2DObject *head=&world->objects,*cur=head->next; WorldSortByPriority(world); //Because CQue's wrap around,we check for head as the last element // A is the head // // A->B->C-\ // ^ | // | | // \-------/ // one: cur=head->next; while(cur!=head) { PrepareForBlot(cur); cur=cur->next; } i2=QueCnt(head); cur=head->next; while(i2--) { if(cur->flags&C2DOBJF_MESH) { C2DObjectUpdateMat(cur); Sprite3Mat4x4B(world->scrn,0,0,0,cur->sprite,cur->mat); } else if(!cur->is_sprite) { old_flags=world->scrn->flags; old_mat=world->scrn->r; world->scrn->flags|=DCF_TRANSFORMATION; world->scrn->r=cur->mat; if(cur->graphics) { if(cur->flags&C2DOBJF_REPLACE_COLOR) DCColorChg(cur->graphics,cur->replace_color,cur->with_color); GrBlot3(world->scrn,0,0,cur->z,cur->graphics); } world->scrn->r=old_mat; world->scrn->flags=old_flags; } else { if(cur->flags&C2DOBJF_REPLACE_COLOR) DCColorChg(cur->_blot_dc,cur->replace_color,cur->with_color); GrBlot3(world->scrn,cur->_blot_at_x,cur->_blot_at_y,cur->z,cur->_blot_dc); DCDel(cur->_blot_dc); } cur=cur->next; } LBtr(&world->in_draw,0); } U0 C2DObjectPointTo(C2DObject *obj,F64 x,F64 y) { //We want to make the x,y relative to the obj's cordnates x-=obj->x; y-=obj->y; //https://en.wikipedia.org/wiki/Atan2 //ATan2 gets the angle that points to (x,y) obj->rot=Arg(x,y); C2DObjectUpdateMat(obj); } // // Test section // class CD2F64 { F64 x,y; }; U0 CrossProduct(CD2F64 *dst,CD2F64 *a,CD2F64 *b) { dst->x=a->y-b->y; dst->y=a->x-b->x; } Bool InRange(F64 a,F64 v,F64 b) { if(a>b) return a>=v>=b; return a<=v<=b; } class CD2F64 { F64 x,y; }; U0 CrossProduct(CD2F64 *dst,CD2F64 *a,CD2F64 *b) { dst->x=a->y-b->y; dst->y=a->x-b->x; } Bool InRange(F64 a,F64 v,F64 b) { if(a>b) return a>=v>=b; return a<=v<=b; } Bool PlaneIntersect(CD2I64 *dst,CD2I64 *a,CD2I64 *b,CD2I64 *a2,CD2I64 *b2) { /* * Nroot here,Heres the deal,I make a system of 2 linear equations and solve for an intersect * I solve for the intersect and check if they are in bounds of points Check for intersection basically. / ----*------ / / / */ F64 slope1,slope2,off1,off2; CD2I64 dummy; if(!dst) dst=&dummy; //If the line points straight up,we can check to see if the other //line goes through the y position,if so,it is a hit if((b->x==a->x)||(b2->x==a2->x)) { if(a->x==b->x&&a2->x==b2->x) { if(a->x==a2->x) { dst->x=a->x; dst->y=a->y; goto fin; } else return FALSE; } if(a->x==b->x) { dst->x=a->x; slope2=(ToF64(b2->y)-a2->y)/(ToF64(b2->x)-a2->x); dst->y=slope2*(dst->x-a2->x)+a2->y; goto fin; } if(a2->x==b2->x) { dst->x=a2->x; slope1=(ToF64(b->y)-a->y)/(ToF64(b->x)-a->x); dst->y=slope1*(dst->x-a->x)+a->y; goto fin; } goto fin; } //https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection slope2=(ToF64(b2->y)-a2->y)/(ToF64(b2->x)-a2->x); slope1=(ToF64(b->y)-a->y)/(ToF64(b->x)-a->x); off1=slope1*-a->x+a->y; off2=slope2*-a2->x+a2->y; dst->x=((off2-off1)/(slope1-slope2)); dst->y=slope1*(dst->x)+off1; fin: return InRange(a->x,dst->x,b->x)&& InRange(a2->x,dst->x,b2->x)&& InRange(a->y,dst->y,b->y)&& InRange(a2->y,dst->y,b2->y); } Bool C2DObjectCollisionTest(C2DObject*o1,C2DObject *o2,CD2I64 *hit_at=NULL) { I64 nul=1,i,i2; I64 o1_mat[16],o2_mat[16]; CD2I64*o1_edges[5]; CD2I64*o2_edges[5]; CD2I64 a,b,c,d; CD2I64 a2,b2,c2,d2; if(!o1->is_sprite) { a.x=0; b.x=0+o1->width; c.x=0+o1->width; d.x=0; a.y=0; b.y=0; c.y=0+o1->height; d.y=0+o1->height; } else{ SpriteExtents(o1->sprite,&a.x,&b.x,&a.y,&c.y); d.x=a.x; //min c.x=b.x; //max b.y=a.y; //min d.y=c.y; //max } if(!o2->is_sprite) { a2.x=0; b2.x=0+o2->width; c2.x=0+o2->width; d2.x=0; a2.y=0; b2.y=0; c2.y=0+o2->height; d2.y=0+o2->height; } else { SpriteExtents(o2->sprite,&a2.x,&b2.x,&a2.y,&c2.y); d2.x=a2.x; //min c2.x=b2.x; //max b2.y=a2.y; //min d2.y=c2.y; //max } C2DObjectUpdateMat(o1); C2DObjectUpdateMat(o2); Mat4x4Equ(o1_mat,o1->mat); Mat4x4Equ(o2_mat,o2->mat); // Mat4x4Scale(o1_mat,1<<16); // Mat4x4Scale(o2_mat,1<<16); nul=0; Mat4x4MulXYZ(o1_mat,&a.x,&a.y,&nul); nul=0; Mat4x4MulXYZ(o1_mat,&b.x,&b.y,&nul); nul=0; Mat4x4MulXYZ(o1_mat,&c.x,&c.y,&nul); nul=0; Mat4x4MulXYZ(o1_mat,&d.x,&d.y,&nul); nul=0; Mat4x4MulXYZ(o2_mat,&a2.x,&a2.y,&nul); nul=0; Mat4x4MulXYZ(o2_mat,&b2.x,&b2.y,&nul); nul=0; Mat4x4MulXYZ(o2_mat,&c2.x,&c2.y,&nul); nul=0; Mat4x4MulXYZ(o2_mat,&d2.x,&d2.y,&nul); o1_edges[0]=&a; o1_edges[1]=&b; o1_edges[2]=&c; o1_edges[3]=&d; o1_edges[4]=&a; o2_edges[0]=&a2; o2_edges[1]=&b2; o2_edges[2]=&c2; o2_edges[3]=&d2; o2_edges[4]=&a2; for(i=0;i!=4;i++) for(i2=0;i2!=4;i2++) { if(PlaneIntersect(hit_at,o1_edges[i],o1_edges[i+1], o2_edges[i2],o2_edges[i2+1])) { if(hit_at) hit_at->x/=(1<<16); if(hit_at) hit_at->y/=(1<<16); return TRUE; } } return FALSE; } U0 C2DObjectSetFlip(C2DObject *sp,Bool flip) { sp->flipped=flip; C2DObjectUpdateMat(sp); } C2DObject *C2DObjectCopy(C2DObject *src) { C2DObject *copy=MAllocIdent(src,mem_task); copy->mat=Mat4x4New(src->mat,mem_task); copy->mem_task=mem_task; if(copy->is_sprite) copy->sprite=src->sprite; else copy->graphics=DCCopy(src->graphics,mem_task); return copy; } #endifCD001//ZZTempleOS RedSeaCD001EL TORITO SPECIFICATIONCD001//ZZTempleOS RedSeaџCD001TempleOS.ЧUЊˆˆXdZ<=ЅЩI UЊџџџџџџџџџџџџ.Z<=ЅЩI ..Z<=ЅЩI Animate.HC\д)†VкЧI Golf.HCq УI GroovyPt1.HC~ЛRОЧI Mouse.HCŠˆ #ЇШI Skeletal.HC˜ n‹ УI _2d.HCŸq7ФВтЛI #ifndef TOON_PORN #define TOON_PORN"What the fuck nroot" #include "Skeletal.HC"; class CAnimation { //Use obj->ident=='Obj' or obj->ident=='Bone' union { C2DObject *obj; CBone *bone; }; #define ANIMT_MOVE 1 #define ANIMT_SPRITE 2 #define ANIMT_SWEEP 3 #define ANIMT_NOISE 4 //Sprites will randomly be selected as particles #define ANIMT_PARTICLE 5 #define ANIMT_PARTICLES 6 #define ANIMT_ROTX 7 #define ANIMT_ROTY 8 #define ANIMT_ROTZ 9 #define ANIMT_SCALE 10 I64 type; CD3 start; CD3 end; F64 spread_angle; U8 **sprites; I64 sprite_cnt,burst_cnt; F64 start_angle; F64 end_angle; F64 time; F64 freq; //Set to 0 for 1 run for all of *time* //Private F64 start_tS; CTask *anim_task; Bool done; }; CTask *mem_task=Fs; CAnimation *AnimationBurstParticlesFromObject(F64 time,I64 amt,C2DObject *obj,F64 x2,F64 y2,F64 spread=pi/6,...) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->time=time; anim->type=ANIMT_PARTICLES; anim->obj=obj; anim->end.x=x2; anim->end.y=y2; anim->burst_cnt=amt; anim->spread_angle=spread; anim->sprites=CAlloc(argc*8,mem_task); MemCpy(anim->sprites,argv,argc*8); anim->sprite_cnt=argc; return anim; } CAnimation *AnimationShotParticlesFromObject(F64 time,F64 freq=10,C2DObject *obj,F64 x2,F64 y2,F64 spread=pi/6,...) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->time=time; anim->type=ANIMT_PARTICLE; anim->obj=obj; anim->end.x=x2; anim->end.y=y2; anim->spread_angle=spread; anim->freq=freq; anim->sprites=CAlloc(argc*8,mem_task); MemCpy(anim->sprites,argv,argc*8); anim->sprite_cnt=argc; return anim; } CAnimation *AnimationNoiseSound(F64 time,I64 low,I64 hi) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->time=time; anim->type=ANIMT_NOISE; anim->start.x=low; anim->end.x=hi; return anim; } CAnimation *AnimationSweepSound(F64 time,I64 low,I64 hi) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->time=time; anim->type=ANIMT_SWEEP; anim->start.x=low; anim->end.x=hi; return anim; } CAnimation *AnimationScale(C2DObject *ob,F64 time,F64 low,F64 hi) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->time=time; anim->type=ANIMT_SCALE; anim->start.x=low; anim->end.x=hi; anim->obj=ob; return anim; } CAnimation *AnimationXRot(C2DObject *obj,F64 time=0,F64 ea=0) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->obj=obj; anim->type=ANIMT_ROTX; if(obj->ident=='Obj') { anim->start_angle=obj->rotx; } else if(obj->ident=='Bone') { //TODO } anim->end_angle=ea; anim->time=time; anim->freq=0; return anim; } CAnimation *AnimationZRot(C2DObject *obj,F64 time=0,F64 ea=0) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->obj=obj; anim->type=ANIMT_ROTZ; if(obj->ident=='Obj') { anim->start_angle=obj->rot; } else if(obj->ident=='Bone') { //TODO } anim->end_angle=ea; anim->time=time; anim->freq=0; return anim; } CAnimation *AnimationYRot(C2DObject *obj,F64 time=0,F64 ea=0) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->obj=obj; anim->type=ANIMT_ROTY; if(obj->ident=='Obj') { anim->start_angle=obj->roty; } else if(obj->ident=='Bone') { //TODO } anim->end_angle=ea; anim->time=time; anim->freq=0; return anim; } CAnimation *AnimationMove(C2DObject *obj,F64 time=0,F64 x,F64 y,F64 sa=0,F64 ea=0) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->obj=obj; anim->type=ANIMT_MOVE; if(obj->ident=='Obj') { anim->start.x=obj->x; anim->start.y=obj->y; } else if(obj->ident=='Bone') { anim->start.x=obj(CBone*)->x; anim->start.y=obj(CBone*)->y; } anim->end.x=x; anim->end.y=y; anim->start_angle=sa; anim->end_angle=ea; anim->time=time; anim->freq=0; return anim; } CAnimation *AnimationMove3D(C2DObject *obj,F64 time=0,F64 x,F64 y,F64 z) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->obj=obj; anim->type=ANIMT_MOVE; if(obj->ident=='Obj') { anim->start.x=obj->x; anim->start.y=obj->y; anim->start.z=obj->z; } else if(obj->ident=='Bone') { anim->start.x=obj(CBone*)->x; anim->start.y=obj(CBone*)->y; anim->start.z=obj(CBone*)->z; } anim->end.x=x; anim->end.y=y; anim->end.z=z; anim->time=time; anim->freq=0; return anim; } //Vargs are sprites to animate CAnimation *AnimationWalkCycle(C2DObject *obj,F64 time=0,F64 freq,...) { CAnimation *anim=CAlloc(sizeof(CAnimation),mem_task); anim->type=ANIMT_SPRITE; anim->obj=obj; anim->freq=freq; anim->time=time; anim->sprites=CAlloc(argc*8); MemCpy(anim->sprites,argv,argc*8); anim->sprite_cnt=argc; return anim; } U0 AnimTask(CAnimation *a) { a->start_tS=tS; F64 en=a->time+a->start_tS,per,x,y,next_particle=tS; I64 idx,idx2; U8 **frames=a->sprites,*spr; U8 final_run=FALSE; F64 dist,an,dx,dy,dz; C2DObject *obj=a->obj,*particle; C2DObject *bone=a->obj; C2DObject *particles[0x100]; C2DWorld *w; CD3 particle_movements[0x100],tmp_cd2,*movement; Bool first=TRUE; static CD3 gravity={0,30*8,0}; MemSetI64(particles,NULL,0x100); I64 particle_cnt=0; while(TRUE) { if(enstart_tS)/a->time; switch(a->type) { case ANIMT_PARTICLES: for(idx=0;idxburst_cnt&&particle_cnt<0x100&&first;idx++) { dx=a->end.x; dy=a->end.y; dist=Sqrt(Sqr(dy)+Sqr(dx)); an=Arg(dx,dy); if(obj->ident=='Obj') { x=obj->x; y=obj->y; w=obj->world; } else if(obj->ident=='Bone') { x=obj(CBone*)->obj->x; y=obj(CBone*)->obj->y; w=obj(CBone*)->obj->world; } an+=(Rand-Rand)*a->spread_angle; particle_movements[particle_cnt].x=dist*Cos(an); particle_movements[particle_cnt].y=dist*Sin(an); spr=a->sprites[RandU16%a->sprite_cnt]; if(w) { if(particles[particle_cnt]) C2DObjectDel(particles[particle_cnt]); particles[particle_cnt]=particle=C2DObjectNewFromSprite(spr); AddObjectToWorld(particle,w); particle->x=x; particle->y=y; particle->rot=an; particle_cnt++; } } first=FALSE; goto update_particles; case ANIMT_PARTICLE: if(next_particle<=tS&&particle_cnt<0x100) { dx=a->end.x; dy=a->end.y; dist=Sqrt(Sqr(dy)+Sqr(dx)); an=Arg(dx,dy); if(obj->ident=='Obj') { x=obj->x; y=obj->y; w=obj->world; } else if(obj->ident=='Bone') { x=obj(CBone*)->obj->x; y=obj(CBone*)->obj->y; w=obj(CBone*)->obj->world; } an+=(Rand-Rand)*a->spread_angle; particle_movements[particle_cnt].x=dist*Cos(an); particle_movements[particle_cnt].y=dist*Sin(an); spr=a->sprites[RandU16%a->sprite_cnt]; if(w) { if(particles[particle_cnt]) C2DObjectDel(particles[particle_cnt]); particles[particle_cnt]=particle=C2DObjectNewFromSprite(spr); AddObjectToWorld(particle,w); particle->x=x; particle->y=y; particle->rot=an; particle_cnt++; } next_particle=1./(a->freq)+tS; } update_particles: for(idx=0;idx!=particle_cnt;idx++) { if(particle=particles[idx]) { movement=&particle_movements[idx]; dx=movement->x; dy=movement->y; movement->z=0; particle->rot=Arg(dx,dy); particle->x+=dx*1./winmgr.fps; particle->y+=dy*1./winmgr.fps; movement->y+=gravity.y*1/winmgr.fps; tmp_cd2.z=0; } } if(final_run==1) { a->done=TRUE; //Wait 2 seconds for all particles to disappear(hopefuly) en=2.+tS; final_run++; Refresh; goto update_particles; } else if(final_run==2 ) { if(tS>en) break; Refresh; goto update_particles; } break; case ANIMT_MOVE: dx=a->end.x-a->start.x; dy=a->end.y-a->start.y; dz=a->end.z-a->start.z; dist=Sqrt(Sqr(dy)+Sqr(dx)); an=Arg(dx,dy); if(obj->ident=='Obj') { if(dx) obj->x=a->start.x+dist*per*Cos(an); if(dy) obj->y=a->start.y+dist*per*Sin(an); if(dz) obj->z=a->start.z+per*dz; if(a->start_angle!=a->end_angle) obj->rot=per*(a->end_angle-a->start_angle)+a->start_angle; } else if(obj->ident=='Bone') { if(dx) obj(CBone*)->x=a->start.x+dist*per*Cos(an); if(dy) obj(CBone*)->y=a->start.y+dist*per*Sin(an); if(dz) obj(CBone*)->y=a->start.z+dz*per; if(a->start_angle!=a->end_angle) obj(CBone*)->rot=per*(a->end_angle-a->start_angle)+a->start_angle; } break; case ANIMT_SWEEP: Sweep(1000*a->time,a->start.x,a->end.x); Sleep(1000*a->time); goto fin; case ANIMT_NOISE: Noise(1000*a->time,a->start.x,a->end.x); Sleep(1000*a->time); goto fin; case ANIMT_SPRITE: idx=ToI64(per*a->time*a->freq); idx2=idx+1; idx%=a->sprite_cnt; idx2%=a->sprite_cnt; dx=per*a->time*a->freq%1.; spr=SpriteInterpolate(dx,frames[idx],frames[idx2]); if(obj->ident=='Bone') { C2DObjectSetGraphicsFromSprite(obj(CBone*)->obj,spr); } else if(obj->ident=='Obj') { C2DObjectSetGraphicsFromSprite(obj,spr); } Free(spr); break; case ANIMT_ROTX: an=per*(a->end_angle-a->start_angle)+a->start_angle; if(obj->ident=='Bone') { //TODO } else if(obj->ident=='Obj') { obj->rotx=an; } break; case ANIMT_ROTY: an=per*(a->end_angle-a->start_angle)+a->start_angle; if(obj->ident=='Bone') { //TODO } else if(obj->ident=='Obj') { obj->roty=an; } break; case ANIMT_SCALE: an=per*(a->end.x-a->start.x)+a->start.x; if(obj->ident=='Bone') { obj(CBone*)->obj->scale=an; } else if(obj->ident=='Obj') { obj->scale=an; } break; case ANIMT_ROTZ: an=per*(a->end_angle-a->start_angle)+a->start_angle; if(obj->ident=='Bone') { //TODO } else if(obj->ident=='Obj') { obj->rot=an; } break; } if(final_run) break; Refresh; } fin: a->done=TRUE; for(idx=0;idx!=particle_cnt;idx++) if(particle=particles[idx$WW,1$]) { C2DObjectDel(particle); } } U0 AnimScene(...) { I64 idx; F64 total=0; Bool all_done=FALSE; CAnimation *anim; for(idx=0;idx!=argc;idx++) { anim=argv[idx]; anim->anim_task=Spawn(&AnimTask,anim,,,Fs); total=Max(anim->time,total); } for(idx=0;idx!=argc;idx++) { anim=argv[idx]; if(!anim->time) anim->time=total; } Sleep(total*1000); while(!all_done) { all_done=TRUE; for(idx=0;idx!=argc;idx++) { anim=argv[idx]; if(!anim->done) all_done=FALSE; } Refresh; } } #endif $SP,"<1>",BI=1$ $SP,"<2>",BI=2$ $SP,"<3>",BI=3$ $SP,"<4>",BI=4$ $SP,"<5>",BI=5$ $SP,"<6>",BI=6$ $SP,"<7>",BI=7$ $SP,"<8>",BI=8$ $SP,"<9>",BI=9$ $SP,"<10>",BI=10$ $SP,"dummy",BI=11$ #define SCRN_SCALE 512 U0 DCTransform(CDC *dc,I64 *x,I64 *y,I64 *z) { I64 zz; Mat4x4MulXYZ(dc->r,x,y,z); zz=SCRN_SCALE/3+*z; if (zz<1) zz=1; *x=SCRN_SCALE/2* *x/zz; *y=SCRN_SCALE/2* *y/zz; *x+=dc->x; *y+=dc->y; *z+=dc->z; } #include "Animate"; C2DWorld *w=C2DWorldNew(WHITE); C2DObject *golf_stick=C2DObjectNewFromSprite($IB,"<1>",BI=1$); C2DObject *balls=C2DObjectNewFromSprite($IB,"<4>",BI=4$); C2DObject *dick=C2DObjectNewFromSprite($IB,"<5>",BI=5$); C2DObject *ball=C2DObjectNewFromSprite($IB,"<6>",BI=6$); C2DObject *guy=C2DObjectNewFromSprite($IB,"<7>",BI=7$); C2DObject *cum=C2DObjectNewFromSprite($IB,"<9>",BI=9$); C2DObject *shit=C2DObjectNewFromSprite($IB,"<10>",BI=10$); C2DObject *dummy=C2DObjectNewFromSprite($IB,"<11>",BI=11$); golf_stick->flags|=C2DOBJF_MESH; AddObjectToWorld(golf_stick,w); AddObjectToWorld(balls,w); AddObjectToWorld(dick,w); AddObjectToWorld(ball,w); U0 DrawIt(CTask *t,CDC *dc) { DrawWorld(t,w); GrBlot(dc,0,0,w->scrn); } U0 SongTask(I64) { Fs->task_end_cb=&SndTaskEndCB; music.mute=0; MusicSettingsRst; while (TRUE) { Play("$FG$$BG$5M6/8e.Gs4G5C4B5C4B5G4G5G4Gq5Get4G5CFsG4G5G4G"); } } U0 Movie() { I64 cnt; w->scrn->transform=&DCTransform; golf_stick->z=700; Fs->draw_it=&DrawIt; Spawn(&SongTask,,,,Fs); WinMax; golf_stick->scale=2.4; balls->x=310; balls->y=300; balls->z=700; dick->x=310; dick->y=300; dick->z=700; ball->x=340; ball->y=165; ball->z=700; golf_stick->x=-1000; golf_stick->roty=pi/3.5; //Scene 1 AnimScene( AnimationMove3D(golf_stick,1.,400,300,golf_stick->z) ); AnimScene( AnimationXRot(golf_stick,1,-pi/2), ); AnimScene( AnimationSweepSound(.1,50,70), AnimationXRot(golf_stick,.1,0), ); AnimScene( AnimationScale(balls,.1,1.,1./10.), AnimationMove(balls,.3,GR_WIDTH,0), AnimationXRot(golf_stick,.05,pi/4), ); // Scene 2 C2DObjectDel(golf_stick); C2DObjectDel(balls); C2DObjectDel(dick); C2DObjectDel(ball); balls=C2DObjectNewFromSprite($IB,"<4>",BI=4$); AddObjectToWorld(balls,w); balls->x=-100; balls->y=GR_HEIGHT/2; AnimScene( AnimationMove(balls,.5,GR_WIDTH,GR_HEIGHT/2,0,8*pi) ); balls->x=GR_WIDTH/2; balls->y=GR_HEIGHT/2+100; balls->rot=0; guy->x=GR_WIDTH/2-100; guy->y=100; guy->priority=-1; AddObjectToWorld(guy,w); AnimScene( ); AnimScene( AnimationSweepSound(1.,100,40), AnimationWalkCycle(guy,1.,1.1,$IB,"<7>",BI=7$,$IB,"<8>",BI=8$), AnimationMove(balls,1,GR_WIDTH/2,GR_HEIGHT/2), AnimationZRot(balls,1,16*pi) ); C2DObjectDel(balls); AddObjectToWorld(cum,w); cum->x=guy->x; cum->y=guy->y; cum->priority=1; AnimScene( AnimationNoiseSound(.5,30,40) ); Sleep(1000); dummy->x=250; dummy->y=270; AddObjectToWorld(dummy,w); for(cnt=0;cnt!=10;cnt++) { AnimScene( AnimationNoiseSound(.1,40,60), AnimationBurstParticlesFromObject(.1,1,dummy,150*3,-128*2,pi/8,$IB,"<10>",BI=10$) ); } Exit; } Movie; 22Ш}Шsм2м-Ш-Ш}с7Œв7-м7-Ш7ћџџџ72ћџџџ7-Ш7000 0 0 0 0  0  0 0 0  0 0           ­ ќџџџьџџџюџџџщџџџпџџџрџџџбџџџоџџџМџџџцџџџИџџџёџџџЛџџџТџџџУџџџ МџџџЗџџџМџџџ'гџџџ.№џџџ$џџџџ  ќџџџъџџџшџџџїџџџ !!ёџџџ#Эџџџ!™џџџ.˜џџџ0џџџ-‚џџџ)xџџџ'xџџџsџџџsџџџuџџџzџџџ‚џџџvџџџrџџџsџџџzџџџќџџџ‚џџџљџџџџџџњџџџ“џџџќџџџ“џџџ–џџџ рџџџњџџџчџџџ їџџџчџџџ ёџџџ ˜џџџ —џџџ‹џџџ#Ыџџџ3иџџџ  эџџџ ўџџџьџџџ цџџџщџџџ нџџџдџџџ ыџџџжџџџ$ кџџџI’ иџџџQ’$! Хџџџ  Тџџџ ќџџџЩџџџл0l эџџџСџџџ цџџџЖџџџ ѓџџџЏџџџ јџџџБџџџ$ Гџџџ Дџџџ Іџџџ жџџџУџџџˆ єџџџїџџџоџџџмџџџУџџџЃџџџФџџџДџџџ)Мџџџ@дџџџ0эџџџ#чџџџ7§џџџ9  ѓџџџѕџџџ иџџџˆ єџџџїџџџЛџџџшџџџУџџџЫџџџФџџџДџџџ)Мџџџ@йџџџ&пџџџ4ѓџџџ>љџџџђџџџ ѓџџџѕџџџ иџџџј7A? 9‚:Ш!ф :ЦJм ]›8š0-&Q'L&' )M($I“d’$щц­нj›$%& ,(Œ‚ XыйЖ}’L€ ™}лф 9Z+€ј;@? =>Ч%у >ХNл aš<œ™4,!%U&P%& )Q'$I“d’$щц­нj›$%& ,#'Œ‚ XыйЖ}’L€ ™}лф =Y3 8@њџџџ4 №џџџ/ўџџџ8 E§џџџZz"n5p>‡Y‚Odkl„esH7{$o&tbW B№џџџS4 б §џџџ(170)*5.D5J4i"i"s.z/…'Š%‹€m`?93 ) ' ! >" U w e U! 6  ." #include "Animate.HC"; //0123456789abcdef //0$SP,"<1>",BI=1$ //1 //2 //3 //4 //5 //6 //8$SP,"<2>",BI=2$ //9 //a //b //c //d //e //f //0123456789abcdef0123456789a //0$SP,"<3>",BI=3$$ER$ //1 //2 //3 //4 //5 //6 //7 //8$SP,"<4>",BI=4$ //9 //a //b //c //d //e //f //0123456789abcdef0123456789a //0$SP,"<5>",BI=5$ //1 //2 //3 //4 //5 //6 //7 //8 //9 //a //b //c //d //e //f //Sting // $SP,"<6>",BI=6$ //0123456789abcdef0123456789a //0$SP,"<7>",BI=7$ //1 //2 //3 //4 //5 //6 //7 //8 //9 //a //b //c //d //e //f //0123456789abcdef0123456789a //0$SP,"<8>",BI=8$ //1 //2 //3 //4 //5 //6 //7 //8 //9 //a //b //c //d //e //f //0123456789abcdef0123456789a //0 $SP,"<9>",BI=9$ //1 //2 //3 //4 //5 //6 //7 //8 //9 //a //b //c //d //e //f //0123456789abcdef0123456789a //0 $SP,"<10>",BI=10$ //1 //2 //3 //4 //5 //6 //7 //8 //9 //a //b //c //d //e //f $SP,"<11>",BI=11$ C2DWorld *w=C2DWorldNew(BLACK); C2DObject *s_head=C2DObjectNewFromSprite($IB,"<1>",BI=1$); C2DObject *s_body=C2DObjectNewFromSprite($IB,"<3>",BI=3$); C2DObject *s_tail=C2DObjectNewFromSprite($IB,"<5>",BI=5$); C2DObject *dick=C2DObjectNewFromSprite($IB,"<7>",BI=7$); C2DObject *claw_top=C2DObjectNewFromSprite($IB,"<9>",BI=9$); C2DObject *claw_bottom=C2DObjectNewFromSprite($IB,"<10>",BI=10$); CBone *claw_top_b=BoneNew(claw_top); CBone *claw_bottom_b=BoneNew(claw_bottom); CBone *s_head_b=BoneNew(s_head); CBone *s_tail_b=BoneNew(s_tail); CBone *s_body_b=BoneNew(s_body); claw_bottom_b->x=-80; QueIns(claw_bottom_b,&claw_top_b->child_bones); QueIns(claw_top_b,&s_body_b->child_bones); QueIns(s_tail_b,&s_body_b->child_bones); QueIns(s_head_b,&s_body_b->child_bones); AddObjectToWorld(s_body,w); AddObjectToWorld(s_head,w); AddObjectToWorld(s_tail,w); AddObjectToWorld(dick,w); AddObjectToWorld(claw_top,w); AddObjectToWorld(claw_bottom,w); claw_top->priority=-1; claw_bottom_b->rot=-pi/2; s_tail_b->x=0x10*8; dick->y=190; dick->x=80; U0 DrawIt(CTask *t,CDC *dc) { BoneUpdate(s_body_b); DrawWorld(t,w); GrBlot(dc,0,0,w->scrn); } F64 Lerp(F64 t,F64 a,F64 b) { return t*(b-a)+a; } U0 SongTask(I64) { Fs->task_end_cb=&SndTaskEndCB; music.mute=0; MusicSettingsRst; while (TRUE) { Play("$FG$$BG$5M6/8e.Gs4G5C4B5C4B5G4G5G4Gq5Get4G5CFsG4G5G4G"); } } U0 Movie() { F64 st_start_tS=tS; Fs->draw_it=&DrawIt; Spawn(&SongTask,,,,Fs); WinMax; w->background_color=TRANSPARENT; I64 part=0; U8 *spr; FlushMsgs; s_body_b->y=258; s_body_b->x=GR_WIDTH; AnimScene( AnimationMove(s_body_b,3.,250,258), AnimationWalkCycle(s_body_b,,6,$IB,"<3>",BI=3$,$IB,"<4>",BI=4$) ); AnimScene( AnimationSweepSound(1/8.,100,10), AnimationMove(claw_bottom_b,1/8.,claw_bottom_b->x,claw_bottom_b->y,-pi/2,0), AnimationWalkCycle(s_tail,,8.,$IB,"<5>",BI=5$,$IB,"<6>",BI=6$) ); AnimScene( AnimationWalkCycle(s_head,1,1,$IB,"<1>",BI=1$,$IB,"<2>",BI=2$) ); for(part=0;part!=5;part++) AnimScene( AnimationNoiseSound(.3,40,60), AnimationBurstParticlesFromObject(.3,5,s_body_b,150*10,128,pi/4,$IB,"<11>",BI=11$) ); Fs->draw_it=0; } Movie; Ќцџџџ.>ЗЃYFй•Пќџџџыџџџ яџџџоџџџ яџџџоџџџлЖm! лџџџ юџџџоџџџжџџџѓџџџщџџџ ьџџџѕџџџѕџџџєџџџЫ ўџџџˆ  #9 9G1B: RO+U7 gr0bC €.A //->^ ћџџџ іџџџцџџџлџџџЭџџџЪџџџіџџџЫџџџэџџџЬџџџюџџџЫџџџфџџџЬџџџ^  ќџџџьџџџсџџџНџџџЎџџџћџџџКџџџтџџџСџџџтџџџОџџџ#џџџзџџџš ,@AяџџџJяџџџRѕџџџTіџџџWџџџџWJ WYSJEA  !'!4+?:?<@G9X6Y,]"\ZQIGPYўџџџ_ќџџџ\ђџџџRяџџџCюџџџ5ћџџџќџџџўџџџўџџџ ? ? Iјџџџ(Ы ўџџџ!   9 9@!</ RO+UH ge'`0 ‰A}"lB *' 2x ўџџџ CCіџџџHјџџџOџџџџRT TCPTTP%H*A%B>< =X&S*b)q#x~~xrrsїџџџzэџџџшџџџ€лџџџtкџџџ`тџџџWюџџџTќџџџU§џџџўџџџ %  F й =џџџяџџџ,џџџџџџџ,џџџ @џџџ#Lџџџ Wџџџfџџџrџџџ|џџџ €џџџ”џџџ—џџџЉџџџИџџџњџџџЛџџџџџџџВџџџєџџџЅџџџьџџџŒџџџцџџџyџџџуџџџRџџџцџџџ>џџџчџџџ;џџџѓџџџџџџ№џџџ б џџџћџџџˆџџџ ‰џџџ”џџџ%Їџџџ(Еџџџ)аџџџ&шџџџ ѕџџџќџџџўџџџяџџџќџџџсџџџнџџџдџџџћџџџЫџџџУџџџМџџџЖџџџџџџџЋџџџЂџџџўџџџžџџџ џџџ§џџџдџџџЌцџџџ-!>ЗЃYFй•Пќџџџыџџџ яџџџоџџџ яџџџоџџџлЖm! лџџџ юџџџоџџџжџџџѓџџџщџџџ ьџџџѕџџџєџџџ " `лЖmлАmumзЖ]л6I’4Iђ$I’$I’$IŠЩџїmпЗm›Ї$‰’DIЂD‰ЂH’$yоїџŸфyпП›%ŠЂ(ŠЂI”$%J˜„I$й†mи†m`‚ лж­›зvоЖnлАmлЖm`@€ ‚dнЖyлЖmнМ­[НКuлжu]з, ? b n = *  ^ #include "Animate.HC"; $SP,"<1>",BI=1$ $SP,"<2>",BI=2$ $SP,"<3>",BI=3$ $SP,"<4>",BI=4$ $SP,"<5>",BI=5$ $SP,"<6>",BI=6$ $SP,"<7>",BI=7$ $SP,"<8>",BI=8$ $SP,"<9>",BI=9$ $SP,"<10>",BI=10$ $SP,"<11>",BI=11$ U0 SongTask(I64) { Fs->task_end_cb=&SndTaskEndCB; music.mute=0; MusicSettingsRst; while (TRUE) { Play("$FG$$BG$5M6/8e.Gs4G5C4B5C4B5G4G5G4Gq5Get4G5CFsG4G5G4G"); } } C2DWorld *w=C2DWorldNew(WHITE); C2DObject *mouse=C2DObjectNewFromSprite($IB,"<1>",BI=1$); C2DObject *wall=C2DObjectNewFromSprite($ER$$IB,"<5>",BI=5$); C2DObject *hole=C2DObjectNewFromSprite($ER$$IB,"<4>",BI=4$); C2DObject *trap=C2DObjectNewFromSprite($IB,"<6>",BI=6$); C2DObject *dick=C2DObjectNewFromSprite($IB,"<9>",BI=9$); AddObjectToWorld(wall,w); AddObjectToWorld(mouse,w); AddObjectToWorld(hole,w); AddObjectToWorld(trap,w); U0 DrawIt(CTask *t,CDC *dc) { DrawWorld(t,w); GrBlot(dc,0,0,w->scrn); } U0 Movie() { F64 st_start_tS=tS; Fs->draw_it=&DrawIt; Spawn(&SongTask,,,,Fs); WinMax; WinBorder(0); w->background_color=TRANSPARENT; I64 part=0; U8 *spr; FlushMsgs; trap->y=-400; trap->x=320; mouse->y=270; mouse->x=0; wall->x=300; wall->y=270; hole->x=300; hole->y=275; AnimScene( AnimationMove(mouse,1.4,500,270), AnimationWalkCycle(mouse,,6,$IB,"<1>",BI=1$,$IB,"<2>",BI=2$) ); AnimScene( AnimationMove(trap,.4,trap->x,470) ); dick->x=-200; dick->y=trap->y-100; dick->rot=pi/2; AddObjectToWorld(dick,w); AnimScene( AnimationMove(dick,1,trap->x*.8,dick->y) ); AnimScene( AnimationMove(dick,.1,trap->x*.8,dick->y+80), AnimationSweepSound(.3,10,80), AnimationZRot(dick,.1,0), AnimationWalkCycle(dick,.5,1/.5,$IB,"<9>",BI=9$,$IB,"<10>",BI=10$), AnimationWalkCycle(trap,.15,1/.15*2,$IB,"<6>",BI=6$,$IB,"<7>",BI=7$,$IB,"<8>",BI=8$) ); mouse->flipped=TRUE; AnimScene( AnimationWalkCycle(mouse,1/2.,2,$IB,"<1>",BI=1$,$IB,"<3>",BI=3$), AnimationNoiseSound(.3,40,60), AnimationBurstParticlesFromObject(.3,5,mouse,-1000,-128,pi/5,$IB,"<11>",BI=11$) ); for(part=0;part!=5;part++) AnimScene( AnimationNoiseSound(.3,40,60), AnimationBurstParticlesFromObject(.3,5,mouse,-2000,-128,pi/3,$IB,"<11>",BI=11$) ); Fs->draw_it=0; }; Movie;–N26 $D^0g <K<XIU _Jacpd rApOƒQ/ћџџџЅ$" ‹yљџџџ— А ЧњџџџС‘-Ѓ/Й-™ ,RЅржШ?Д  Г ˜ ЅX: Л‰–N26 $D#X1W <K<eLe _JaVmU rAr_†^/ Ѓ" ‰wѓџџџ• ЎХєџџџП'Ё)З'—,RЅржШ?Вџџџџ Б –ЃX: Й‡ І l5вœв8ЯСВЈ– ‘‘vџџџ{$џџџf0 аš‹rЊ< ™Аџџџ– ЅњџџџЇ€Ь˜а0ЫНЃјџџџЗS ЃїџџџНцџџџIйџџџšоџџџЃS†•Ю™ќDL й%1у іОЋџџџіџџџеџџџ2 е№ўџџџ:лџџџL шџџџ ‘нѕџџџБНџџџ]Ыџџџ |ўџџџ|ѕџџџїџџџpјџџџoыџџџvьџџџaъџџџ`сџџџfрџџџlнџџџ]тџџџUлџџџUдџџџ_Щџџџ pюџџџ#їџџџьџџџL й%1у іОЋџџџіџџџеџџџ2 е№ўџџџ:лџџџL шџџџ ‘ЂДџџџgxџџџ]Ыџџџ |ўџџџ|ѕџџџїџџџpјџџџoыџџџvьџџџaъџџџ`сџџџfрџџџlнџџџ]тџџџUлџџџUдџџџ_Щџџџ pюџџџ#їџџџьџџџL й%1у іОЋџџџіџџџеџџџ2 е№ўџџџ:лџџџL шџџџ ‘$лџџџ]Ыџџџ |ўџџџ|ѕџџџїџџџpјџџџoыџџџvьџџџaъџџџ`сџџџfрџџџlнџџџ]тџџџUлџџџUдџџџ_Щџџџ pюџџџ#їџџџьџџџ e -7(A4`8q,zz_јџџџYїџџџzџџџџ†їџџџ–чџџџ‘Шџџџ‚ПџџџdНџџџIПџџџAтџџџ"уџџџ"cџџџ .(џџџџ ўџџџџџџџџџџџaџџџ"aџџџ9dџџџ7Sџџџ29џџџ"*џџџ$џџџ;џџџ$џџџџџџџџџџџџџљџџџ џџџѓџџџ%џџџьџџџ4џџџъџџџ9џџџшџџџDџџџхџџџLџџџфџџџUџџџуџџџ`џџџbџџџЭџџџ ќџџџSџџџџ Uaпџџџ@A€I$IЂ(Š”(Fa’$I’$I mRџџџџ"I’$)Š$I’$}џўmћЖMлЖmгіmкџлЗЭџчyžчy’$y’$) LTлЖmыкжЕmлЖmпОmзnЛmѓЖЭл6oл6oы ?mйџџџLТР0I’$R$I’D’$Р&’"I’ЄH 8@ўџџџи€mлЖmЕ]лЕ]лЕнЕ]лЖлv e <M&T*a&puqўџџџ_јџџџYїџџџsєџџџэџџџŽрџџџŒШџџџwУџџџcЬџџџQгџџџAтџџџ"уџџџ"cџџџ <(џџџџ ўџџџџџџџџџџџaџџџ"aџџџ9dџџџ7Sџџџ29џџџ"*џџџ$џџџ;џџџ$џџџџџџџџџџџџџљџџџ џџџѓџџџ%џџџьџџџ4џџџъџџџ9џџџшџџџDџџџхџџџLџџџфџџџUџџџуџџџ`џџџbџџџЭџџџ ќџџџSџџџџ Uaпџџџ@A€I$IЂ(Š”(Fa’$I’$I mRџџџџ"I’$)Š$I’$}џўmћЖMлЖmгіmкџлЗЭџчyžчy’$y’$) LTлЖmыкжЕmлЖmпОmзnЛmѓЖЭл6oл6oы ?mйџџџLТР0I’$R$I’D’$Р&’"I’ЄH 8@ўџџџи€mлЖmЕ]лЕ]лЕнЕ]лЖлv " `лЖmлАmumзЖ]л6I’4Iђ$I’$I’$IŠЩџїmпЗm›Ї$‰’DIЂD‰ЂH’$yоїџŸфyпП›%ŠЂ(ŠЂI”$%J˜„I$й†mи†m`‚ лж­›зvоЖnлАmлЖm`@€ ‚dнЖyлЖmнМ­[НКuлжu]з, ? b n = *  ^ –N26 $D#X1W <K<eLe _JaVmU rAr_†^/ Ѓ" ‰wѓџџџ• ЎХєџџџП'Ѕ?З'—,RЅржШ?Вџџџџ Џ –ЃX: Й‡ #ifndef SKELETAL #define SKELETAL #include "_2d.HC"; class CBone:CQue { U64 ident; C2DObject *obj; //Bone takes rotation from rot #define BONE_M_NORMAL 0 //Bone points to point_x,point_y motherfucker(point_rot_off is added to rot) #define BONE_M_POINT_TO 1 I64 mode; #define BONE_F_FLIP 1 I64 flags; F64 x,y,z,length; F64 point_x,point_y,point_rot_off; F64 rot; CQue child_bones; }; CBone *BoneNew(C2DObject *obj,CTask *mem_task=NULL) { CBone *b=CAlloc(sizeof CBone,mem_task); b->ident='Bone'; b->obj=obj; QueInit(&b->child_bones); return b; } U0 BoneSetFlip(CBone *bone,Bool on=TRUE) { if(!on) {bone->obj->flipped=TRUE;bone->flags|=BONE_F_FLIP;} else {bone->flags&=~BONE_F_FLIP;bone->obj->flipped=FALSE;} CBone *head=&bone->child_bones,*cur; for(cur=head->next;cur!=head;cur=cur->next) BoneSetFlip(cur,on); } F64 FlipAngle(F64 a) { return (pi-a)+pi; } U0 BoneUpdate(CBone *bone,CBone *parent=NULL) { CBone *head,*cur; F64 dist,ang,flip=1; if(parent&&parent->flags&BONE_F_FLIP) flip=-1; if(!parent) { bone->obj->x=bone->x; bone->obj->y=bone->y; bone->obj->rot=bone->rot; bone->obj->flipped=!!(bone->flags&BONE_F_FLIP); } else { switch(bone->mode) { start: bone->obj->x=parent->obj->x; bone->obj->y=parent->obj->y; dist=Sqrt(Sqr(bone->x)+Sqr(bone->y)); ang=Arg(flip*bone->x,bone->y); bone->obj->x+=dist*Cos(parent->obj->rot+ang); bone->obj->y+=dist*Sin(parent->obj->rot+ang); case BONE_M_NORMAL: if(!(bone->flags&BONE_F_FLIP)) bone->obj->rot=bone->rot+parent->obj->rot; else bone->obj->rot=FlipAngle(bone->rot)+parent->obj->rot; break; case BONE_M_POINT_TO: if(!(bone->flags&BONE_F_FLIP)) bone->obj->rot=Arg(bone->point_x-bone->obj->x,bone->point_y-bone->obj->y)+bone->point_rot_off; else bone->obj->rot=FlipAngle(Arg(-(bone->point_x-bone->obj->x),bone->point_y-bone->obj->y)+bone->point_rot_off); break; end:; } } head=&bone->child_bones; for(cur=head->next;cur!=head;cur=cur->next) { BoneUpdate(cur,bone); } } #if __CMD_LINE__ C2DWorld *w=C2DWorldNew(BLACK); CDC*rect1=DCNew(200,50); CDC*rect2=DCNew(100,50); DCFill(rect1,YELLOW); DCFill(rect2,CYAN); CDC*sq=DCNew(50,50); DCFill(sq,RED); C2DObject *arm=C2DObjectNewFromDC(rect1); C2DObject *arm2=C2DObjectNewFromDC(rect2); C2DObject *hand=C2DObjectNewFromDC(sq); C2DObjectMoveCenter(arm,0,25); C2DObjectMoveCenter(arm2,0,25); C2DObjectMoveCenter(hand,0,0); CBone *arm_bone=BoneNew(arm); CBone *arm_bone2=BoneNew(arm2); arm_bone->x=0,arm_bone->y=0; arm_bone2->x=200,arm_bone2->y=25; CBone *hand_bone=BoneNew(hand); hand_bone->x=100; hand_bone->y=0; QueIns(arm_bone2,&arm_bone->child_bones); QueIns(hand_bone,&arm_bone2->child_bones); AddObjectToWorld(arm,w); AddObjectToWorld(arm2,w); AddObjectToWorld(hand,w); //Recursive U0 DrawIt(CTask *t,CDC *dc) { DrawWorld(Fs,w); GrBlot(dc,0,0,w->scrn); } FlushMsgs; WinMax; U0 Foo() { Fs->draw_it=&DrawIt; while(!ScanKey) { arm_bone->x=GR_WIDTH/2; arm_bone->y=GR_HEIGHT/2; arm_bone->rot=tS; arm_bone2->rot=tS*3; arm_bone2->mode=BONE_M_POINT_TO; arm_bone->point_x=0; arm_bone->point_y=0; BoneUpdate(arm_bone); BoneSetFlip(arm_bone,Blink(.5)); Refresh; } Exit; }; Foo; #endif #endif#ifndef ENGINE_2D #define ENGINE_2D //2 dimensional object extern class C2DWorld; class C2DObject:CQue { U64 ident; //See replace_color/with_color #define C2DOBJF_REPLACE_COLOR 1 #define C2DOBJF_MESH 2 I64 flags; union { CDC *graphics; U8 *sprite; }; F64 x,y,z; F64 center_x,center_y; F64 center_z; F64 rot; F64 rotx,roty; F64 scale; F64 priority; F64 width,height; //This matrix includes all transofrmations U64 *mat; Bool flipped; Bool is_sprite; U8 replace_color; U8 with_color; U8 pad[4]; CTask *mem_task; I64 user_data,lock; U8 name[STR_LEN]; //Private I64 _blot_at_x,_blot_at_y; CDC *_blot_dc; C2DWorld *world; }; CTask *mem_task=Fs; class C2DWorld { I64 background_color; CDC *scrn; CQue objects; I64 in_draw; }; C2DWorld *C2DWorldNew(I64 background_color=BLACK) { C2DWorld *ret=CAlloc(sizeof C2DWorld); QueInit(&ret->objects); ret->scrn=DCNew(GR_WIDTH,GR_HEIGHT); ret->background_color=background_color; DCDepthBufAlloc(ret->scrn); return ret; } U0 C2DObjectUpdateMat(C2DObject *obj) { //This sets us to the identity matrix Mat4x4IdentEqu(obj->mat); //1: move center of graphics to (0,0) //2: rotate //3: scale //4: move to (x,y) // // Move center to 0,0 // Becasue rotations are rotated around (0,0) // Mat4x4TranslationAdd(obj->mat, -obj->center_x, //Use negative cordnates to move towards 0,0 -obj->center_y, -obj->center_z); // //Flip the image by rotationg around the Y axis // if(obj->flipped) Mat4x4RotY(obj->mat,pi); // // We need to rotate around the center // Mat4x4RotX(obj->mat,obj->rotx); Mat4x4RotY(obj->mat,obj->roty); Mat4x4RotZ(obj->mat,obj->rot); // // Scale the image // Mat4x4Scale(obj->mat,obj->scale); // // Now we move // Mat4x4TranslationAdd(obj->mat,obj->x,obj->y,obj->z); } C2DObject *C2DObjectNewFromSprite(U8 *sprite) { I64 min_x,max_x,min_y,max_y; C2DObject *new=CAlloc(sizeof(C2DObject),mem_task); new->ident='Obj'; new->mem_task=mem_task; SpriteExtents(sprite,&min_x,&max_x,&min_y,&max_y); new->width=max_x-min_x; new->height=max_y-min_y; new->sprite=CAlloc(SpriteSize(sprite),mem_task); MemCpy(new->sprite,sprite,SpriteSize(sprite)); new->is_sprite=TRUE; new->mat=Mat4x4IdentNew(mem_task); new->scale=1; QueInit(new); return new; } U0 C2DObjectSetGraphicsFromSprite(C2DObject *obj,U8 *sprite) { I64 min_x,max_x,min_y,max_y; if(!obj->is_sprite) DCDel(obj->graphics); if(obj->sprite) Free(obj->sprite); obj->sprite=CAlloc(SpriteSize(sprite),obj->mem_task); MemCpy(obj->sprite,sprite,SpriteSize(sprite)); sprite=obj->sprite; SpriteExtents(sprite,&min_x,&max_x,&min_y,&max_y); obj->width=max_x-min_x; obj->center_x=0; obj->center_y=0; obj->sprite=sprite; obj->is_sprite=TRUE; C2DObjectUpdateMat(obj); } C2DObject *C2DObjectNewFromDC(CDC*img) { C2DObject *new=CAlloc(sizeof C2DObject,mem_task); new->ident='Obj'; new->mem_task=mem_task; new->graphics=DCCopy(img,mem_task); new->center_x=img->width/2 ; new->center_y=img->height/2; new->width=img->width; new->height=img->height; new->mat=Mat4x4IdentNew(mem_task); new->scale=1; QueInit(new); return new; } U0 C2DObjectMoveCenter(C2DObject *obj,F64 x,F64 y) { obj->center_x=x,obj->center_y=y; C2DObjectUpdateMat(obj); } U0 C2DObjectMove(C2DObject *obj,F64 x,F64 y) { obj->x=x,obj->y=y; C2DObjectUpdateMat(obj); } U0 C2DObjectRotate(C2DObject *obj,F64 rot=0) { obj->rot=rot; C2DObjectUpdateMat(obj); } U0 C2DObjectScale(C2DObject *obj,F64 s) { obj->scale=s; C2DObjectUpdateMat(obj); } U0 C2DObjectSetGraphics(C2DObject *obj,CDC *gr) { if(!obj->is_sprite) DCDel(obj->graphics); obj->graphics=DCCopy(gr,obj->mem_task); obj->center_x=gr->width/2 ; obj->center_y=gr->height/2; obj->width=gr->width; obj->height=gr->height; C2DObjectUpdateMat(obj); } U0 PrepareForBlot(C2DObject *obj) { I64 dummy,min_x,min_y,max_x,max_y; CDC *sprite_dc; CD2I64 a,b,c,d; C2DObjectUpdateMat(obj); if(!obj->is_sprite) ; //GrBlot3(to,0,0,depth_offset,obj->graphics); else if(!(obj->flags&C2DOBJF_MESH)) { SpriteExtents(obj->sprite,&a.x,&b.x,&a.y,&b.y); c.x=a.x; c.y=b.y; d.x=b.x; d.y=a.y; Mat4x4MulXYZ(obj->mat,&a.x,&a.y,&dummy); Mat4x4MulXYZ(obj->mat,&b.x,&b.y,&dummy); Mat4x4MulXYZ(obj->mat,&c.x,&c.y,&dummy); Mat4x4MulXYZ(obj->mat,&d.x,&d.y,&dummy); min_x=MinI64(a.x,b.x); min_x=MinI64(min_x,c.x); min_x=MinI64(min_x,d.x); min_y=MinI64(a.y,b.y); min_y=MinI64(min_y,c.y); min_y=MinI64(min_y,d.y); max_x=MaxI64(a.x,b.x); max_x=MaxI64(max_x,c.x); max_x=MaxI64(max_x,d.x); max_y=MaxI64(a.y,b.y); max_y=MaxI64(max_y,c.y); max_y=MaxI64(max_y,d.y); sprite_dc=DCNew( Clamp(max_x-min_x+1,1,GR_WIDTH), Clamp(max_y-min_y+1,1,GR_HEIGHT)); DCFill(sprite_dc); Sprite3Mat4x4B(sprite_dc,-min_x,-min_y,0,obj->sprite,obj->mat); //Compute center c.x=0,c.y=0; Mat4x4MulXYZ(obj->mat,&c.x,&c.y,&dummy); obj->_blot_at_x=c.x-(c.x-min_x); obj->_blot_at_y=c.y-(c.y-min_y); obj->_blot_dc=sprite_dc; } } U0 C2DObjectRemoveFromWorld(C2DObject *obj) { QueRem(obj); QueInit(obj); } U0 C2DObjectDel(C2DObject *obj) { QueRem(obj); if(!obj->is_sprite) DCDel(obj->graphics); Free(obj->mat); Free(obj); } U0 C2DWorldDel(C2DWorld *world) { C2DObject *cur,*next; I64 idx; while(LBts(&world->in_draw,0)) Sleep(1); for(cur=world->objects.next;cur!=&world->objects;) { next=cur->next; C2DObjectDel(cur); cur=next; } Free(world);; } U0 AddObjectToWorld(C2DObject *obj,C2DWorld *world) { while(LBts(&world->in_draw,0)) Yield; C2DObject *head=&world->objects,*cur=head->next; if(!obj->priority) obj->priority=QueCnt(head); while(cur!=head) { if(obj->prioritypriority) { QueInsRev(obj,cur); goto fin; } cur=cur->next; } obj->world=world; QueIns(obj,head->last); fin: LBtr(&world->in_draw,0); } class CMPDrawItNugget { CDC *to; C2DWorld *world; I64 start,end; CMPDrawItNugget *last,*next; I64 ready_to_merge; I64 merged; CTask *parent; I64 done; }; U0 MPDrawIt(CMPDrawItNugget *nugget) { C2DObject *head=&nugget->world->objects,*cur=head->next; I64 old_flags; U8 *old_mat; if(!nugget->to) { nugget->to=DCNew( nugget->world->scrn->width, nugget->world->scrn->height, nugget->world->scrn->mem_task); DCFill(nugget->to,TRANSPARENT); } I64 i; for(i=0;iend&&cur!=head;i++) { if(nugget->start<=i) { PrepareForBlot(cur); if(cur->flags&C2DOBJF_MESH) { C2DObjectUpdateMat(cur); Sprite3Mat4x4B(nugget->to,0,0,0,cur->sprite,cur->mat); } else if(!cur->is_sprite) { old_flags=nugget->to->flags; old_mat=nugget->to->r; nugget->to->flags|=DCF_TRANSFORMATION; nugget->to->r=cur->mat; if(cur->graphics) { if(cur->flags&C2DOBJF_REPLACE_COLOR) DCColorChg(cur->graphics,cur->replace_color,cur->with_color); GrBlot3(nugget->to,0,0,0,cur->graphics); } nugget->to->r=old_mat; nugget->to->flags=old_flags; } else { if(cur->flags&C2DOBJF_REPLACE_COLOR) DCColorChg(cur->_blot_dc,cur->replace_color,cur->with_color); GrBlot(nugget->to,cur->_blot_at_x,cur->_blot_at_y,cur->_blot_dc); DCDel(cur->_blot_dc); cur->_blot_dc=NULL; } } cur=cur->next; } nugget->parent->wake_jiffy=0; LBts(&nugget->done,0); } I64 PrioritySort(C2DObject *a,C2DObject *b) { if(b->priority>a->priority) return 1; if(b->prioritypriority) return -1; return 0; } U0 WorldSortByPriority(C2DWorld *w) { I64 cnt=QueCnt(&w->objects),i; C2DObject **sorted=MAlloc(8*cnt); C2DObject *head=&w->objects,*cur=head->next; for(cnt=0;cur!=head;cnt++) { sorted[cnt]=cur; cur=cur->next; } QSortI64(sorted,cnt,&PrioritySort); QueInit(&w->objects); for(i=0;i!=cnt;i++) { QueIns(sorted[i],&w->objects); } Free(sorted); } U0 DrawWorld(CTask *t,C2DWorld *world) { if(!t) t=Fs; LBts(&world->in_draw,0); I64 i,core_cnt,i2=0,cap; I64 old_flags,*old_mat; CMPDrawItNugget nuggets[mp_cnt]; MemSet(nuggets,0,sizeof(CMPDrawItNugget)*mp_cnt); world->scrn->color=world->background_color; DCDepthBufRst(world->scrn); DCFill(world->scrn,TRANSPARENT); TextRect(t->win_left,t->win_right,t->win_top,t->win_bottom,world->background_color<<12); //head points to the head of the CQue C2DObject *head=&world->objects,*cur=head->next; WorldSortByPriority(world); //Because CQue's wrap around,we check for head as the last element // A is the head // // A->B->C-\ // ^ | // | | // \-------/ // one: cur=head->next; while(cur!=head) { PrepareForBlot(cur); cur=cur->next; } i2=QueCnt(head); cur=head->next; while(i2--) { if(cur->flags&C2DOBJF_MESH) { C2DObjectUpdateMat(cur); Sprite3Mat4x4B(world->scrn,0,0,0,cur->sprite,cur->mat); } else if(!cur->is_sprite) { old_flags=world->scrn->flags; old_mat=world->scrn->r; world->scrn->flags|=DCF_TRANSFORMATION; world->scrn->r=cur->mat; if(cur->graphics) { if(cur->flags&C2DOBJF_REPLACE_COLOR) DCColorChg(cur->graphics,cur->replace_color,cur->with_color); GrBlot3(world->scrn,0,0,cur->z,cur->graphics); } world->scrn->r=old_mat; world->scrn->flags=old_flags; } else { if(cur->flags&C2DOBJF_REPLACE_COLOR) DCColorChg(cur->_blot_dc,cur->replace_color,cur->with_color); GrBlot3(world->scrn,cur->_blot_at_x,cur->_blot_at_y,cur->z,cur->_blot_dc); DCDel(cur->_blot_dc); } cur=cur->next; } LBtr(&world->in_draw,0); } U0 C2DObjectPointTo(C2DObject *obj,F64 x,F64 y) { //We want to make the x,y relative to the obj's cordnates x-=obj->x; y-=obj->y; //https://en.wikipedia.org/wiki/Atan2 //ATan2 gets the angle that points to (x,y) obj->rot=Arg(x,y); C2DObjectUpdateMat(obj); } // // Test section // class CD2F64 { F64 x,y; }; U0 CrossProduct(CD2F64 *dst,CD2F64 *a,CD2F64 *b) { dst->x=a->y-b->y; dst->y=a->x-b->x; } Bool InRange(F64 a,F64 v,F64 b) { if(a>b) return a>=v>=b; return a<=v<=b; } class CD2F64 { F64 x,y; }; U0 CrossProduct(CD2F64 *dst,CD2F64 *a,CD2F64 *b) { dst->x=a->y-b->y; dst->y=a->x-b->x; } Bool InRange(F64 a,F64 v,F64 b) { if(a>b) return a>=v>=b; return a<=v<=b; } Bool PlaneIntersect(CD2I64 *dst,CD2I64 *a,CD2I64 *b,CD2I64 *a2,CD2I64 *b2) { /* * Nroot here,Heres the deal,I make a system of 2 linear equations and solve for an intersect * I solve for the intersect and check if they are in bounds of points Check for intersection basically. / ----*------ / / / */ F64 slope1,slope2,off1,off2; CD2I64 dummy; if(!dst) dst=&dummy; //If the line points straight up,we can check to see if the other //line goes through the y position,if so,it is a hit if((b->x==a->x)||(b2->x==a2->x)) { if(a->x==b->x&&a2->x==b2->x) { if(a->x==a2->x) { dst->x=a->x; dst->y=a->y; goto fin; } else return FALSE; } if(a->x==b->x) { dst->x=a->x; slope2=(ToF64(b2->y)-a2->y)/(ToF64(b2->x)-a2->x); dst->y=slope2*(dst->x-a2->x)+a2->y; goto fin; } if(a2->x==b2->x) { dst->x=a2->x; slope1=(ToF64(b->y)-a->y)/(ToF64(b->x)-a->x); dst->y=slope1*(dst->x-a->x)+a->y; goto fin; } goto fin; } //https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection slope2=(ToF64(b2->y)-a2->y)/(ToF64(b2->x)-a2->x); slope1=(ToF64(b->y)-a->y)/(ToF64(b->x)-a->x); off1=slope1*-a->x+a->y; off2=slope2*-a2->x+a2->y; dst->x=((off2-off1)/(slope1-slope2)); dst->y=slope1*(dst->x)+off1; fin: return InRange(a->x,dst->x,b->x)&& InRange(a2->x,dst->x,b2->x)&& InRange(a->y,dst->y,b->y)&& InRange(a2->y,dst->y,b2->y); } Bool C2DObjectCollisionTest(C2DObject*o1,C2DObject *o2,CD2I64 *hit_at=NULL) { I64 nul=1,i,i2; I64 o1_mat[16],o2_mat[16]; CD2I64*o1_edges[5]; CD2I64*o2_edges[5]; CD2I64 a,b,c,d; CD2I64 a2,b2,c2,d2; if(!o1->is_sprite) { a.x=0; b.x=0+o1->width; c.x=0+o1->width; d.x=0; a.y=0; b.y=0; c.y=0+o1->height; d.y=0+o1->height; } else{ SpriteExtents(o1->sprite,&a.x,&b.x,&a.y,&c.y); d.x=a.x; //min c.x=b.x; //max b.y=a.y; //min d.y=c.y; //max } if(!o2->is_sprite) { a2.x=0; b2.x=0+o2->width; c2.x=0+o2->width; d2.x=0; a2.y=0; b2.y=0; c2.y=0+o2->height; d2.y=0+o2->height; } else { SpriteExtents(o2->sprite,&a2.x,&b2.x,&a2.y,&c2.y); d2.x=a2.x; //min c2.x=b2.x; //max b2.y=a2.y; //min d2.y=c2.y; //max } C2DObjectUpdateMat(o1); C2DObjectUpdateMat(o2); Mat4x4Equ(o1_mat,o1->mat); Mat4x4Equ(o2_mat,o2->mat); // Mat4x4Scale(o1_mat,1<<16); // Mat4x4Scale(o2_mat,1<<16); nul=0; Mat4x4MulXYZ(o1_mat,&a.x,&a.y,&nul); nul=0; Mat4x4MulXYZ(o1_mat,&b.x,&b.y,&nul); nul=0; Mat4x4MulXYZ(o1_mat,&c.x,&c.y,&nul); nul=0; Mat4x4MulXYZ(o1_mat,&d.x,&d.y,&nul); nul=0; Mat4x4MulXYZ(o2_mat,&a2.x,&a2.y,&nul); nul=0; Mat4x4MulXYZ(o2_mat,&b2.x,&b2.y,&nul); nul=0; Mat4x4MulXYZ(o2_mat,&c2.x,&c2.y,&nul); nul=0; Mat4x4MulXYZ(o2_mat,&d2.x,&d2.y,&nul); o1_edges[0]=&a; o1_edges[1]=&b; o1_edges[2]=&c; o1_edges[3]=&d; o1_edges[4]=&a; o2_edges[0]=&a2; o2_edges[1]=&b2; o2_edges[2]=&c2; o2_edges[3]=&d2; o2_edges[4]=&a2; for(i=0;i!=4;i++) for(i2=0;i2!=4;i2++) { if(PlaneIntersect(hit_at,o1_edges[i],o1_edges[i+1], o2_edges[i2],o2_edges[i2+1])) { if(hit_at) hit_at->x/=(1<<16); if(hit_at) hit_at->y/=(1<<16); return TRUE; } } return FALSE; } U0 C2DObjectSetFlip(C2DObject *sp,Bool flip) { sp->flipped=flip; C2DObjectUpdateMat(sp); } C2DObject *C2DObjectCopy(C2DObject *src) { C2DObject *copy=MAllocIdent(src,mem_task); copy->mat=Mat4x4New(src->mat,mem_task); copy->mem_task=mem_task; if(copy->is_sprite) copy->sprite=src->sprite; else copy->graphics=DCCopy(src->graphics,mem_task); return copy; } #endif