I’m making a simple platforming game in SDL 2.0 and C++.
I’m having a few problems, one of them is getting a map loader working, currently I have something mashed together from some tutorials and some of my own stuff.
Here are all the files in question (Since I can only post 2 links, I’ll just post the link to the github repo)
The Github Repo
The files that I’m talking about are:
- Map.h
- Map.cpp
- Tile.h
- Tile.cpp
- Window.h
- Window.cpp
- .Map file
- The tileset.png
So I use Map::OnLoad()
to load the map from the .map file, then while it’s loading, all the tiles are being pushed to my Tile list “TileList”. Then I use Map::OnRender()
to render it tile by tile.
Now I’m not quite sure where my error roots from or why it’s happening, but I think it’s in my Map::OnRender()
where I actually render it using
SDL_Rect _SrcTile = { TilesetX, TilesetY, TILE_SIZE, TILE_SIZE }; SDL_Rect _DstRect = { MapX, MapY, tY, tX }; SDL_RenderCopy(_renderer, _tileset, &_SrcTile, &_DstRect);
When I run the game, this is what I end up with:
I’m not getting any errors, but it’s not at all what I expect to happen, how can I fix this?