Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(+1)

It doesn't really need to swap the whole texture page, it does get all the sprites from the same page. It only swaps for the goddesses which I put on a separate page because the sprites are very large and they wouldn't fit on the main page. 

The reason it was doing a lot of swaps before v9.8 was because I was using the built in draw_rectangle function which swaps textures to a built in page that contains only a white pixel which it uses to draw the rectangles (I wasn't aware of this). Rectangles were used for progress bars on structures, so it had to swap a few times for every structure that had a progress bar. The way I fixed it was using a white pixel I had on the main page, and just making my own rectangle function.

(+1)

Oh, ok. I see that the progress bars are just one colored growing rectangles. Why don't you detach it from the building, render it above it and just draw the vertices of the rectangle growing and color it with a shader something like that? That doesn't require any textures. If your engine supports shaders, you can even calculate the position of the colors of the conveyor belts with a bit of math. This would be much more faster then swapping the textures. I see that some sprites are just simple rectangles or lines. Calculating and rendering them yourself is much much faster than using a texture. You should consider that in the next update.

(+1)

The progress bar is already not a part of the structure sprite, and the game does draw the rectangle above the structure. I don't know if calculating and rendering vertices is faster in this engine, maybe it is, but it's fine now. The rectangle function that I made uses a white pixel on the texture page that is already loaded, and stretches and recolours it to make a rectangle for things like the progress bar, so there are no swaps (basically works the same as the built in rectangle function, but without swapping pages). Drawing more sprites doesn't impact performance that much, so it's fine.

If I should optimize, it would be other parts of the code at this point. The crafters for instance start at the top of an array containing the recipes in the form of arrays of items, and check every one of those arrays against their inventory until they find an array whose items the inventory contains (and then they start the crafting countdown). This is really inefficient, and is probably having a much larger performance impact than the same structure drawing an additional sprite as a progress bar.

Conveyors do already use a shader to swap colours.

I hope I'm understanding your points properly, and not speaking past you. If you want you can add me on discord, it could be easier to talk there.

(1 edit) (+1)

Oh, that would be nice if you could add me to discord. I will send you a request when I can, I probably don't understand the language of your engine, but having someone to talk about game dev and engine stuff would be really nice for once and maybe I can help you with some stuff. 


The thing I was getting at is that texture swaps are apparently really expensive. I was just naming examples to reduce them. And conveyor belts with 2 sprites are much more expensive as you build a lot more of them and are always active than just a building with 6 sprites that are only active when you place items in them.

I've just sended you the friend request. It's under a different name because I would've never expected to get someone to talk with over this account.