home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / euphor10.zip / MOUSE.EX < prev    next >
Text File  |  1993-06-25  |  1KB  |  63 lines

  1.         ----------------
  2.         -- mouse test --
  3.         ----------------
  4. -- This is a simple program to demonstrate the get_mouse() built-in
  5. -- function. No call is made to mouse_events(), so by default all events are
  6. -- reported by get_mouse(). 
  7.  
  8. include mouse.e
  9. include graphics.e
  10.  
  11. sequence vc
  12. vc = video_config()
  13. graphics_mode(17 + vc[VC_COLOR]) -- 640x480 (16 colors)
  14. vc = video_config()
  15.  
  16. procedure beep()
  17.     atom t
  18.     sound(500)
  19.     t = time()
  20.     while time() < t+0.07 do
  21.     end while
  22.     sound(0)
  23. end procedure
  24.  
  25. constant origin = {vc[VC_XPIXELS]/2, vc[VC_YPIXELS]/2}
  26.  
  27. procedure try_mouse()
  28.     integer color
  29.     object event
  30.  
  31.     color = 14
  32.     while 1 do
  33.         event = get_mouse()
  34.         if sequence(event) then
  35.         printf(1, "event: %d, x:%d, y:%d       \r", event)
  36.         if event[1] = MOVE then
  37.         draw_line(color, 1, {origin, {event[2], event[3]}}) 
  38.  
  39.         elsif event[1] = LEFT_DOWN then
  40.         beep()
  41.             color = color + 1
  42.         if color > 15 then
  43.             color = 0
  44.         end if 
  45.  
  46.         elsif event[1] = LEFT_UP then
  47.         beep()
  48.                 
  49.         elsif event[1] = RIGHT_DOWN or 
  50.           event[1] = MIDDLE_DOWN then
  51.         exit
  52.         end if
  53.     end if
  54.     end while
  55. end procedure
  56.  
  57. try_mouse()
  58. if vc[VC_COLOR] then
  59.     graphics_mode(3)
  60. else
  61.     graphics_mode(7)
  62. end if
  63.