home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Aktiv 1 / CDA1_96.ISO / clipper / poink.prg < prev    next >
Text File  |  1996-01-06  |  5KB  |  148 lines

  1. //----------------------------------------------------------------------------
  2. //           Name: Poink.prg
  3. //        Purpose: bounce a bmpfile around the screen / need vga display
  4. //
  5. //         Author: Esteban Castorena Osuna
  6. //   Date created: 12-08-95
  7. //      Copyright: Naaaaa
  8. //
  9. //         Syntax: Poink(bmpfile [,speedinX] [,speedinY])   --> NIL
  10. //
  11. //   Return Value: NIL
  12. //
  13. //    Description: bounces a bmpfile around the screen
  14. //
  15. //           Note: speedinX is Delta X
  16. //                 speedinY is Delta Y
  17. //
  18. //                 WORKS ONLY WITH CA-CLIPPER 5.3
  19. //
  20. //                 EXOSPACE FI POINK LIB LLIBG
  21. //
  22. //                 Have some other nice libs will be contributing later
  23. //                 Tell me if you liked it or if you have some other
  24. //                 libs to share with me.
  25. //           CIS : 75061,417
  26. //
  27. //----------------------------------------------------------------------------
  28.  
  29.  
  30.  
  31. #define nwait   .01                    // seconds to wait between displays
  32. #define xincrement 1                   // increment xN between displays
  33. #define yincrement 1                   // increment yN between displays
  34.  
  35. #define screenw    639                 // screen witdh  640-1 starts at 0
  36. #define screenh    479                 // screen height 480-1 starts at 0
  37.  
  38. static bmp,x,y,xincr,yincr,xold,yold,iwidth,iheight,direction:=1
  39.                                                    // 1 fowards   down
  40.                                                    // 2 fowards   up
  41.                                                    // 3 backwards down
  42.                                                    // 4 backwards up
  43.  
  44. func Poink(newbmp,speedx,speedy)
  45. Local nkey
  46.    cls
  47.    if newbmp<>NIL .and. File(newbmp)
  48.       bmp := gbmpload(newbmp)  // load bmp
  49.    else
  50.       ? "Can't seem to find any bmp to display"
  51.       quit
  52.    endif
  53.    iwidth  = bmp[1]       // bmp's width
  54.    iheight = bmp[2]       // bmp's height
  55.    set videomode to 18
  56.    set cursor off
  57.    x=0 ; y=0              // inicial position
  58.    xincr = if(speedx==NIL,xincrement,val(speedx))
  59.    yincr = if(speedy==NIL,yincrement,val(speedy))
  60.    xold = x ; yold = y
  61.    gbmpdisp(bmp,x,y)
  62.    nkey = fowdn()
  63.    do while .t. .and. nkey == 0
  64.       do case
  65.       case direction == 1
  66.          nkey = if( x >= screenw-iwidth, bakdn(),fowup())
  67.       case direction == 2
  68.          nkey = if( x >= screenw-iwidth, bakup(),fowdn())
  69.       case direction == 3
  70.          nkey = if( y >= screenh-iheight,bakup(),fowdn())
  71.       case direction == 4
  72.          nkey = if( x <= 0              ,fowup(),bakdn())
  73.       endcase
  74.       if nkey<>0 ; exit ; endif
  75.    enddo
  76.    cls
  77.    set videomode to 3
  78.    set cursor on
  79. retu nkey
  80.  
  81.  
  82. stat func fowdn
  83. local nkey:=0
  84.    do while x < screenw-iwidth .and. y < screenh-iheight
  85.       nkey:=inkey(nwait)
  86.       if (x+xincr+iwidth )>screenw ; x = screenw-(xincr+iwidth ) ; endif
  87.       if (y+yincr+iheight)>screenh ; y = screenh-(yincr+iheight) ; endif
  88.       x+=xincr ; y+=yincr
  89.       gbmpdisp(bmp,x,y)
  90.       grect(xold,yold,xold+iwidth,y           ,.t.,0,-1)
  91.       grect(xold,y   ,x          ,yold+iheight,.t.,0,-1)
  92.       xold = x ; yold = y
  93.       if nkey<>0 ; exit ; endif
  94.    enddo
  95.    direction = 1
  96. retu nkey
  97.  
  98.  
  99. stat func fowup
  100. local nkey:=0
  101.    do while x < screenw-iwidth .and. y > 0
  102.       nkey:=inkey(nwait)
  103.       if (x+xincr+iwidth )>screenw ; x = screenw-(xincr+iwidth ) ; endif
  104.       if (y-yincr) < 0 ; y = yincr ; endif
  105.       x+=xincr ; y-=yincr
  106.       gbmpdisp(bmp,x,y)
  107.       grect(xold,y        ,x          ,y+iheight   ,.t.,0,-1)
  108.       grect(xold,y+iheight,xold+iwidth,yold+iheight,.t.,0,-1)
  109.       xold = x ; yold = y
  110.       if nkey<>0 ; exit ; endif
  111.    enddo
  112.    direction = 2
  113. retu nkey
  114.  
  115. stat func bakdn
  116. local nkey:=0
  117.    do while x > 0 .and. y < screenh-iheight
  118.       nkey:=inkey(nwait)
  119.       if (x-xincr) < 0 ; x = xincr ; endif
  120.       if (y+yincr+iheight)>screenh ; y = screenh-(yincr+iheight) ; endif
  121.       x-=xincr ; y+=yincr
  122.       gbmpdisp(bmp,x,y)
  123.       grect(xold    ,yold,xold+iwidth,y            ,.t.,0,-1)
  124.       grect(x+iwidth,y   ,xold+iwidth,yold+ iheight,.t.,0,-1)
  125.       xold = x ; yold = y
  126.       if nkey<>0 ; exit ; endif
  127.    enddo
  128.    direction = 3
  129. retu nkey
  130.  
  131. stat func bakup
  132. local nkey:=0
  133.    do while x > 0 .and. y > 0
  134.       nkey:=inkey(nwait)
  135.       if (x-xincr) < 0 ; x = xincr ; endif
  136.       if (y-yincr) < 0 ; y = yincr ; endif
  137.       x-=xincr ; y-=yincr
  138.       gbmpdisp(bmp,x,y)
  139.       grect(x+iwidth,yold     ,xold+iwidth,y+iheight   ,.t.,0,-1)
  140.       grect(xold    ,y+iheight,xold+iwidth,yold+iheight,.t.,0,-1)
  141.       xold = x ; yold = y
  142.       if nkey<>0 ; exit ; endif
  143.    enddo
  144.    direction = 4
  145. retu nkey
  146.  
  147. *** End of Poink()
  148.