Using array as 3D map?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By sand

So in python numpy arrays of objects are extremely convenient to use as maps for turn based game because they can be sliced instantly (e.g map_array[100:200, 10, 350:450]) to get the area you want to simulate or render, and you just call whatever object is in players position for implementing interactions. So you can build, attack, mine, anything by just calling that method on the object.

I was wondering if anything like that is possible on GDScript? Main issue as far as I understand is that there is no numpy-like array in godot. Can I make something like numpy array where slicing will be fast enough to scroll through a map? If a big array is made up of complex objects with subobjects, will that be fine? Or would it be easier to use nodes to implement the same functionality? With python it was extremely easy so far, but rendering array as actual tile images, animating all that, and UI are really annoying to make

I’m not familiar with the syntax but you’re still essentially slicing? gdscript has a Array.slice: Array — Godot Engine (stable) documentation in English

While it lacks the syntactic sugar it is certainly possible to wrap it up in an extension.

spaceyjase | 2023-04-11 11:22

I am slicing, but with numpy I can slice along all three axes to get a 3D map. With godot, will I have to use two additional loops to slice in second and third dimensions? That might become too slow

sand | 2023-04-12 05:49