I was wondering how exactly cameras are programmed in a 2D platform game. How is it programmed only to render whats in the view of the camera without rendering the whole map? Also, whats the proper开发者_如何学Python way to do this?
Lazy foo has some good tutorials on this subject and further http://lazyfoo.net/SDL_tutorials/index.php navigate to the scrolling tutorial, its in c++ with SDL but the logic should be universal.
There is no secret about that, you can simple check which tiles and which sprites are inside the rectangle that defines the screen and only draw those.
Another trick is to make the cameras always follows the player, but when it gets to the corner of the scenario you stop moving the camera, so you do not show the scenario borders.
精彩评论