Game Programming Tutorial -
Beginners Guide -
'This Sub Procedure Initializes The Direct and Direct3D objectHTML Code:'-------------------------- 'Game Programming Tutorial - Part 1 'Drawing a colored Screen 'For the time being we will use the Main Form, will change later 'MainForm.frm 'Since we are using MainForm public can be dim on the const and objects, but set them to public becase they will be moved to a MODULE in the upcoming Tutorials '-------------------------- 'Make sure all variables are declared Option Explicit 'CONSTANTS NEEDED 'CUSTOMIZE PROGRAM HERE 'desired width Public Const SCREENWIDTH as Long = 800 'desired height public Const SCREENHEIGHT AS LONG = 600 'change to true when all 'code works public Const FULLSCREEN AS BOOLEAN = FALSE 'COLORS Public Const C_BLACK as long = &h0 'Direct Objects that will be needed 'this will be explained in Sub InitDirect public dx as directx8 public d3d as direct3d8 public d3dpp as D3DPRESENT_PARAMETERS Public dispmode as D3DDISPLAY_MODE Public d3ddev as direct3dDevice8
'along with setting the display parameters and creating the primary display device,
On Form Load EventHTML Code:Public Sub InitDirect( _ ByVal hwnd as long, _ ByVal lWidth as long, _ ByVal lHeight as long, _ ByVal bFullScreen as Boolean) 'catch errors on local error goto error_handler 'Create the DirectX Object Set dx = New DirectX8 'Create the Direct3D Object Set d3d = dx.Direct3DCreate() if d3d is nothing then MsgBox "Error Initializing Direct3D!" Shutdown End If 'use the current color depth d3d.GetAdapterDisplayMode D3DADAPTER_DEFAULT, dispmode 'Set up the Present Parameters For Windowed Mode With d3dpp .hDeviceWindow = hwnd .backbuffercount = 1 .backbufferwidth = lWidth .backbufferheight = lHeight .SwapEffect = D3DSWAPEFFECT_COPY_VSYNC 'If change FULLSCREEN to TRue then Windowed = 0 (Fullscreen Mode) 'else then Windowed = 1 (Normal Mode) if bFullscreen then .Windowed = 0 else .Windowed = 1 End If End With 'Create the Primary Display Device Set d3ddev = d3d.CreateDevice( _ D3DADAPTER_DEFAULT, _ D3DDEVTYPE_HAL, _ hwnd, _ D3D_CREATE_SORTWARE_VERTEXPROCESSING, _ d3dpp) if d3ddev is nothing then msgbox "Error Creating Primary Display Device!" Shutdown End if exit sub error_handler: MsgBox "Error Creating Direct Objects!" Shutdown End Sub
I hope some people can use thisHTML Code:Private Sub Form_Load() me.caption = "Color Screen" me.scalemode = 3 me.width = screen.twipsPerPixelX * (SCREENWIDTH + 12) me.height = screen.twipsPerPixelY * (SCREENHEIGHT + 30) me.show 'Initialize Direct3D InitDirect Me.hwnd, SCREENWIDTH, SCREENHEIGHT, FULLSCREEN 'Clear the Screen d3ddev.Clear 0, ByVal 0, D3DCLEAR_TARGET, C_BLACK, 1, 0 'Refresh the screen with the color d3ddev.Present ByVal 0, ByVal 0, 0, ByVal 0 End Sub
Also I am not good with graphics so if someone can send me a small 2D tile game world map, I will show users how a character moves around
Size 1600 x 1200, Tile Size Does not matter, but I normally use for my world 64 x 64, 32, x 32 is fine. I have a site that I can get the sprites from just not the tiles for the map.


Reply With Quote
