Map loading and drawing on screen


First attempt to load my custom map files into the game.

The maps are created with a proprietary tool that saves the structure of the map as an XML file. Using pugixml in C++ I was able to deserialise the map files and load the data into memory.

This video demonstrates two background images moving in parallax. Each image is approximately 4K or larger with no optimisation at this point.

I added a multiplier to force the images to move at different rates for a more convincing parallax effect.

Once I was happy with the parallax movements for now I worked to get the rest of the map drawing.
This was easier than I initially thought, the only issue i had was that I forgot to factor in the image draw offsets within the image libraries so most tiles would draw at the position of the object placement (all stacked on top of each other).

At this point i was getting around 400 - 420 fps which is nice, but everything is being drawn, even if it was out of the games viewport.
So with some tinkering I updated by Draw call to calculate if the tile was partially on the screen or not and use that as the deciding factor to draw or not. The implimentation of this is quite poor and could do with some refactoring, but it does bring the average fps up to 480 - 500 which should be consistant for the whole level as the player plays.

I can imaging it will drop when I start adding AI and collision checks.

Demonstration of parallax background drawing only within the set resolution for optimisation

Leave a comment

Log in with itch.io to leave a comment.