home *** CD-ROM | disk | FTP | other *** search
/ Virtual Reality Madness / VRMAD96_ONE.ISO / virtek / libex / libex072.c < prev    next >
C/C++ Source or Header  |  1995-08-24  |  2KB  |  59 lines

  1.                                            // Example: 072 from Library Reference
  2. #include "..\3d-ware\dddware.h"
  3.  
  4. struct ObjectStructure shape1 =
  5.   {
  6.     0,0,0,                                 // positions : Xpos,Ypos,Zpos
  7.     0,0,0,                                 // angles    : Xangle,Yangle,Zangle
  8.     0,                                     // handle    : ShapeHandle
  9.     0,                                     // flags     : ShapeFlags
  10.     DRW_MOBILE };                          // draw type : DrawRoutine
  11. struct ObjectStructure shape2 =
  12.   {
  13.     100,0,0,                               // position, a little to the right.
  14.     0,0,0,                                 // angles
  15.     0,                                     // handle
  16.     0,                                     // flags
  17.     DRW_MOBILE };                          // draw type
  18.  
  19. short myXpos,myYpos;
  20.  
  21. short  main(void)
  22. {
  23.   dddInitAll();
  24.   shape1.ShapeHandle=shape2.ShapeHandle=dddShapeLoad("EXAMPLE.3D");
  25.   dddLookAt16(0,0,0,-16384,0,0,700);       // Look from above.
  26.   while (dddkeycode!=_ESC)
  27.   {
  28.     dddCls();
  29.  
  30.     dddClearObjects();
  31.     dddQInsertObject(&shape1);             // Insert first shape.
  32.     dddQInsertObject(&shape2);             // Insert second shape.
  33.     dddDrawObjects();
  34.  
  35.     if (dddIsCollision(&shape1,&shape2))   // Check for collision.
  36.     {
  37.       dddMedPrintC(11,10,"COLLISION");
  38.     }
  39.     else
  40.     {
  41.       dddMedPrintC(11,10,"NO COLLISION");
  42.     }
  43.     dddMouseGetRelPointerXy(&myXpos,&myYpos);
  44.     if (dddMouseGetButtons())
  45.     {                                      // If button pressed.
  46.       shape2.Yangle+=(myXpos)<<4;          // Rotate shape2.
  47.     }
  48.     else
  49.     {                                      // If no buttons pressed.
  50.       shape2.Xpos+=(myXpos)<<2;            // Move shape2 using.
  51.       shape2.Zpos-=(myYpos)<<2;            // The mouse.
  52.     }
  53.  
  54.     dddScreenSwap();
  55.   }
  56.   dddRestoreAll();
  57.   return 0;
  58. }
  59.