home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD15673312001.psc / CCar.cls < prev    next >
Encoding:
Visual Basic class definition  |  2001-02-18  |  1.8 KB  |  90 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "CCar"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. Option Explicit
  15. Private sdCar As DDSURFACEDESC2
  16. Public dsCar As DirectDrawSurface7
  17. Private recCar As RECT
  18.  
  19. Private m_XPos
  20. Private m_YPos
  21.  
  22. Private Sub Class_Initialize()
  23. Dim Key As DDCOLORKEY
  24.  
  25. sdCar.lFlags = DDSD_CAPS
  26. sdCar.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
  27. Set dsCar = ddMain.CreateSurfaceFromFile(App.Path & "\car.BMP", sdCar)
  28. recCar.Bottom = sdCar.lHeight
  29. recCar.Right = sdCar.lWidth
  30. Key.low = 0
  31. Key.high = 0
  32. dsCar.SetColorKey DDCKEY_SRCBLT, Key
  33.  
  34. XPos = 240
  35. YPos = 300
  36. End Sub
  37.  
  38. Public Property Get XPos() As Long
  39. XPos = m_XPos
  40. End Property
  41. Public Property Let XPos(vNewVal As Long)
  42. m_XPos = vNewVal
  43. End Property
  44.  
  45. Public Property Get YPos() As Long
  46. YPos = m_YPos
  47. End Property
  48. Public Property Let YPos(vNewVal As Long)
  49. m_YPos = vNewVal
  50. End Property
  51.  
  52. Public Property Get RECTO() As RECT
  53. RECTO = recCar
  54. End Property
  55.  
  56. Public Property Get DestRect() As RECT
  57. DestRect.Bottom = YPos + RECTO.Bottom
  58. DestRect.Top = YPos
  59. DestRect.Left = XPos
  60. DestRect.Right = XPos + RECTO.Right
  61. End Property
  62.  
  63.  
  64. Public Function ShiftRight()
  65. If Not m_XPos >= 340 Then
  66.     m_XPos = m_XPos + 5
  67. End If
  68. End Function
  69.  
  70. Public Function ShiftLeft()
  71. If Not m_XPos <= 205 Then m_XPos = m_XPos - 5
  72. End Function
  73.  
  74. Public Function ShiftUP()
  75. If Not m_YPos <= 0 Then
  76.     m_YPos = m_YPos - 5
  77. Else: m_YPos = 0
  78. End If
  79. End Function
  80.  
  81. Public Function ShiftDown()
  82. If Not m_YPos >= 480 - RECTO.Bottom Then
  83.     m_YPos = m_YPos + 5
  84. Else
  85.     m_YPos = 480 - RECTO.Bottom
  86. End If
  87. End Function
  88.  
  89.  
  90.