home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / source / chap17 / saucer3.avr < prev    next >
Encoding:
Text File  |  1996-08-14  |  1.4 KB  |  44 lines

  1. // ActiveVRML 1.0 ASCII
  2. // Saucer3 Sample Script
  3.  
  4. // The first step is to import the raw media for our sample
  5. shipred = first (import ("shipred.gif"));
  6. shipblue = first (import ("shipblue.gif"));
  7. mountain, extents = import ("mountain.gif");
  8. clouds = first (import ("clouds.gif"));
  9. shipnoise = loop (first (import ("ship.wav")));
  10.  
  11. // The saucer will alternate between two different images
  12. saucer = shipred until predicate (time > 1) => 
  13.     (shipblue until predicate (time > 1) => saucer);
  14.  
  15. // Identify the components of the image boundary
  16. maxx = xComponent (extents);
  17. maxy = yComponent (extents);
  18.  
  19. // Make speed a function of the image size
  20. velocityx = maxx / 5;
  21. velocityy = velocityx;
  22.  
  23. // Modify the x and y positions
  24. xpos = (velocityx * time - maxx) until edgeevent => xpos;
  25. ypos = sin (time) * velocityy + (maxy / 4);
  26.  
  27. // Define an event handling moving off the right side of the image
  28. edgeevent = predicate (xpos > maxx); 
  29.  
  30. // Define a 2D transformation to describe the saucer's position
  31. movement = translate (xpos, ypos);
  32.  
  33. // Define a new saucer object that has movement applied to it
  34. activesaucer = transformImage (movement, saucer);
  35.  
  36. // Add some effects to our sound
  37. soundgain = ypos / maxy  + 0.2;
  38. soundeffect = gain (soundgain, rate (2, shipnoise));
  39.  
  40. // Define the expression used for display output
  41. model = mountain over activesaucer over clouds, soundeffect;
  42.  
  43.  
  44.