Hiya, so i've been working on a city simulation game and currently have a map consisting of 200 tiles, which are currently drawn in a for loop by graphics.draw(). However,I understand that this is not terribly effecient and the only alternative I have come across are spritebatches, but these don't seem to be suitable as the player has the ability to build bulidngs,lakes and roads etc, therefore changing the image of the tile that is being drawn; and sprite batches can only consist of one image?
Other than putting as little code as possible in the for loop, I don't really have any other ideas for optimisation! Any suggestions would be appreciated, thanks!!
Help optmising city simulation game!
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Help optmising city simulation game!
You can use a spritesheet as the spritebatch texture, and add quads to it so that you only add one part of the image.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Re: Help optmising city simulation game!
Thanks, i'll look into it!Nixola wrote:You can use a spritesheet as the spritebatch texture, and add quads to it so that you only add one part of the image.
Re: Help optmising city simulation game!
You could probably use a canvas.
Possession - Escape from the Nether Regions, my roguelike made in LÖVE for the 2013 7-Day Roguelike Challenge
And its sequel, simply called Possession , which is available on itch.io or Steam, and whose engine I've open-sourced!
And its sequel, simply called Possession , which is available on itch.io or Steam, and whose engine I've open-sourced!
Re: Help optmising city simulation game!
A game like Sim City would probably have all the sprites in one spritesheet, including the buildings and all their animations.
Or you could have a separate table for all the building locations, and draw only those that are visible on top of the map.
Or you could have a separate table for all the building locations, and draw only those that are visible on top of the map.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Help optmising city simulation game!
My advise on optimization would be: try your code without optimizations first. If it works ok in your target machine (i.e. a low-spec pc), then move on to the next thing - don't "optimize" what is fast enough. Don't leave optimizations in "just in case". The time you save can be employed in making your game better. Or at least in optimizing what really needs to be optimized.
When I write def I mean function.
-
- Party member
- Posts: 125
- Joined: Wed Nov 26, 2014 6:43 am
Re: Help optmising city simulation game!
Store tiles in a table BEFORE drawing. Then draw using the data of the table. Should be a bit more efficient.rougan wrote:Hiya, so i've been working on a city simulation game and currently have a map consisting of 200 tiles, which are currently drawn in a for loop by graphics.draw(). However,I understand that this is not terribly effecient and the only alternative I have come across are spritebatches, but these don't seem to be suitable as the player has the ability to build bulidngs,lakes and roads etc, therefore changing the image of the tile that is being drawn; and sprite batches can only consist of one image?
Other than putting as little code as possible in the for loop, I don't really have any other ideas for optimisation! Any suggestions would be appreciated, thanks!!
Who is online
Users browsing this forum: Bing [Bot] and 49 guests