Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[CS:DE, EA] Scrolling MiniMap (on large maps)


zomb88
 Share

Recommended Posts

Hey guys,
Ive been doing alot of work on my game and whilst i have been holding back releasing any of it as tutorials i thought i would release this as it is a sort of essential addon to the minimap system posted by Ertzel.

First you will need the tutorial posted by Ertzel found [HERE](http://www.eclipseorigins.com/community/index.php?/topic/129760-ea-minimap/?hl=minimap). This will give you the back bones.

Once you have implemented his tutorial you just need to replace your DrawMiniMap sub  with this one :)
```
Public Sub DrawMiniMap()
Dim i As Long, z As Long
Dim x As Integer, y As Integer
Dim direction As Byte
Dim CameraX As Long, CameraY As Long, playerNum As Long
Dim MapX As Long, MapY As Long, MinMapX As Long, MinMapY As Long
Dim CameraXSize As Long, CameraYSize As Long, CameraHalfX As Long, CameraHalfY As Long

CameraXSize = ScreenWidth - 50 - (MAX_MAPX * 4)
CameraYSize = ScreenHeight - 50 - (MAX_MAPY * 4)

' If debug mode, handle error then exit out
If Options.Debug = 1 Then On Error GoTo errorhandler
CameraHalfX = (MAX_MAPX / 2)
CameraHalfY = (MAX_MAPY / 2)

MinMapX = Player(MyIndex).x - CameraHalfX
MinMapY = Player(MyIndex).y - CameraHalfY
MapX = Player(MyIndex).x + CameraHalfX
MapY = Player(MyIndex).y + CameraHalfY

If Player(MyIndex).x <= CameraHalfX Then MinMapX = 0
If Player(MyIndex).y <= CameraHalfY Then MinMapY = 0
If MinMapX <= CameraHalfX Then MapX = MAX_MAPX
If MinMapY <= CameraHalfY Then MapY = MAX_MAPY
If MapX > Map.MaxX Then MapX = Map.MaxX
If MapY > Map.MaxY Then MapY = Map.MaxY

    ' Draw Outline
    For x = 0 To MAX_MAPX
        For y = 0 To MAX_MAPY
            CameraX = CameraXSize + (x * 4)
            CameraY = CameraYSize + (y * 4)
            RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(255, 255, 255, 150)
        Next y
    Next x

    ' Draw Player dot
    For i = 1 To Player_HighIndex
        If IsPlaying(i) Then
            CameraX = CameraXSize + (((MiniMapPlayer(i).x / 4) - MinMapX) * 4)
            CameraY = CameraYSize + (((MiniMapPlayer(i).y / 4) - MinMapY) * 4)
            If (MiniMapPlayer(i).x / 4) < MapX Or (MiniMapPlayer(i).x / 4) > MinMapX Then
                If (MiniMapPlayer(i).y / 4) < MapY Or (MiniMapPlayer(i).y / 4) > MinMapY Then
                    If GetPlayerMap(i) = GetPlayerMap(MyIndex) And (Not i = MyIndex) Then
                        Select Case Player(i).PK
                            Case 0
                                RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(0, 255, 0, 200)
                            Case 1
                                RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(100, 0, 0, 200)
                        End Select
                    Else
                        If (Map.MaxX - CameraHalfX) < (MiniMapPlayer(i).x / 4) Then CameraX = CameraXSize + ((MAX_MAPX - (Map.MaxX - (MiniMapPlayer(i).x / 4))) * 4)
                        If (Map.MaxY - CameraHalfY) < (MiniMapPlayer(i).y / 4) Then CameraY = CameraYSize + ((MAX_MAPY - (Map.MaxY - (MiniMapPlayer(i).y / 4))) * 4)
                        RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(0, 255, 0, 200)
                    End If
                End If
            End If
        End If
    Next i

    ' Draw Tile Attribute
    For x = 0 To Map.MaxX
        For y = 0 To Map.MaxY
            If Map.Tile(x, y).Type > 0 Then
                    CameraX = CameraXSize + ((x - MinMapX) * 4)
                    CameraY = CameraYSize + ((y - MinMapY) * 4)
                    If Player(MyIndex).x > (Map.MaxX - CameraHalfX) Then CameraX = CameraXSize + ((x - (Map.MaxX - MAX_MAPX)) * 4)
                    If Player(MyIndex).y > (Map.MaxY - CameraHalfY) Then CameraY = CameraYSize + ((y - (Map.MaxY - MAX_MAPY)) * 4)
                If CameraX >= CameraXSize And CameraX <= CameraXSize + (MAX_MAPX * 4) And CameraY >= CameraYSize And CameraY <= CameraYSize + (MAX_MAPY * 4) Then
                    Select Case Map.Tile(x, y).Type
                        Case TILE_TYPE_BLOCKED
                            RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(255, 0, 0, 200)
                        Case TILE_TYPE_WARP
                            RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(75, 0, 155, 200)
                        Case TILE_TYPE_ITEM
                            RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(0, 155, 0, 200)
                        Case TILE_TYPE_SHOP
                            RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(255, 125, 0, 200)
                    End Select
                End If
            End If
        Next y
    Next x

        ' Draw NPC dot
    For i = 1 To MAX_MAP_NPCS
        If MapNpc(i).Num > 0 Then
            CameraX = CameraXSize + (((MiniMapNPC(i).x / 4) - MinMapX) * 4)
            CameraY = CameraYSize + (((MiniMapNPC(i).y / 4) - MinMapY) * 4)
            If Player(MyIndex).x > (Map.MaxX - CameraHalfX) Then CameraX = CameraXSize + (((MiniMapNPC(i).x / 4) - (Map.MaxX - MAX_MAPX)) * 4)
            If Player(MyIndex).y > (Map.MaxY - CameraHalfY) Then CameraY = CameraYSize + (((MiniMapNPC(i).y / 4) - (Map.MaxY - MAX_MAPY)) * 4)
            Select Case NPC(i).Behaviour
                Case NPC_BEHAVIOUR_ATTACKONSIGHT
                    RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(0, 0, 0, 200)
                Case NPC_BEHAVIOUR_ATTACKWHENATTACKED
                    RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(100, 0, 100, 200)
                Case NPC_BEHAVIOUR_SHOPKEEPER
                    RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(255, 125, 0, 200)
                Case NPC_BEHAVIOUR_FRIENDLY
                    RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(255, 0, 255, 200)
                Case NPC_BEHAVIOUR_GUARD
                    RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(0, 255, 255, 200)
            End Select
        End If
    Next i

    ' directional blocks
    For x = 0 To Map.maxX
        For y = 0 To Map.maxY
            If Map.Tile(x, y).DirBlock >= 1 Then
                CameraX = CameraXSize + ((x - MinMapX) * 4)
                CameraY = CameraYSize + ((y - MinMapY) * 4)
                If Player(MyIndex).x > (Map.maxX - CameraHalfX) Then CameraX = CameraXSize + ((x - (Map.maxX - MAX_MAPX)) * 4)
                If Player(MyIndex).y > (Map.maxY - CameraHalfY) Then CameraY = CameraYSize + ((y - (Map.maxY - MAX_MAPY)) * 4)
                If CameraX >= CameraXSize And CameraX <= CameraXSize + (MAX_MAPX * 4) And CameraY >= CameraYSize And CameraY <= CameraYSize + (MAX_MAPY * 4) Then
                    RenderTexture Tex_White, CameraX, CameraY, 0, 0, 4, 4, 4, 4, D3DColorRGBA(255, 0, 0, 200)
                End If
            End If
        Next
    Next

' Error handler
Exit Sub
errorhandler:
HandleError "DrawMiniMap", "modRendering", Err.Number, Err.Description, Err.Source, Err.HelpContext
Err.Clear
Exit Sub
End Sub 

```It has been written so that it will adjust based on your set resolution (this is for my personal project {multiple resolutions})

**Currently this draws only:**
- Tile Types
- Players
- NPCs
- Directional Blocking

**Update coming for:**
- Events
Link to comment
Share on other sites

  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...