Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / 2D ARRAY Compared to DATA statements

Author
Message
Fleep
14
Years of Service
User Offline
Joined: 1st Oct 2010
Location:
Posted: 28th Aug 2011 23:48
Hey guys so here's my problem, ive copied more or less what ive seen from Pizzaman's 2d tile guide(dont remember the link) and im trying to get my map to be drawn according to the 2d Array.
This is what it looks like at the moment.



And this will give me this output


as you can probably tell its reading the array 90 degrees to the right

When this is done in DB Pro with data statements the display is different.
With this code



This is the result



Which is what im TRYING to achieve, i dont want to have to write my map at a 90 degree angle as it will be a nightmare.

All im trying to do is to get the array to output those values the same way the data statement does

this is how im currently displaying the array




The code is pretty much the same for both versions.
Please help me out
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 29th Aug 2011 16:56
Quote: "map[x + tilenumx][y + tilenumy]"

the first part of an array is the "y" value. You have transposed the x and y.

The fastest code is the code never written.
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 30th Aug 2011 08:12 Edited at: 30th Aug 2011 08:18
EDIT: disregard this post.
Fleep
14
Years of Service
User Offline
Joined: 1st Oct 2010
Location:
Posted: 30th Aug 2011 13:01
Hawkblood by changing that like you said it does work, but screws up all of the collision big time, i found another way by making a temporary array and copying the contents of that to my map, and its working thank you for your help.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 30th Aug 2011 14:34
doing what Hawkblood said is more efficient, with large arrays it could get slow, and that is not even necessary, better change the collision code, perhaps you are flipping the x and y there too, so it could be simple to fix

Fleep
14
Years of Service
User Offline
Joined: 1st Oct 2010
Location:
Posted: 30th Aug 2011 15:12
Hm i see what your saying Hassan, i spent a fair part of the night trying to fix that, for now i think i'l just leave it and when i'm done i'l go back to try and write more efficient code.

Thanks
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 30th Aug 2011 15:27
Believe me, you don't want to rewrite code when you are finished.... The further you get in your program, the more integrated a problem becomes and the more work you will have to do to change it.

The fastest code is the code never written.

Login to post a reply

Server time is: 2024-11-19 08:43:52
Your offset time is: 2024-11-19 08:43:52