Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How do i load only enemies from file?  (Read 799 times)

0 Members and 1 Guest are viewing this topic.

M4c!3K

  • Newbie
  • *
  • Posts: 2
    • View Profile
How do i load only enemies from file?
« 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.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: How do i load only enemies from file?
« Reply #1 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.