MightyPrinny/godot-gputilemap

Minimal usage example

Closed this issue · 13 comments

Hi! I'm completely stuck with initializing GPUTilemap. Could you provide a small example (or tutorial)? Maybe It's almost initialized and I misconfigure it, but I'm getting the error `Parse Error: Expected float in constructor' (error from the root scene) when I'm trying to run the scene with existing GPUTilemap.
I just added GPUTilemap to the scene and select godot icon as a tilemap, configure tile size to 128x128 (See image below)

image

Thanks!

I'll take a look, what version of godot are you using and what version of the addon?

@MightyPrinny I'm using Godot 3.1 and the latest version of your plugin (master branch)

I've pushed a fix for a parse error that seems to only happen in godot 3.2.2 beta, it was working in 3.2 stable, I'm not sure if it works in 3.1 anymore.

@MightyPrinny Also, are you working with 2D water simulation in Godot? I'm looking for a productive solution to use it in the ProceduralGenerated world like in terraria. I was found some solutions: Cellular Automata and SPH but I cannot scale these solutions to my case. Also, I found good cellular automata simulation, written in C and OpenGL, and now I'm trying to write it in GDNative(Rust) and I'm stuck with rectangle drawing performance (I'm drawing a simple rectangle with color and sizes). So, the long way brought me to your plugin and I wanna test it performance in my case. The current task is simple, randomly draw about 200-300 tiles in a grid with size 100x100 cells and with 60fps. Maybe default tilemap can give me the same performance but also I should make calculations for simulation in 100x100 grid (simple array of arrays) - then default tilemap show 5-10 fps (because it works also on CPU, as my calculations)

@MightyPrinny Sorry, I mixed up, I'm using 3.2.1.

No I haven't done that, the plugin doesn't include methods to change the map, you'd have to edit the image manually, but i can add that, I have a set cell method in C# for the project where I'm using this. For safety I use image locks in the plugin, but for real time edits it might be better to keep the image of the map locked.

Oh never mind it actually has a put_tile method, I just didn't want to use it in C#. Then you should use it with the do_locks parameter set to false and lock the map after it has initialized using map_data.lock() on the tilemap instance.

Btw godot 3.2.2 has 2d batching in the gles 2 renderer so rect drawing should be better there

@MightyPrinny so, could you provide minimal example?:) I need a code for simple set tile by x,y and remove it :)

DemoProject.zip

Ok here's a demo, this will only work in the master branch with the changes I made just now.

GPUTilemapEditDemo.zip
This one is a little better, it also has a demo for the normal version of put_tile and I updated the master branch to remove the alpha parameter since now you use erase_tile to remove tiles.
(The tileset has a tile that's just a line and it shouldn't be there, that's not a seam, however seams will be visible without integer scaling or the viewport stretch mode, I had been using integer scaling all this time so I never noticed tilemaps could look so bad when you stretch the window until now, sorry about that, but I don't know how to fix that)

@MightyPrinny Thank you! I close the issue and will test this demo and tell you about a progress 👍

Can one of the demos get linked to in the README?