(Sorry for bad spelling)
Hello, I am trying to create a map for a game I am working on, but I can't seem to find a way to do it without it lagging the whole game.
So I have some sprites(32x32 pixels), witch i use to build the map like a puzzle, and then move the map behind the player to make it look like he is moving.
I was thinking I could use something like (image):replacePixels, but I'm not shure it will work. Any one have sugestions?
Using sprites to create a map
Re: Using sprites to create a map
Hi, welcome to the forums! It's hard to give any advice without looking at what you're doing. Using Image:replacePixels to draw a background sounds like a bad idea performance wise. One way is to draw the map at a different coordinate every frame (hopefully that's what you mean by "move the map"); if it's causing you performance issues, then we need to know more about what you're doing exactly, because it's not supposed to do so. Could you show us the code? Also, what size is your image?
- CrimsonGuy
- Prole
- Posts: 48
- Joined: Thu Apr 04, 2019 3:32 pm
Re: Using sprites to create a map
Im just guessing, but you probably have a lot of sprites and drawing them one by one with a call to love.graphics.draw which is bad for performance since each love.graphics.draw generates a call to the gpu. You could use a Spritebatch https://love2d.org/wiki/SpriteBatch to draw all the sprites on the map in a single call and improve performance by a lot. I was having a similar problem with my prototype and fixed it with Spritebatch.
Re: Using sprites to create a map
Oh, I think you're right CrimsonGuy, I didn't read the OP carefully enough it seems.
@szabo_tudor If you're using 11.x, then just using a texture atlas for all the map tiles would suffice to trigger autobatching, which should already improve performance significantly.
By the way, this subforum is for showing your games and creations. The questions normally go in Support and Development.
@szabo_tudor If you're using 11.x, then just using a texture atlas for all the map tiles would suffice to trigger autobatching, which should already improve performance significantly.
By the way, this subforum is for showing your games and creations. The questions normally go in Support and Development.
Who is online
Users browsing this forum: Google [Bot] and 1 guest