Question

I'm making a game (libgdx & box2d) with randomly generated planets having skyscrapers on them - see image below.

The Skyscrapers are random in their position, width and height. I'm now looking for the best way to texture these.

This is a general question on how to best solve texturing randomly sized objects, you don't need to supply code, though you may.

What are the options I have? Make small texture-squares and tile them? Stretch them? Procedurally generate them (would this be possible for a skyscraper-like texture - grey square for the base and black/yellow windows for with/without light)? What do I have to consider?

I really don't know how to go about this at the moment. Any ideas are welcome!

Thank you!

Jonas

Planet with Skyscrapers

Managed to do get it done with stretching - now only using one texture for all sizes, but I'll change that. stretched textures over box2d objects

Was it helpful?

Solution

As you said you have alot of possebilitys to solve this. Streching often does not look nice if you are close to those. But if they are fare away it could be a good solution. in my opinion Generating those does take time i guess and thats not a good idea for a game. You even do have to code alot of stuff and they look always simelar i guess.

I think Tileing isn't possible because your skytower are not always on a base of the tiles. So for example you got 32px Tiles and your tower is 53px high it does not work well because you would need to strech / cut or such one of the tiles.

I'd take the streching solution with a good filter. Get more than 1 picture for that so if you have bigger towers also take a bigger picture for a better solution. You need to take care about the width and height. You shouldnt clinch a really wide tower to much and also should stech a thin tower to a wide one. You can also randomize it a bit so you got some different pictures for sure.
Example for a Filter:

// we set the linear texture filter to improve the stretching
splashTexture.setFilter( TextureFilter.Linear, TextureFilter.Linear );

From this tutorial
Also take a look at this entry from the libgdx: Know Your Texture Filters!


But this is just my opinion.


To find out the Filter is used by default take a look at the Texture Methods.

getMagFilter();
getMinFilter() 

because you set the filters like this:

setFilter(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter) 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top