Results 1 to 6 of 6

Thread: Map Editors

  1. #1

    Thread Starter
    Lively Member Spie's Avatar
    Join Date
    Jul 2000
    Location
    On a very small coconut somewhere near Mars
    Posts
    126
    I am trying to make a map editor for my tile-based RPG. I need to know how to do things like save the map (the right information) and load it.. help is greatly appreciated.
    -Spie

  2. #2
    Guest
    One of the easiest and most efficient ways is to use a byte array.

  3. #3
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    Hey, Meg can you show some sample code on how to use the byte array?

    Thanks

  4. #4
    Guest
    Sure,
    Code:
    '********************************
    'Creating and saving the Map file
    '********************************
    
    Dim Map(5, 5) As Byte
    
    'Create numbers (items, enemies etc.) in the byte array
    For X = 0 To 5
        For Y = 0 To 5
            Map(X, Y) = X * Y 'Assign a number
        Next Y
    Next X
    
    Open "MyMap.map" For Binary Access Write As #1
    Put #1, , Map
    Close #1
    Loading the Map
    Code:
    '********************
    'Loading the Map File
    '********************
    
    Dim Map(5, 5) As Byte
    
    Open "MyMap.map" For Binary Access Read As #1
    Get #1, , Map
    Close #1
    
    'Loop through and display the number at each coordinate
    For X = 0 To 5
        For Y = 0 To 5
            Debug.Print Map(X, Y)
        Next Y
    Next X
    Make sure in your game, though, that the Map is declared at global or module level because you would be using it throughout your project.

    You can assign values to your characters like this.
    Code:
    MyChar = 10  'Where ever 10 is on the Map is where "you" are
    MyEnemy = 20 '20 is your enemy 
    'etc.
    Then you can move the characters up or down by looping through the Map file and when 10 (your character) is found, then change your current position to a 0, and assign the ajacent position to 10 (your character).

  5. #5

    Thread Starter
    Lively Member Spie's Avatar
    Join Date
    Jul 2000
    Location
    On a very small coconut somewhere near Mars
    Posts
    126
    Wow! That was (I think) excatly what I needed.. Do the other things, like the MyChar and MyEnemy save automaticly, or do I have to tell it to save?
    Thanks,
    Spie

  6. #6
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    Thanks Meg )

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