|
-
Dec 3rd, 2004, 10:25 PM
#1
Thread Starter
Junior Member
Directx 7 Tiles [resolved]
ok this is probly a simple problem. but i can't change the size of the map that i want to draw with dx7 . i am using the tutorial off directx4vb.com . it will change the ones i want so they flash.The ones Around it don't flash but they shouldn't even be there. i'll show u a pic . *'s flash 0 don't. say i wan't to show a 4 sqaure wide map.
****00000
****00000
****00000
****00000
000000000
i can get that to happen but the 0 shouldn't b show but i don't kno how to do that with dx . here is my code so u can see what i am using
well i'll just post the part for drawing and creating the map
Dim Map(39, 29) As Byte
Sub CreateRndMap()
'This part will need to be changed if you
'alter the dimensions of the map
Dim X As Integer, Y As Integer
For X = 0 To 39
For Y = 0 To 29
Map(X, Y) = Int(Rnd * 9)
Next Y
Next X
End Sub
Sub RenderMap(NumTilesX As Integer, NumTilesY As Integer, TileWidth As Integer, TileHeight As Integer, TileSourcesurf As DirectDrawSurface7, TileDestSurf As DirectDrawSurface7)
Dim X As Integer, Y As Integer, r As RECT, retVal As Long
For X = 0 To NumTilesX - 1
For Y = 0 To NumTilesY - 1
'For the full speed advantage - take out this line.
Map(X, Y) = Int(Rnd * 9)
'Create our Rectangle.
r.Left = 0
r.Top = Map(X, Y) * 16
r.Right = r.Left + TileWidth
r.Bottom = r.Top + TileHeight
'This is where we copy the tile from the source to the destination
retVal = TileDestSurf.BltFast(Int(X * TileWidth), Int(Y * TileHeight), TileSourcesurf, r, DDBLTFAST_WAIT)
Next Y
Next X
End Sub
Sub blt()
On Local Error GoTo errOut
If binit = False Then Exit Sub
Dim ddrval As Long
Dim rBack As RECT
' this will keep us from trying to blt in case we lose the surfaces (alt-tab)
bRestore = False
Do Until ExModeActive
DoEvents
bRestore = True
Loop
' if we lost and got back the surfaces, then restore them
DoEvents
If bRestore Then
bRestore = False
dd.RestoreAllSurfaces
InitSurfaces
End If
rBack.Bottom = ddsd3.lHeight
rBack.Right = ddsd3.lWidth
ddrval = backbuffer.BltFast(0, 0, Mainsurf, rBack, DDBLTFAST_WAIT)
Call backbuffer.DrawText(1, 1, LengthText, False)
Call backbuffer.DrawText(1, 16, LengthTextFPS, False)
Call backbuffer.DrawText(1, 31, FrameText, False)
If RunOptimised = True Then
Call backbuffer.DrawText(1, 46, "Running Optimised [F1 to toggle]", False)
Else
Call backbuffer.DrawText(1, 46, "NOT Running Optimised [F1 to toggle]", False)
End If
If dx.TickCount - LastTimeChecked >= 1000 Then
LastTimeChecked = dx.TickCount
FrameText = "Current Frame rate: " & CStr(framesDone) & " fps"
framesDone = 0
End If
'flip the back buffer to the screen
primary.Flip Nothing, DDFLIP_WAIT
framesDone = framesDone + 1
errOut:
End Sub
Sub EndIt()
'This procedure is called at the end of the loop, or whenever there is an error.
'Although you can get away without these few lines it is a good idea to keep them
'as you can get unpredictable results if you leave windows to "clear-up" after you.
'This line restores you back to your default (windows) resolution.
Call dd.RestoreDisplayMode
'This tells windows/directX that we no longer want exclusive access
'to the graphics features/directdraw
Call dd.SetCooperativeLevel(Me.hWnd, DDSCL_NORMAL)
'Stop the program:
End
End Sub
goto http://216.5.163.53/DirectX4Vb/index.asp
and under dx7 it has a tutorial if you want to see the whole code but u'll have to download it. Well hopefully sum1 can help me
thnx
Last edited by Electroman; Dec 4th, 2004 at 11:24 AM.
Reason: Changed to Resolved Icon
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|