[SDL] correct way of map scrolling

Will Langford unfies at gmail.com
Thu Aug 9 18:15:31 PDT 2007


On 8/9/07, Scott Harper <orcein at gmail.com> wrote:
>
> > If you're doing a true tiling system (say, 32x32 tiles or similar),
> > then ya might consider just recreating the background every frame.
> > You'll undoubtedly be animating EVERY tile, so you'll have to
> > redraw it anyway...
>
> For me, since I use SDL as a cheap way to set up and OpenGL context
> on whatever platform, I'm pretty sure I have to redraw all the tiles
> each frame anyway, as a result of using 3D acceleration for drawing.
> It should be relatively easy, however, to figure out what is on-
> screen or not (test bounds) so you don't have to draw EVERYTHING...
> Though with OGL, I recall that if something's offscreen it'll PROCESS
> the vertices you give it, but won't waste time drawing if nothing
> shows on-screen...  My general idea is to break larger maps down into
> smaller map segments, and do hit-testing on them for if they're near
> the screen edges, that way I may lose SOME cycles each redraw to
> wasted tiles drawn, but probably not as many as would be wasted with
> small hit-checks on each tile.  Kind of like a hand-made quad-tree,
> only without the even breaks.
>
> Wow, that was scatterbrained! >.<  Sorry for the unintelligible
> response! =)
>
> -- Scott
>

I've got very little experience in 3D, but is there an inexpensive distance
calculation kind of thing ? If the distance from the origin of the tile to
the camera is over a given amount, don't draw it ? or something ?  might
take some weird tweaking if you're doing distant paralaxing, but... I dunno
?

-Will
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20070809/a149f94e/attachment.html 


More information about the SDL mailing list