Problem With Viewport Camera[SDL2] |
Naith
|
That's not really how the viewport is supposed to be used. The viewport is used to "set the drawing area for rendering on the current target" (https://wiki.libsdl.org/SDL_RenderSetViewport).
What you want to do instead is offset your objects (player, enemies and such) by the camera position to make the illusion that the objects are moving to the left whenever the camera is moving to the right. Example code below:
Let me know if you have any more questions |
|||||||||||||
|
Naith
|
Also:
Here you can learn more about the usage of the viewport: http://lazyfoo.net/tutorials/SDL/09_the_viewport/index.php And learn more about camera scrolling: http://lazyfoo.net/tutorials/SDL/30_scrolling/index.php |
|||||||||||
|
theatron
|
Ohhhh :O
When you think you of it like that you don't really need a Viewport, and thanks also for the tutorial on cameras! |
|||||||||||
|