简体   繁体   中英

2D platform game camera in c++

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 way to do this?

Lazy foo在这个主题上有一些不错的教程,并且进一步http://lazyfoo.net/SDL_tutorials/index.php导航到滚动教程,它是带有SDL的c ++语言,但是逻辑应该是通用的。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM