Page 152 - DCAP313_LAB_ON_COMPUTER_GRAPHICS
P. 152

Lab on Computer Graphics



                   Notes                   intgrd,grm;
                                           intkey;
                                           intx1=10,y1=30,x2=100,y2=70;
                                           intnewx,newy;
                                           intxoffset=10,yoffset=5;
                                           detectgraph(&grd,&grm);
                                           initgraph(&grd,&grm,”“);
                                           draw_pixelbackground();
                                           draw_object(x1,y1,x2,y2);
                                           while(1)
                                           {
                                           key=bioskey(0);
                                           if((key&0x00FF)>0)
                                           key=key&0x00FF;
                                           else
                                           key=(key&0xFF00)>>8;
                                           switch(key)
                                           {
                                           caseLTARROW:
                                           newx=x1-xoffset;
                                           newy=y1;
                                           move_object(x1,y1,x2,y2,newx,newy);
                                           x1-=xoffset;
                                           x2-=xoffset;
                                           break;
                                           caseRTARROW:
                                           newx=x1+xoffset;
                                           newy=y1;
                                           move_object(x1,y1,x2,y2,newx,newy);
                                           x1+=xoffset;
                                           x2+=xoffset;
                                           break;
                                           caseDNARROW:
                                           newx=x1;
                                           newy=y1+yoffset;
                                           move_object(x1,y1,x2,y2,newx,newy);
                                           y1+=yoffset;
                                           y2+=yoffset;
                                           break;
                                           caseUPARROW:
                                           newx=x1;




        146                               LOVELY PROFESSIONAL UNIVERSITY
   147   148   149   150   151   152   153   154   155   156   157