Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::ifstream fin("animation.txt");
- std::string keyword;
- int frameCount;
- void skipComment(std::istream& in) {
- std::string line;
- //skip comment line
- while(in.peek() == '#')
- std::getline(in, line);
- }
- skipComment(fin);
- fin>>keyword;
- if(keyword != "animation") {
- std::cout<<"Bad animation file";
- return;
- }
- fin>>frameCount;
- if(frameCount <= 0) {
- std::cout<<"Bad animation file";
- return;
- }
- skipComment(fin)
- fin>>keyword;
- if(keyword == "name") {
- std::getline(fin, keyword);
- // do something with the name.
- }
- while(fin) {
- skipComment(fin);
- fin>>keyword;
- if(keyword == "frame") {
- fin>>bound.x>>bound.y>>bound.width>>bound.height;
- bounds.push_back(bound);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement