[SDL] correct way of map scrolling
Alan Wolfe
Atrix2 at cox.net
Thu Aug 9 20:19:18 PDT 2007
You could for sure do that and just compare squared distances to save on the
square roots (slow!) but I think in the end you'd end up with a CIRCLE of
tiles instead of a rectangle :P
Maybe you could use "fog of war" to round the rectangle to a circle with
tiles on the outside fading to darkness but dont know if thats appropriate
for the game.
$0.02 (:
________________________________________
From: sdl-bounces at lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Will Langford
Sent: Thursday, August 09, 2007 6:16 PM
To: A list for developers using the SDL library. (includes SDL-announce)
Subject: Re: [SDL] correct way of map scrolling
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
More information about the SDL
mailing list