Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why the need to reverse the map? #1

Open
sproket opened this issue Oct 24, 2022 · 4 comments
Open

Why the need to reverse the map? #1

sproket opened this issue Oct 24, 2022 · 4 comments

Comments

@sproket
Copy link

sproket commented Oct 24, 2022

Looking at code. Very cool! But I don't understand why you read the file and then reverse the whole map to render it. It looks like the map would be "north" facing (with north being up) but you seem to need to make it "south" facing when you generate the blocks.

Why is that? For my tests it means reversing multiple model objects and walls etc...

TIA

@icza
Copy link
Owner

icza commented Oct 24, 2022

I wrote the code a very long time ago, can you point out exactly where this is?

@sproket
Copy link
Author

sproket commented Oct 24, 2022

Yeah it's the Level.generateMap method you added the comment // Reverse the list so the row index will grow as the z index

I'm not sure what that means. Is it because this is the way JavaFX expects the objects to be added? I tried reversing the for loops and I didn't see any difference. Or could it be because of the Perspective Camera orientation?

Thanks for replying BTW. This this is very nice sample on how to make a 3D maze. In my case, I don't only use Blocks. I also use other object types which need the correct orientation.

@icza
Copy link
Owner

icza commented Oct 24, 2022

I think the answer simply is because the map is saved as a 2D matrix in the map data files, and naturally the row index starts at 0, at the top left corner, and increases downward (like pixel coordinates on the screen). But if we reverse the lines and face "upward" on the plane of the map, then increasing row index will correspond to increasing z coordinate.

I don't think this has much significance, this might have just been more natural to me, and might result in somewhat easier calculations. Does not have a big impact.

@sproket
Copy link
Author

sproket commented Oct 24, 2022

I see. Thanks. OK I'll make a point of referencing your gihub page when I make my game public. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants