home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / OldSrc / CH5 / SRC / SPRITES.BAS < prev    next >
Encoding:
BASIC Source File  |  1997-01-08  |  3.1 KB  |  71 lines

  1. Attribute VB_Name = "SpriteFuncs"
  2. Option Explicit
  3.  
  4. Global Const PS_SOLID = 0  ' Solid pen style.
  5.  
  6. #If Win32 Then  ' 32-bit VB.
  7.     Type POINTAPI
  8.         x As Long
  9.         y As Long
  10.     End Type
  11.     
  12.     Type BITMAP ' 24 bytes
  13.         bmType As Long
  14.         bmWidth As Long
  15.         bmHeight As Long
  16.         bmWidthBytes As Long
  17.         bmPlanes As Integer
  18.         bmBitsPixel As Integer
  19.         bmBits As Long
  20.     End Type
  21.     Global Const BITMAP_SIZE = 24
  22.     Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Integer, ByVal dwCount As Long, lpBits As Any) As Long
  23.     Declare Function SetBitmapBits Lib "gdi32" (ByVal hBitmap As Integer, ByVal dwCount As Long, lpBits As Any) As Long
  24.     Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
  25.     Declare Function GetTickCount Lib "kernel32" () As Long
  26.     Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
  27.     Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
  28.     Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
  29.     Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
  30.     Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
  31. #Else           ' 16-bit VB.
  32.     Type POINTAPI
  33.         x As Integer
  34.         y As Integer
  35.     End Type
  36.     
  37.     Type BITMAP ' 14 bytes
  38.         bmType As Integer
  39.         bmWidth As Integer
  40.         bmHeight As Integer
  41.         bmWidthBytes As Integer
  42.         bmPlanes As String * 1
  43.         bmBitsPixel As String * 1
  44.         bmBits As Long
  45.     End Type
  46.     Global Const BITMAP_SIZE = 14
  47.     Declare Function GetBitmapBits Lib "GDI" (ByVal hBitmap As Integer, ByVal dwCount As Long, lpBits As Any) As Long
  48.     Declare Function SetBitmapBits Lib "GDI" (ByVal hBitmap As Integer, ByVal dwCount As Long, lpBits As Any) As Long
  49.     Declare Function GetObject Lib "GDI" (ByVal hObject As Integer, ByVal nCount As Integer, lpObject As Any) As Integer
  50.     Declare Function GetTickCount Lib "User" () As Long
  51.     Declare Function Polygon Lib "GDI" (ByVal hdc As Integer, lpPoints As POINTAPI, ByVal nCount As Integer) As Integer
  52.     Declare Function CreatePen Lib "GDI" (ByVal nPenStyle As Integer, ByVal nWidth As Integer, ByVal crColor As Long) As Integer
  53.     Declare Function CreateSolidBrush Lib "GDI" (ByVal crColor As Long) As Integer
  54.     Declare Function SelectObject Lib "GDI" (ByVal hdc As Integer, ByVal hObject As Integer) As Integer
  55.     Declare Function DeleteObject Lib "GDI" (ByVal hObject As Integer) As Integer
  56. #End If
  57.  
  58. ' ************************************************
  59. ' Pause until GetTickCount shows the indicated
  60. ' time. This is accurate to within one clock tick
  61. ' (55 ms), not counting variability in DoEvents
  62. ' and Windows itself.
  63. ' ************************************************
  64. Sub WaitTill(next_time As Long)
  65.     Do
  66.         DoEvents
  67.     Loop While GetTickCount() < next_time
  68. End Sub
  69.  
  70.  
  71.