''''''These Variables are for the example game'''''''
Public CurX As Integer
Public CurY As Integer
Public UX As Integer
Public UY As Integer
Public TX As Integer
Public TY As Integer
Public AY As Integer
Public AX As Integer
Public kflag As Boolean
Public UDir As Byte
Public TDir As Byte
Public iHeight As Integer
Public iWidth As Integer
Public FPS As Integer
Public gpos As Integer
'Leave the rest of them though...
Private Const CCDEVICENAME = 32
Private Const CCFORMNAME = 32
Private Const DISP_CHANGE_SUCCESSFUL = 0
Private Const DISP_CHANGE_RESTART = 1
Private Const DISP_CHANGE_FAILED = -1
Private Const DISP_CHANGE_BADMODE = -2
Private Const DISP_CHANGE_NOTUPDATED = -3
Private Const DISP_CHANGE_BADFLAGS = -4
Private Const DISP_CHANGE_BADPARAM = -5
Private Const CDS_UPDATEREGISTRY = &H1
Private Const CDS_TEST = &H2
Private Const DM_BITSPERPEL = &H40000
Private Const DM_PELSWIDTH = &H80000
Private Const DM_PELSHEIGHT = &H100000
Public Const Cmd1Color = &H808080
Private Type DEVMODE
dmDeviceName As String * CCDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
Private Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lpDevMode As Any) As Boolean
Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Declare Function ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwflags As Long) As Long
Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Declare Function GdiFlush Lib "gdi32" () As Long
Public Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
'###### YIGE Functions #######
'Change Screen settings allows you to specifie the display mode,
'the recommended display mode for this engine is 640 X 480 With 16 bit color
'That display mode can be accessed like this:
'ChangeScreenSettings 640, 480, 16
'(or 24 bit color - it makes it run alot faster at 24)
'To restore their screen mode when the game is done, do as follows
'Call RestoreScrnMode
Public Function ChangeScreenSettings(lWidth As Integer, lHeight As Integer, lColors As Integer)
Dim tDevMode As DEVMODE, lTemp As Long, lIndex As Long
lIndex = 0
Do
lTemp = EnumDisplaySettings(0&, lIndex, tDevMode)
If lTemp = 0 Then Exit Do
lIndex = lIndex + 1
With tDevMode
If .dmPelsWidth = lWidth And .dmPelsHeight = lHeight And .dmBitsPerPel = lColors Then
' MsgBox "The display settings change was successful", vbInformation
Case DISP_CHANGE_RESTART
MsgBox "The computer must be restarted in order for the graphics mode to work", vbQuestion
Case DISP_CHANGE_FAILED
MsgBox "The display driver failed the specified graphics mode", vbCritical
Case DISP_CHANGE_BADMODE
MsgBox "The graphics mode is not supported", vbCritical
Case DISP_CHANGE_NOTUPDATED
MsgBox "Unable to write settings to the registry", vbCritical
Case DISP_CHANGE_BADFLAGS
MsgBox "An invalid set of flags was passed in", vbCritical
End Select
End Function
'Call this procedure directly before calling the ChangeScreenSettings
'function so we cn restore their settings later,
'(see RestoreRes function)
Public Sub RememberScreenRes()
iWidth = Screen.Width \ Screen.TwipsPerPixelX
iHeight = Screen.Height \ Screen.TwipsPerPixelY
End Sub
Public Sub PauseSystem(StopDurationInMilliseconds As Long) 'Stop the engine
Sleep (StopDurationInMilliseconds) 'bring CPU into a hault
End Sub
Public Sub RestoreRes() 'restore the screen settings...
ChangeScreenSettings iWidth, iHeight, 24
GdiFlush
ShowCursor 1
End Sub
'This is the main part of this engine that does the blitting
'use the DrawSprite sub to draw your sprites to the game screen
'(See our example)
'Call the CLS and Refresh functions of the game
'surface (game surface is usually a picturebox
'or form, its the object that all the sprites are displayed in...
Public Sub DrawSprite(GameSurf As Object, SpriteSource As Object, SpriteX As Integer, SpriteY As Integer, SpriteWidth As Integer, SpriteHeight As Integer, DrawMode As Long, SpriteID As Integer)