cavestory-development icon indicating copy to clipboard operation
cavestory-development copied to clipboard

tiled level is not rendering

Open nsklaus opened this issue 5 years ago • 2 comments

hello, thanks for the tutorial. i'm having a problem with it though. i'm not getting errors, it compiles fine, i can move the hero sprite around but, the tiled level is not rendering. please see screenshot. below is my "content" and "maps" directories. i don't think i'm missing a file ? also the map shows correctly in tiled.

MBP: cavestory-development
$ tree content/ maps/
content/
├── backgrounds
│   └── bkBlue.png
├── sprites
│   ├── MyChar.png
│   ├── NpcCemet.png
│   └── TextBox.png
└── tilesets
    ├── NpcSym.png
    └── PrtCave.png
maps/
├── Map 1.tmx
└── Map 2.tmx

3 directories, 8 files
MBP: cavestory-development

screenshot_20190112_200247

nsklaus avatar Jan 12 '19 19:01 nsklaus

This and #4 may be related to the fact that the map files use a path for the tileset that is relative to the tmx file, while the binary needs a path relative to where it is. This seems to work fine for however Limeoats has his eclipse project set up, but doesn't seem to work if you are running your own binary.

I'm still pretty early on in the YouTube videos, finished Part 3 of "The level class", however rather than using the path in the source attribute of the tmx directly I've added code to extract the filename and rebuilt the path used by the game to be relative to my binary.

const char* source = pTileset->FirstChildElement("image")->Attribute("source");
char* path = "content/tilesets/"; // Where my tilesets are located
std::string file = source; // Use a string object created from the c_str source
std::string filename = file.substr(file.find_last_of("/") + 1); // Find the file's name which is after the last / in the path
std::stringstream ss;
ss << path << filename; // Pass the path and the filename into the stringstream instead of source

flagrama avatar Jan 18 '19 14:01 flagrama

thanks for telling !

nsklaus avatar Jan 18 '19 15:01 nsklaus