Results 1 to 9 of 9

Thread: 2D Tile RPG - Help with Arrays for Maps/Levels

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2004
    Posts
    16

    2D Tile RPG - Help with Arrays for Maps/Levels

    Ok, 2D tile based rpg.

    I am going to be using the following:
    -32x32 pixel tiles
    -The entire map will be 15 tiles wide, 15 tiles high (480x480 pixel total).
    -225 Tiles in one map

    Right now I am setting up an Array.

    I need this array because: Say, if you are creating the map in a map editor and deciding what kind of tiles will be placed in each one of the 225 blocks on the map. When you save the map, it will store that information into a file which stores each map for the game. It will need to store a map#, and the type of tile that needs to load on each one of the 225 squares.

    Not really sure how to setup this array, but I came up with this so far:

    Public Type MapInfo ' define the contents of the map array
    mapNumber As Integer 'just a reference number so the game knows which map this is.
    mapTile1_1 As String 'string to define which type of tile is at this location on the map
    mapTile1_2 As String
    mapTile1_3 As String
    mapTile1_4 As String
    mapTile1_5 As String 'mapTile1_5 will be the tile at Row 1, Column 5
    mapTile1_6 As String
    mapTile1_7 As String
    mapTile1_8 As String
    mapTile1_9 As String
    mapTile1_10 As String
    mapTile1_11 As String
    mapTile1_12 As String
    mapTile1_13 As String
    mapTile1_14 As String
    mapTile1_15 As String
    mapTile2_1 As String
    mapTile2_2 As String
    mapTile2_3 As String
    mapTile2_4 As String
    mapTile2_5 As String
    mapTile2_6 As String
    mapTile2_7 As String
    mapTile2_8 As String
    mapTile2_9 As String
    mapTile2_10 As String
    mapTile2_11 As String
    mapTile2_12 As String
    mapTile2_13 As String
    mapTile2_14 As String
    mapTile2_15 As String
    mapTile3_1 As String
    mapTile3_2 As String
    mapTile3_3 As String
    mapTile3_4 As String
    mapTile3_5 As String
    mapTile3_6 As String
    mapTile3_7 As String
    mapTile3_8 As String
    mapTile3_9 As String
    mapTile3_10 As String
    mapTile3_11 As String
    mapTile3_12 As String
    mapTile3_13 As String
    mapTile3_14 As String
    mapTile3_15 As String
    mapTile4_1 As String
    mapTile4_2 As String
    mapTile4_3 As String
    mapTile4_4 As String
    mapTile4_5 As String
    mapTile4_6 As String
    mapTile4_7 As String
    mapTile4_8 As String
    mapTile4_9 As String
    mapTile4_10 As String
    mapTile4_11 As String
    mapTile4_12 As String
    mapTile4_13 As String
    mapTile4_14 As String
    mapTile4_15 As String
    mapTile5_1 As String
    mapTile5_2 As String
    mapTile5_3 As String
    mapTile5_4 As String
    mapTile5_5 As String
    mapTile5_6 As String
    mapTile5_7 As String
    mapTile5_8 As String
    mapTile5_9 As String
    mapTile5_10 As String
    mapTile5_11 As String
    mapTile5_12 As String
    mapTile5_13 As String
    mapTile5_14 As String
    mapTile5_15 As String
    mapTile6_1 As String
    mapTile6_2 As String
    mapTile6_3 As String
    mapTile6_4 As String
    mapTile6_5 As String
    mapTile6_6 As String
    mapTile6_7 As String
    mapTile6_8 As String
    mapTile6_9 As String
    mapTile6_10 As String
    mapTile6_11 As String
    mapTile6_12 As String
    mapTile6_13 As String
    mapTile6_14 As String
    mapTile6_15 As String
    mapTile7_1 As String
    mapTile7_2 As String
    mapTile7_3 As String
    mapTile7_4 As String
    mapTile7_5 As String
    mapTile7_6 As String
    mapTile7_7 As String
    mapTile7_8 As String
    mapTile7_9 As String
    mapTile7_10 As String
    mapTile7_11 As String
    mapTile7_12 As String
    mapTile7_13 As String
    mapTile7_14 As String
    mapTile7_15 As String
    mapTile8_1 As String
    mapTile8_2 As String
    mapTile8_3 As String
    mapTile8_4 As String
    mapTile8_5 As String
    mapTile8_6 As String
    mapTile8_7 As String
    mapTile8_8 As String
    mapTile8_9 As String
    mapTile8_10 As String
    mapTile8_11 As String
    mapTile8_12 As String
    mapTile8_13 As String
    mapTile8_14 As String
    mapTile8_15 As String
    mapTile9_1 As String
    mapTile9_2 As String
    mapTile9_3 As String
    mapTile9_4 As String
    mapTile9_5 As String
    mapTile9_6 As String
    mapTile9_7 As String
    mapTile9_8 As String
    mapTile9_9 As String
    mapTile9_10 As String
    mapTile9_11 As String
    mapTile9_12 As String
    mapTile9_13 As String
    mapTile9_14 As String
    mapTile9_15 As String
    mapTile10_1 As String
    mapTile10_2 As String
    mapTile10_3 As String
    mapTile10_4 As String
    mapTile10_5 As String
    mapTile10_6 As String
    mapTile10_7 As String
    mapTile10_8 As String
    mapTile10_9 As String
    mapTile10_10 As String
    mapTile10_11 As String
    mapTile10_12 As String
    mapTile10_13 As String
    mapTile10_14 As String
    mapTile10_15 As String
    mapTile11_1 As String
    mapTile11_2 As String
    mapTile11_3 As String
    mapTile11_4 As String
    mapTile11_5 As String
    mapTile11_6 As String
    mapTile11_7 As String
    mapTile11_8 As String
    mapTile11_9 As String
    mapTile11_10 As String
    mapTile11_11 As String
    mapTile11_12 As String
    mapTile11_13 As String
    mapTile11_14 As String
    mapTile11_15 As String
    mapTile12_1 As String
    mapTile12_2 As String
    mapTile12_3 As String
    mapTile12_4 As String
    mapTile12_5 As String
    mapTile12_6 As String
    mapTile12_7 As String
    mapTile12_8 As String
    mapTile12_9 As String
    mapTile12_10 As String
    mapTile12_11 As String
    mapTile12_12 As String
    mapTile12_13 As String
    mapTile12_14 As String
    mapTile12_15 As String
    mapTile13_1 As String
    mapTile13_2 As String
    mapTile13_3 As String
    mapTile13_4 As String
    mapTile13_5 As String
    mapTile13_6 As String
    mapTile13_7 As String
    mapTile13_8 As String
    mapTile13_9 As String
    mapTile13_10 As String
    mapTile13_11 As String
    mapTile13_12 As String
    mapTile13_13 As String
    mapTile13_14 As String
    mapTile13_15 As String
    mapTile14_1 As String
    mapTile14_2 As String
    mapTile14_3 As String
    mapTile14_4 As String
    mapTile14_5 As String
    mapTile14_6 As String
    mapTile14_7 As String
    mapTile14_8 As String
    mapTile14_9 As String
    mapTile14_10 As String
    mapTile14_11 As String
    mapTile14_12 As String
    mapTile14_13 As String
    mapTile14_14 As String
    mapTile14_15 As String
    mapTile15_1 As String
    mapTile15_2 As String
    mapTile15_3 As String
    mapTile15_4 As String
    mapTile15_5 As String
    mapTile15_6 As String
    mapTile15_7 As String
    mapTile15_8 As String
    mapTile15_9 As String
    mapTile15_10 As String
    mapTile15_11 As String
    mapTile15_12 As String
    mapTile15_13 As String
    mapTile15_14 As String
    mapTile15_15 As String
    End Type
    Global MapArray(1 To 15, 1 To 15) As MapInfo 'define a 15x15 map

    'TILE TYPES (will hold a location for the tile image later on, right now I just put 0)
    Public Const TileType1 = 0 'example = tiles/tile1.jpg
    Public Const TileType2 = 0 'example = tiles/tile2.jpg
    Public Const TileType3 = 0 'example = tiles/grass1.jpg
    Public Const TileType4 = 0 'The 0's are just temporary
    Public Const TileType5 = 0
    Public Const TileType6 = 0
    Public Const TileType7 = 0

  2. #2
    Hyperactive Member wiccaan's Avatar
    Join Date
    Apr 2004
    Location
    127.0.0.1
    Posts
    475
    Wouldnt you be able to use something like:

    Code:
    mapTile1_1 To mapTile1_15 As String
    mapTile2_1 To mapTile2_15 As String
    And so on so that its not as lengthy. Just a suggestion.
    If my post was helpful please rate it

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2004
    Posts
    16
    Was hoping I could actually lol.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Oct 2004
    Posts
    16
    It won't work that way but there may be a way to shorten the code. I just don't know of a way. Thats one thing I need help with. :-)

  5. #5
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Why not make a 2 dementional array?

    VB Code:
    1. Dim mapArray(15, 15) As String
    2.  
    3. mapArray(1, 1) = "First"
    4.  
    5. mapArray(15, 15) = "Last"
    6.  
    7. For i = 1 To 15
    8.   For j = 1 To 15
    9.  
    10. Debug.Print mapArray(i, j)
    11.  
    12.   Next j
    13. Next i
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  6. #6

    Thread Starter
    Junior Member
    Join Date
    Oct 2004
    Posts
    16
    Well that was my intention actually but Im a little foggy on how I should do this and how things work. Just haven't gotten this part worked out yet.

  7. #7
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629
    I posted a sample of a type definiion for the map in your other thread, that way you could use an array instead.

    http://www.vbforums.com/showthread.p...hreadid=308604

    And you also have to consider the screen size and also the number of tiles displayed on screen. Memory considerations, you "draw" or "assemble" only the visible portion of the screen plus 1 tile all edges.

    Why plus 1 tile? So you can then scroll the assembled image, the extra tile slowly showing up. Also to speed up image assembly, you only have to redraw the edges of the map (assuming all other detail or non background tiles as static).
    Last edited by leinad31; Oct 13th, 2004 at 09:17 PM.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Oct 2004
    Posts
    16
    Im not going to allow any resizing for sake of keeping it simple for now.

  9. #9
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629
    So the whole map will be visible in the screen?

    If that's the case then it would be best for the tile size to be a factor of the screen size, eg, 800 x 600 -> 16 x 12 to give 50 tiles across and 50 tiles vertically to display the screen.

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