-
[ 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
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|