Bomberman Clone, 2D Camera

Hello dear readers! Today I will talk about my 2D camera class, why I created it, why I don’t really use it and why I chose to keep it. The 2D camera class was first created as a solution for having bigger maps than would fit on the screen (I had plans to make big challenge levels that you could play alone against AI “zombies”, similar to the first original bomberman).

It would allow the camera to move around the map and make sure to only render things that were actually shown on the screen, so if the map was bigger than what could be displayed, it would not render things outside of the screen (as it can’t be seen anyway by the user).

In the picture below you can see the whole map, while the red square is what the player can actually see on their screen. The camera class main job was to tell the draw manager what was inside the red square, to ensure the renderer only rendered a small portion of the map.

Camera use exempel.png
As you can see in the picture of what will get rendered, some of the wall blocks that are only half inside of the screen still gets fully rendered, this was because it was easier and faster to do this than to try and “cut” the wall. However as seen on the larger map a lot of things on the map are not drawn or rendered. This would help when making larger levels, though I would probably never get to the size of a map where the performance would actually matter. I do however believe in creating code that can be reused later in other projects.

Later in the making of bomberman I chose to simply scale the level so as to make sure it would always appear within the screen, meaning bigger screen = bigger object, smaller screen = smaller objects. This was to make  quicker progress in development . However I chose to keep the camera class in the engine simple if I would later like to make another game that would have use of it (maybe a  Mario clone or something similar). And I still use the camera2D class, though I don’t really depend on it as much.

 

Thank you for reading! Next post I will probably go into how the input manager works. If you have any question or anything specific you would like me to go into in more detail, just leave a comment and I will see what I can do.

About Pontus Berglund

2015 Programming