[SDL] Tile engine code
Trick
gerry at c64.org
Thu Jan 31 10:49:01 PST 2002
> I won't have to use any virtual members in my tile class.
That's good, but be careful if the tile class gets little ones - non-virtual
destructors may behave badly if they're doing something important, in some
cases.
[..]
> Hm, I was going to go through the list and check to see which ones are
> currently
> visible on the screen, and only draw those. That does sound a little
> inefficient
> though. What would be the best way to do this?
Depends =) See D.O.'s answer =)
[..]
> >So it's actually not just a plain map file, but a complete "level
> >definition"...?
>
> Why yes... yes it is. I want to use my tiling engine for more then one
> thing
>
> :)
I know the feeling - when i first started doing that little interface library
of mine, SIF, i wanted it to be able to do _everything_. After a couple of
rewrites and some good advice from (and rambling to =) David Olofson, i
realized that designing something to fit everything is generally a bad idea,
unless you're very, very careful. It's like designing an engine to fit cars,
boats, airplanes, space shuttles, time machines, and multidimensional
improbability/bistro-drive spaceships equally well =)
You'll probably get the best results for designing your tile engine for what
you need it for _right_now_ (grass mower), and leave room for enhancements
(interdimensional space-time controllers). After i started thinking this way,
i've done much more progress on SIF (it's still far from done, of course, but
i'm feeling that i'm getting somewhere). Whenever i get an idea that could be
implemented into SIF (which i do all the time), i don't actually implement it
right there and then. In stead, i put it into the back of my head, and keep
it in mind while writing the API.
For example, in SIF, i need to calculate a "hitmap" of sorts of a surface.
The hitmap is used for detecting collisions, etc. Right now, i'm planning on
using it with SDL surfaces (whoa, we're getting on topic!), but later on i
might want to use it with other things, like fx. OpenGL textures. That will
be no problem at all, because the only time i need to access the SDL surface
is when actually calculating the hitmap - the hitmap calculator isn't a true
part of SIF, it's just a tool to calculate the hitmap, which _is_ a true part
of SIF. The hitmap can be calculated in other ways, SIF doesn't care, as long
as the hitmap is there. I'm not that good explaining, but hopefully you get
the idea =)
[..]
> The tile size would be defined in one of the first few lines at the top
> of the file. I thought of this shortly after writing this letter.
Different sized tiles in the same tilemap ? Be sure that you actually need
that before you go on implementing it - there's more than one way to do
whatever it is you want to do, and the most advanced way is almost never the
best. Really =)
--
Trick
__________________________________________
Linux User #229006 * http://counter.li.org
"There is no magic" - Nakor, magic user
More information about the SDL
mailing list