Results 1 to 6 of 6

Thread: Directx 7 Tiles [resolved]

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2004
    Posts
    31

    Resolved 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

  2. #2
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Directx 7 Tiles

    Try this:

    http://216.5.163.53/DirectX4VB/Tutor...7/DD_Tiles.asp

    and I don't know if you missed it, but they had a zip file in there too:

    http://216.5.163.53/DirectX4VB/Downl...d_DD_Tiles.zip

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 2004
    Posts
    31

    Re: Directx 7 Tiles

    thats the tutorial i am using but i need to find a way to only blit a certain area instead of a full screen. and another thing when i compile my program to make it exe it will load to full screen and then exit. i don't kno why it works in vb . ne1 kno why
    thnx

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Nov 2004
    Posts
    31

    Re: Directx 7 Tiles

    i have the compiled verison that came with it and it works fine. but i tried compiling the one i downloaded off directx4vb.com but it does the same thing. it loads and then quits. any1 have an idea why it is not compiling right?

  5. #5
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Directx 7 Tiles

    I have no idea why it won't run. Maybe your Video card is lacking some features needed to run the program and during the enumeration process, it may have detected that and exited out as a result.

    Blitting only a certain area on screen ehy? I kinda wish you had DirectX8 because I solved that one. Maybe you need to change a certain surface's size. Either maybe the Backbuffer or the Primary. Give it a whirl and let me know how it turns out.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Nov 2004
    Posts
    31

    Re: Directx 7 Tiles

    i fixed the probelm by changing the backcolour to black. and it works now and the compiling works. So its all good for now thnx guys
    Last edited by vbuser1338; Dec 4th, 2004 at 11:18 AM. Reason: fixed the probelm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width