MCPcopy Create free account
hub / github.com/atraczyk/2d-engine / loadConfig

Method loadConfig

engine/src/game.cpp:422–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

420};
421
422void Game::loadConfig(const char* filename)
423{
424 // Safe defaults if config is missing or malformed.
425 atlasInfo.sprites = {"textures/sprite01.bmp", 32, 16, 16, 32};
426 atlasInfo.tiles = {"textures/tiles03.bmp", 16, 16, 16, 16};
427 atlasInfo.abgs = {"textures/abg01.bmp", 2, 2, 512, 432};
428 atlasInfo.bgs = {"textures/bg01.bmp", 2, 4, 512, 432};
429
430 string line;
431 ifstream file(resolveResourcePath(filename));
432 istringstream ssf;
433 AtlasInfo* info;
434 if (file.is_open())
435 {
436 getline(file, line);
437 if (line.compare(0, 3, "\xEF\xBB\xBF") == 0)
438 line.erase(0, 3);
439 ssf = istringstream(line);
440 info = &atlasInfo.sprites;
441 ssf >> info->file >> info->framesWide >> info->framesHigh >>
442 info->frameWidth >> info->frameHeight;
443 getline(file, line);
444 ssf = istringstream(line);
445 info = &atlasInfo.tiles;
446 ssf >> info->file >> info->framesWide >> info->framesHigh >>
447 info->frameWidth >> info->frameHeight;
448 getline(file, line);
449 ssf = istringstream(line);
450 info = &atlasInfo.abgs;
451 ssf >> info->file >> info->framesWide >> info->framesHigh >>
452 info->frameWidth >> info->frameHeight;
453 if (!getline(file, line))
454 {
455 file.close();
456 return;
457 }
458 ssf = istringstream(line);
459 info = &atlasInfo.bgs;
460 ssf >> info->file >> info->framesWide >> info->framesHigh >>
461 info->frameWidth >> info->frameHeight;
462 file.close();
463 }
464};
465
466void P_pause(bool pause)
467{

Callers 1

G_initializeGameFunction · 0.80

Calls 1

resolveResourcePathFunction · 0.85

Tested by

no test coverage detected