home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1994-09-02 | 4.0 KB | 177 lines | [ TEXT/MMCC]
/******************************************** **** ACL-World **** **** Controls.cp **** **** Created: 25 August 1994 **** Modified: 30 August 1994 **** Version: 0 **** Compatible: C++, Mac System 7 **** **** Description: Sorting demo. **** *******************/ #include "ACL-World.h" //************************************* static const short PICT_BACKGROUND = 157; static const short PICT_MONSTER = 156; static const short PICT_PERS = 160; //************************************* #define TEXTSTEP1 "\pSuppose that there are two objects on screen: a character and a bird. Should the bird be in front of the character..." #define TEXTSTEP2 "\pOr should the character be in front of the bird? All moveable objects of ACL have a sorting priority. Objects which have the higher priority are draw in front of others. At any time the user can change the priority of an object." #define TEXTSTEP3 "\pNow look at this background. How should be sorted objects? Objects which have the smaller vertical position should be drawed behind the others. ACL implements eight algorithms which allow automatic sorting." #define TEXTSTEP4 "\pIn this example an ACL algorithm may be installed to automatically sort the object using the vertical position. Click in the picture to move the charactere and examine the result of the automatic classing." //************************************* static AnimGfx *background; static short backwidth,backheight; static Anim *anims[5]; //************************************* Boolean ACLWorld::sorting_advance(void) { short i; Handle ha; Rect rect; static short w,h; step++; GetDItem(dialog,1,&i,&ha,&rect); switch(step) { case 1: SetIText(ha,TEXTSTEP1); animbase->setsortflags(ASORT_PRIORITY); anims[0] = animbase->createanim(PICT_PERS); anims[1] = animbase->createanim(PICT_MONSTER); anims[0]->arrange_movehandlepoint(0,0,-1); anims[1]->arrange_movehandlepoint(0,0,-1); anims[0]->findmaxsize(&w,&h); anims[0]->place((backwidth/2)-(w/2),((backheight/2)-(h/2))+h); anims[1]->findmaxsize(&w,NULL); anims[1]->place((backwidth/2)-(w/2),((backheight/2)-(h/2))+h); anims[1]->setpriority(10); return FALSE; case 2: SetIText(ha,TEXTSTEP2); anims[0]->setpriority(20); return FALSE; case 3: SetIText(ha,TEXTSTEP3); animbase->installbackground(background); anims[2] = animbase->createanim(PICT_MONSTER); anims[3] = animbase->createanim(PICT_MONSTER); anims[4] = animbase->createanim(PICT_MONSTER); anims[2]->arrange_movehandlepoint(0,0,-1); anims[3]->arrange_movehandlepoint(0,0,-1); anims[4]->arrange_movehandlepoint(0,0,-1); anims[0]->findmaxsize(&w,&h); anims[0]->arrange_moveframeoffsets(0, -(w/2), 0); animbase->setsortflags(ASORT_BOTTOMRIGHT); anims[0]->place((backwidth/2)-(w/2),((backheight/2)-(h/2))+h+30); anims[1]->place(60,145); anims[2]->place(280,200); anims[3]->place(60,198); anims[4]->place(330,185); return FALSE; case 4: SetIText(ha,TEXTSTEP4); return FALSE; } return TRUE; } //************************************* Boolean ACLWorld::do_sorting(void) { Point p; char key; short res; Boolean done = FALSE; pleasewait(TRUE); animbase = new AnimBase(); background = animbase->newgfx(PICT_BACKGROUND); animbase->newgfx(PICT_PERS); animbase->newgfx(PICT_MONSTER); backwidth = background->getwidth(); backheight = background->getheight(); animbase->buildbuffer(460,217); animbase->setbasex(17); animbase->setbasey(8); pleasewait(FALSE); step = 0; openbasedialog(); SetWTitle(dialog,"\pSorting"); sorting_advance(); for(;;) { res = processbasedialog(key,p); if (res==DO_QUIT) {done=TRUE; break;} else if (res==DO_MENU) break; else if (res==DO_CONTINUE && sorting_advance()) break; else if (res==DO_MOUSECLICK && step==4) { if (p.h<460 && p.v<217 && p.h>=0 && p.v>=0) { if (p.v<140) p.v=140; anims[0]->place(p.h,p.v); } } } closebasedialog(); delete animbase; return done; } //*************************************