SFML community forums

Help => Graphics => Topic started by: theonekamisama on April 21, 2017, 09:22:33 am

Title: Level making how?
Post by: theonekamisama on April 21, 2017, 09:22:33 am
i've been reading up , and if i'm not wrong a single image generated, is much better than generating each image tile by tile

That being said....
say
String a="\

_____________________"
;

//run the loop
{
if (if a[i][j]=="_")
w.draw(tile);
}

I've never actualy done this, or commented code on a forum.
But i've seen this work on others. And i wanna ask, is there a better way to do this? like less messy
Title: Re: Level making how?
Post by: eXpl0it3r on April 21, 2017, 01:44:05 pm
There are lots of different ways to save and parse a level. What you probably don't want to do is have x static if statements that determine what to draw, instead you might want to have an additional file that defines all the tile string characters and what image and texture rect zo use.
Additionally you want to build a vertex array and not directly call draw. This allows you to not having to parse the level every frame and drastically improves performance.

Not the best example, but here's how I did it for a game jam: https://github.com/eXpl0it3r/Synth-Guitar/blob/master/bin/res/level01.json