Drawing level art by hand sucks. Up until now, that's how I made all the level art for my games: I'd whitebox a room, spend an hour or two drawing over it, then rinse and repeat for 7-40 other rooms.
Although the process is brain-dead easy, it takes a lot of memory and time to store and load those textures. Each room texture on average is about 1.4 MB and takes around a second or two to load. Add in the time it takes to draw the image itself and making levels becomes a huge pain in the ass. The game's framerate also tends to stutter when it's loading all that garbage in the background.
To solve all those problems, I put on my thinking cap and investigated ways to speed up the process.
A tile-based system wouldn't work. There are lots of curves and odd angles in the level geometry so there would have to be as many tiles as there are angles. Plus, tiles blow. After doing some more research, I came upon the idea of using sprite stamps to generate a texture at runtime. Unfortunately, the art style I'm using won't let me use plain ol' stamps because of the black outlines. I'd have to get creative.
Coding happened, and here's how the level art generator works:
- Draw the shapes that make up the ground.
- Use a duo of shaders to outline the ground shapes and give it a black outline.
- Draw strips of "siding" stamps along walls.
- In a separate texture, draw the strips of grass stamps, which are blotches of color without black outlines.
- Once the grass stamp strips are drawn, use the shaders to outline them.
- Draw the outlined grass on the rest of the level art, using a special dropshadow shader. The shader makes the grass look like it's casting a shadow on the ground it's drawn over.
There's still some refinement to be done, but the initial results are promising:
The best part is that it uses way less space, takes less time than loading a texture into memory, and doesn't ruin my wrist from drawing grass for hours. Don't take my word for it, the numbers don't lie:
Space used by prebaked textures for Petal Pass: 11.7 Mb
Space used by the level generator textures: 334 kb (2.7% of the size!)
Time to load a prebaked texture into memory: About 0.22 seconds
Time to generate a level texture dynamically: About 0.06 seconds (three times faster!)
Time to draw prebaked textures: 45 to 90 minutes per room
Time to set up a level for generation: About 10 to 15 minutes per room (way faster!)
There you have it. Now that I have the level art generator to take care of level art, I'm free to draw way cooler stuff like butts and dead people.