SFML community forums

Help => General => Topic started by: M4c!3K on December 09, 2014, 08:39:25 pm

Title: How do i load only enemies from file?
Post by: M4c!3K on December 09, 2014, 08:39:25 pm
I have been writing a kind of Space Shooter game in SFML2 (really ambitiously), then i started to create level loading from files. And i have no idea how to do it. I know how to read from files, and i saw tutorials on creating tilemaps in SFML however i don't want to load whole tilemap, just general information (name) and enemies (plus it's positions). Is it possible to load them from textfile with content like...
{0,0,level};[0, 255, 255], [0,255,255]
Where things in {} are informations and things in [type, posision-x, position-y] are enemies.
I'll be really thankful for answers.
Title: Re: How do i load only enemies from file?
Post by: Ixrec on December 09, 2014, 10:09:05 pm
Yes, it's possible.  As you've probably realized, what you need to do is decide on a precise format, and then teach your program how to parse that format.

For maximum flexibility (and to skip the hassle of writing your own parser just for this), it's probably easiest to use a preexisting format like JSON or XML which has plenty of C++ libraries already written to do the parsing/encoding stuff for you.