Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. std::ifstream fin("animation.txt");
  2.  
  3. std::string keyword;
  4. int frameCount;
  5.  
  6. void skipComment(std::istream& in) {
  7.     std::string line;
  8.     //skip comment line
  9.     while(in.peek() == '#')
  10.         std::getline(in, line);
  11. }
  12.  
  13. skipComment(fin);
  14. fin>>keyword;
  15. if(keyword != "animation") {
  16.     std::cout<<"Bad animation file";
  17.     return;
  18. }
  19.  
  20. fin>>frameCount;
  21. if(frameCount <= 0) {
  22.     std::cout<<"Bad animation file";
  23.     return;
  24. }
  25.  
  26. skipComment(fin)
  27. fin>>keyword;
  28. if(keyword == "name") {
  29.     std::getline(fin, keyword);
  30.     // do something with the name.
  31. }
  32.  
  33. while(fin) {
  34.     skipComment(fin);
  35.     fin>>keyword;
  36.     if(keyword == "frame") {
  37.         fin>>bound.x>>bound.y>>bound.width>>bound.height;
  38.         bounds.push_back(bound);
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement