Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MS4 Seamless Maps
#1
Ok, so i started to program in seamless maps for MS4. Maybe some others can help finish it up and make it better.

Code:
' Seamless maps
Public Const MAXX As Byte = (MAX_MAPX * 3) + 3
Public Const MAXY As Byte = (MAX_MAPY * 3) + 3

Code:
' Used for seamless maps
Public Enum Compass
    NorthWest = 0
    North = 1
    NorthEast = 2
    West = 3
    Center = 4
    East = 5
    SouthWest = 6
    South = 7
    SouthEast = 8
End Enum

Code:
Public SMaps(Compass.NorthWest To Compass.SouthEast) As MapRec
Public Tiles(0 To MAXX, 0 To MAXY) As TileRec

Code:
Sub iLoadMap(MapNum As Long, ByVal Size As Byte)
    Dim FileName As String
    Dim f As Long
    
    FileName = App.Path & MAP_PATH & "map" & MapNum & MAP_EXT
    
    If FileExist(FileName, True) Then
        f = FreeFile
        Open FileName For Binary As #f
              Get #f, , SMaps(Size)
        Close #f
    End If
End Sub

Sub LoadSurroundingMaps()
Dim MapNum As Long
Dim BlankMap As MapRec
Dim i As Byte

    ' [0] [1] [2]
    ' [3] [4] [5]
    ' [6] [7] [8]
    
    ' NorthWest = 0
    ' North     = 1
    ' NorthEast = 2
    ' West      = 3
    ' Center    = 4
    ' East      = 5
    ' SouthWest = 6
    ' South     = 7
    ' SouthEast = 8
    
    SMaps(Compass.Center) = Map
    
    ' North
    MapNum = Map.Up
    If MapNum > 0 Then
        Call iLoadMap(MapNum, Compass.North)
    Else
        SMaps(Compass.North) = BlankMap
    End If
    
    ' East
    MapNum = Map.Right
    If MapNum > 0 Then
        Call iLoadMap(MapNum, Compass.East)
    Else
        SMaps(Compass.East) = BlankMap
    End If
    
    ' South
    MapNum = Map.Down
    If MapNum > 0 Then
        Call iLoadMap(MapNum, Compass.South)
    Else
        SMaps(Compass.South) = BlankMap
    End If
    
    ' West
    MapNum = Map.Left
    If MapNum > 0 Then
        Call iLoadMap(MapNum, Compass.West)
    Else
        SMaps(Compass.West) = BlankMap
    End If
    
    ' NorthEast
    MapNum = SMaps(Compass.North).Right
    If MapNum = 0 And SMaps(Compass.East).Up > 0 Then MapNum = SMaps(Compass.East).Up
    If MapNum > 0 Then
        Call iLoadMap(MapNum, Compass.NorthEast)
    Else
        SMaps(Compass.NorthEast) = BlankMap
    End If
    
    ' SouthEast
    MapNum = SMaps(Compass.East).Down
    If MapNum = 0 And SMaps(Compass.South).Right > 0 Then MapNum = SMaps(Compass.South).Right
    If MapNum > 0 Then
        Call iLoadMap(MapNum, Compass.SouthEast)
    Else
        SMaps(Compass.SouthEast) = BlankMap
    End If
    
    ' SouthWest
    MapNum = SMaps(Compass.South).Left
    If MapNum = 0 And SMaps(Compass.West).Down > 0 Then MapNum = SMaps(Compass.West).Down
    If MapNum > 0 Then
        Call iLoadMap(MapNum, Compass.SouthWest)
    Else
        SMaps(Compass.SouthWest) = BlankMap
    End If
    
    ' NorthWest
    MapNum = SMaps(Compass.West).Up
    If MapNum = 0 And SMaps(Compass.North).Left > 0 Then MapNum = SMaps(Compass.North).Left
    If MapNum > 0 Then
        Call iLoadMap(MapNum, Compass.NorthWest)
    Else
        SMaps(Compass.NorthWest) = BlankMap
    End If
    
    CreateTileView
End Sub

Code:
Sub CreateTileView()
Dim X As Long, Y As Long, i As Long
Dim MapX As Long, MapY As Long
Dim EmptyTiles As TileRec
    
    For i = Compass.NorthWest To Compass.SouthEast
        For X = 0 To MAX_MAPX
            For Y = 0 To MAX_MAPY
                MapX = (MAX_MAPX * (i Mod 3)) + X
                MapY = (MAX_MAPY * (i \ 3)) + Y

                Tiles(MapX, MapY) = SMaps(i).Tile(X, Y)
            Next
        Next
    Next
End Sub

Code:
Public DDSD_LowerBuffer As DDSURFACEDESC2

Code:
With DDSD_LowerBuffer
        .lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
        .ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
        .lWidth = (MAXX) * PIC_X
        .lHeight = (MAXY) * PIC_Y
    End With

Code:
Set DD_LowerBuffer = DD.CreateSurface(DDSD_LowerBuffer)

Changes to BltMap
Code:
With rec
        .Top = 0
        .Bottom = DDSD_LowerBuffer.lHeight
        .Left = 0
        .Right = DDSD_LowerBuffer.lWidth
    End With
        
    ' clear buffers
    Call DD_LowerBuffer.BltColorFill(rec, MASK_COLOR)
    Call DD_UpperBuffer.BltColorFill(rec, MASK_COLOR)

    For X = 0 To MAXX
        For Y = 0 To MAXY
            With Tiles(X, Y)

GameLoop
Code:
MapXOffset = Int(MAX_MAPX / 2) + GetPlayerX(MyIndex)
                MapYOffset = Int(MAX_MAPY / 2) + GetPlayerY(MyIndex)
                
                With Camera
                    .Top = MapYOffset * PIC_Y
                    .Bottom = .Top + (MAX_MAPY + 1) * PIC_Y
                    .Left = MapXOffset * PIC_X
                    .Right = .Left + (MAX_MAPX + 1) * PIC_X
                End With
                
                'Now that all the drawing routines are done, draw everything to the backbuffer.
                Call DD_BackBuffer.BltFast(0, 0, DD_LowerBuffer, Camera, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)

I think that was everything i had started. Some parts come from the old seamless maps tutorial, some of it my own.
Reply
#2
This is for MS4, I have the code for the other seamless maps.
Reply
#3
Seamless Maps is when you can adjust the size of the maps right?
Reply
#4
So then what's the different between seamless and scrolling if it's like that?
Reply
#5
Does this work now? Or is it not done?
Reply
#6
Not done, it was just a basic idea / start.
Reply
#7
Alrighty, I'll try to finish it later. If I do, I'll put up how I did it.
Reply
#8
DarkC Wrote:Alrighty, I'll try to finish it later. If I do, I'll put up how I did it.

Tried? ;D
Reply
#9
Finish this Dugor baby.
Reply
#10
one Wrote:also displaying npcs and players on surrounding maps would be cool... but it would mean that playermovements for 9 maps have to be send, thus up to 9x the traffic...
At max if you optimize it right you will only send 4 map's data.
Reply
#11
Someone finish it ?
Reply
#12
Wow, looking good. Hope it gets finished.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)