[ H3LP ] Map (scenario) based on an array?
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [ H3LP ] Map (scenario) based on an array?

  1. #1
    I'm not Crazy :D
    Join Date
    Nov 2015
    Location
    Brazil [<o>]
    Posts
    76

    Question [ H3LP ] Map (scenario) based on an array?

    Hello, I developed a simple system of inserting objects in the game based on the values of an array, more necessarily to make maps.

    The code reads a text file and pulls all the values into an array. From that array, I insert objects in the game.

    The code is working, but the objects are not aligning with the "grid" (white lines). I think the problem should be in my math haha, so, can someone help me?

    Note: in the following file have a image showing the problem and the source code.

    Files:
    https://mega.nz/#!aY1HXYCa!ZuKqyryUU...dceG_aKP_BKPVw

  2. #2
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,748
    The problem you're having is you're not compensating for the extra pixel in the border. Another thing, you should consider using a 2d array instead of what you have set up.
    Code:
    1,0,1,0,1,0,1,0,
    0,0,0,0,0,0,0,0,
    1,0,1,0,1,0,1,0
    Instead something like this:
    Code:
    1,0,1,0,1,0,1,0
    0,0,0,0,0,0,0,0
    1,0,1,0,1,0,1,0
    Then you first split it into an array using the return line, then loop through that array then split it into a new array for each row. Then you can use x/y coordinates with the array. map[y][x] I can explain further if you need me to.
    .

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

HTML5 Development Center

Poll by Flashkit.com