// Read data of sprites and animations from file. void LoadSprites(int id, LPCWSTR tex, LPCWSTR sprite_data, LPCWSTR animation_data) { textures->Add(id, tex); LPDIRECT3DTEXTURE9 texture = textures->Get(id); ifstream spriteReader, animationReader; spriteReader.open(sprite_data); animationReader.open(animation_data); if (spriteReader.fail()) { DebugOut(L"[ERROR] LoadSprites failed!: ID=%d", id); spriteReader.close(); return; } if (animationReader.fail()) { DebugOut(L"[ERROR] LoadAnimation failed!: ID=%d", id); animationReader.close(); return; } // Load sprite data string spriteid; int left, top, right, bottom; while (spriteReader >> spriteid >> left >> top >> right >> bottom) sprites->Add(spriteid, left, top, right, bottom, texture); spriteReader.close(); // Load animation data string animationId; string line; string spriteId; int frameTime; while (getline(animationReader, line)) { LPANIMATION ani = new Animation(); istringstream iss(line, istringstream::in); iss >> animationId; while (iss >> spriteId >> frameTime) ani->Add(spriteId, frameTime); animations->Add(animationId, ani); } animationReader.close(); } LoadSprites(ID_TEX_SIMON, L"Textures\\Simon.png", L"Textures\\Simon_sprites.txt", L"Textures\\Simon_animations.txt");