[SDL] correct way of map scrolling
Stefan Hendriks
stefanhen83 at gmail.com
Thu Aug 9 06:51:12 PDT 2007
> Question is:
> am i go wrong way or what?
>
> What do you think about that?
Are you really going to change all positions of your sprite? Instead,
change the position of your screenport and calculate the X and Y
positions from there.
ie.
CameraX = 10;
SpriteX = 10;
will result into:
drawX = SpriteX - CameraX;
the same goes for Y. This way you do not have to process your scroll
logic in your drawin routine (seperate drawing & logic).
Another tip would be to simply do a 'continue' when the sprite is not
in your viewport, skipping all other code it has to check which is
irrelevant.
regards,
Stefan
--
Stefan Hendriks
-----------------------
http://www.fundynamic.nl
More information about the SDL
mailing list