Hypothetically, if I wanted to get a 1000x1000 tilegrid (like for snake or a maze) how would I do it? You can’t really spawn 1 million sprites. In defold you can only draw_line and not draw shapes like in other programs.
You could somehow make a special font and use that as a tile, but that would only work for 2 colors. You could also go the jpeg approach and compress the tiles into images and depending on the placement change the picture. I don’t see any of those ideas working very effectively, thats why I ask the forum, is their a better way?
Could you do something in the renderscript to display that many tiles in several different colors?
You can also create an “empty” tilegrid. It’s currently not possible to create a tilegrid from placing the corners (r.g. (0,0) and (1000,1000). After that, you can use tilemap.set_tile to set the desired items in a layer.
E.g. you can use the same tilegrid as a background (e.g. generate the maze at init()) in one layer, and put the players/enemies/items in another layer
Ended up using this method. Worked great!
The only question I have is, how optimized is defold running code? When running my not so efficient maze generator my computer didn’t like checking ~2000 if statement every second. I thought morden day computers could handle that, so is it defold or my computer/code?
The other thing that got my interest is the draw_line message, my computer really didn’t like that. My framerate went from 55 to ~22, half of the original by just drawing some squares (it was ~4000 draw calls every frame so it didn’t surprise me as much) why is it such an expensive operation even if it just draws some pixels on the screen?
(just a question about the forum itself, what’s up with the hexagon and circle profile icons? They seem to change randomly, right now im using the web version on my ipad and it shows an hexagon, on my phone (in the app thing) it’s a circle and on the computer it seems to be randomly selected each day, is something wrong?)
Well, it depends on the code, and what you do in the if-statement. What does your code look like now?
A draw call may cause a state change on the GPU, and that can be expensive. The overhead of each call is large, and passing only one triangle (a line) is then very expensive. More so on older hardware, but even new games does limit their number of draw calls.
Drawing lines should be batched, so there shouldn’t be 4000 draw calls because of that. Do you have any other things that are rendered in large amounts?
I used a Depth-first search algorithm to generate my maze. Insted of checking if the tile I was on already had been looked at, it just when back in the list of tiles and comparing every single tile. This resulted in instances that 95% of the maze already had been searched but it had to go back and do 10 000 comparison when it just had to do 10. Very inefficient. The second thing was that I used draw_line and not a tilegrid.
I would also recommend using a regular table for creating the maze upfront, and once it’s done copy it to the tilemap. There is some overhead to getting/setting tiles, so it will be faster to do it this way.