icza / amaze

Amaze is a 3D labyrinth demo written using JavaFX
Apache License 2.0
5 stars 1 forks source link

Why the need to reverse the map? #1

Open sproket opened 1 year ago

sproket commented 1 year ago

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 commented 1 year ago

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

sproket commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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