Theory question

Helo!

    I wanted to know if some of you can tell me the theory of

something… not how it is done by the code.

I have made myself some ideas about it, but well… i thought… i will ask
the guys at the list so if what im thinking about is something not that
eficient they can tell me.

Its about makeing maps. I was wondering how to make a 2D map, where i can
draw things by tiles, but, to make a 3D aspect. What is it call (i think)
Isomeric View. (someone already told me to use diamons, thats a great idea
:wink: )

So my 3 questions are:

Can i use Triangles for TILES instead of squares or diamonds?
Do i have to use a SDL_Surface for EACH tile?
Can i have, instead a BIG image, a lot of tiny triangle images, and a data
file where i tell what tile image to blit in every place?

If you ask why i want to use lots of little images, its just because im
thinking to make (in the future when i get more experienced) an engine with
no need of EXTRA maps for creating a world. I mea, to be able to build a
Whole WORLD with just one map file, and an index-data that tells What parts
of the map are accesible or not (for eample, if there is a wall in front of
you, u cant go forward).
And, obviously, geting from that data files a “zone buffer”. So that the
players will move freely in that zone that will be already buffered. When
they go to another plays, that buffer is cleared and replaced with the “new
zone buffer”.

Thats my interpretation of how the Ultima Online map works… but well im
like a year of distand of that :stuck_out_tongue:

Thanks a lot for your help!! :slight_smile:

PD: Please, dont tell me how to do it by code, i dont want to bother. I just
want to know if it is possible, and i will find how to do it :))

                               Eduardo Garcia Rajo (h)------------------------------------------------------------------

Visite: http://www.solucion-digital.com.ar
SOLUCION DIGITAL
Redes - Software - Servicios

heya,

using triangles instead of diamonds or squares is possible yeah, it might be
wierd/difficult to program though. I dont have alot of 2d programming
experience but i have a little and i think youd be better off using a shape
like this if your going orthographic: /__/ (with a top of course too).

In any case, using tiles and having a graphic for each tile is a very common
technique. You wouldnt have to make a seperate surface for each tile, in
fact if you look at old games they often have 1 graphics file with alot of
pictures in it. What they do is load up the graphics into one "surface"
basicly and if they just draw the part of the surface that has the picture
they want. Does that make sense?

And yeah, for a map file, its fairly common to have an ascii map file where
different characters mean different things. For instance, if ‘X’ is a wall,
’ ’ is empty space, ‘Q’ is a door, and D are blocks that you cant move you
could have a map like below (looks like something outa zelda 1!):

XXXXXXQXXXXXXX
X X
X D D X
X Q
X D D X
X X
XXXXXXQXXXXXXX

and when you drew it to the screen youd just draw the right graphics
depending on what the map said was drawn there. The good thing about this
too is you can edit the map files yourself by hand in a text file, much
easier to work with.

also if you are doing your game orthographicly, you could have square
pictures but draw them crookedly so it looks like // instead of like ||.
That way you wouldnt have to make // shaped pictures since you would have
to worry about cutting off the parts that shouldnt be drawn. So basicly in
your graphics files, your tiles would look like |
| but they would be
designed to look good like // because thats how you draw them to the
screen. Drawing |
| graphics like /__/ is VERY fast compared to drawing
triangle textures or crazy stuff like that.

I dont have alot of this kind of game experience but i hope i cleared it up
a little!> ----- Original Message -----

From: quaker@advancedsl.com.ar (eDU)
To:
Sent: Saturday, May 24, 2003 8:05 PM
Subject: [SDL] theory question

Helo!

    I wanted to know if some of you can tell me the theory of

something… not how it is done by the code.

I have made myself some ideas about it, but well… i thought… i will ask
the guys at the list so if what im thinking about is something not that
eficient they can tell me.

Its about makeing maps. I was wondering how to make a 2D map, where i can
draw things by tiles, but, to make a 3D aspect. What is it call (i think)
Isomeric View. (someone already told me to use diamons, thats a great idea
:wink: )

So my 3 questions are:

Can i use Triangles for TILES instead of squares or diamonds?
Do i have to use a SDL_Surface for EACH tile?
Can i have, instead a BIG image, a lot of tiny triangle images, and a data
file where i tell what tile image to blit in every place?

If you ask why i want to use lots of little images, its just because im
thinking to make (in the future when i get more experienced) an engine
with
no need of EXTRA maps for creating a world. I mea, to be able to build a
Whole WORLD with just one map file, and an index-data that tells What
parts
of the map are accesible or not (for eample, if there is a wall in front
of
you, u cant go forward).
And, obviously, geting from that data files a “zone buffer”. So that the
players will move freely in that zone that will be already buffered. When
they go to another plays, that buffer is cleared and replaced with the
"new
zone buffer".

Thats my interpretation of how the Ultima Online map works… but well im
like a year of distand of that :stuck_out_tongue:

Thanks a lot for your help!! :slight_smile:

PD: Please, dont tell me how to do it by code, i dont want to bother. I
just
want to know if it is possible, and i will find how to do it :))

                               Eduardo Garcia Rajo (h)

Visite: http://www.solucion-digital.com.ar
SOLUCION DIGITAL
Redes - Software - Servicios


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Attrix thanks a lot for ur reply.

I will start testing, and well… i will see what is better i think. I like
that idea of using || but showing them like //. I can have an isomeric
view, and also, using sprites with the same perspective will do the rest.

Thanks :slight_smile:

                       Eduardo Garcia Rajo (h)------------------------------------------------------------------

Visite: http://www.solucion-digital.com.ar
SOLUCION DIGITAL
Redes - Software - Servicios

----- Original Message -----
From: atrix2@cox.net (atrix2)
To:
Sent: Sunday, May 25, 2003 12:36 AM
Subject: Re: [SDL] theory question

heya,

using triangles instead of diamonds or squares is possible yeah, it
might be wierd/difficult to program though. I dont have alot of 2d
programming experience but i have a little and i think youd be
better off using a shape like this if your going orthographic:
/__/ (with a top of course too).

That would give you a different perspective from the diamond format,
though.

In any case, using tiles and having a graphic for each tile is a
very common technique. You wouldnt have to make a seperate surface
for each tile, in fact if you look at old games they often have 1
graphics file with alot of pictures in it. What they do is load up
the graphics into one “surface” basicly and if they just draw the
part of the surface that has the picture they want. Does that make
sense?

Well, yes - but not these days. Old games did this either because they
had custom blitters that sheared the graphics into the /_/ shape, or
because they were using h/w blitting, like the Amiga, for example.

However, if you use software rendering, RLE acceleration and
non-rectangular tiles, it’s not a good idea to use a single surface
for all tiles. When you clip, blitting from an RLE surface, the RLE
blitter will have to scan RLE runs to find out which ones to render,
so it can be rather expensive.

And yeah, for a map file, its fairly common to have an ascii map
file where different characters mean different things. For
instance, if ‘X’ is a wall, ’ ’ is empty space, ‘Q’ is a door, and
D are blocks that you cant move you could have a map like below
(looks like something outa zelda 1!):

XXXXXXQXXXXXXX
X X
X D D X
X Q
X D D X
X X
XXXXXXQXXXXXXX

and when you drew it to the screen youd just draw the right
graphics depending on what the map said was drawn there. The good
thing about this too is you can edit the map files yourself by hand
in a text file, much easier to work with.

It’s even easier to just draw the map in the game, in an "edit mode"
of some kind. :wink:

Of course, then you’ll have to hack a simple editor, but if you’re
going to edit tons of maps with tons of graphics - especially if
there are multilayered tiles, background sprites, parallax and stuff
like that - it’s going to be worth it.

Also note that ASCII maps don’t map very well to isometric
perspectives. (Pun is a free bonus.) It gets a bit hard to see what
you’re doing, but I supposed you get used to it…

also if you are doing your game orthographicly, you could have
square pictures but draw them crookedly so it looks like //
instead of like |
|.

Yep, but then you’d have to use OpenGL, or hack custom blitters.

Well, you could just blit one pixel row at a time, but that’s
h*lluva lot of calls to SDL_BlitSurface()…

Besides, it doesn’t really buy you much compared to the diamond shape.
Diamons give you a slighly higher number of lines per tile, but
that’s pretty irrelevant. Whether you roll your own diamond blitters
or use SDL’s RLE (which can handle diamonds just fine), it’s only a
plain block copy per line.

If you use your own blitters, you can indeed pack the diamonds and
still get them out, but with RLE, the apparently unused space
actually doesn’t exist in the RLE encoded surfaces. Each run of
transparent pixels is replaced with a “skip instruction”, which
doesn’t cost much more than the corresponding logic in a custom
blitter.

That way you wouldnt have to make // shaped
pictures since you would have to worry about cutting off the parts
that shouldnt be drawn. So basicly in your graphics files, your
tiles would look like |
| but they would be designed to look good
like /__/ because thats how you draw them to the screen.

That only makes graphics editing harder. It’s much easier to get the
graphics right if you can just draw it like it will look in the game.

Besides, I don’t know of any graphics applications (GIMP, PhotoShop,
PantShop Pro, Corel PhotoPaint [or whatever it’s called] etc) that
can take shearing and transformations like that into account when
applying filters and stuff. Aspect ratio compensation is about as far
as that goes.

Drawing
|| graphics like // is VERY fast compared to drawing triangle
textures or crazy stuff like that.

It’s slower than plain RLE blits of any sensibly shaped colorkeyed
surfaces, though, unless possibly if you hack your own blitters.
Not many cycles you can save there, though. I wouldn’t bother.

I dont have alot of this kind of game experience but i hope i
cleared it up a little!

I would say you’ve managed to complicate stuff a little. :wink:

What you’re suggesting would indeed work, and it would probably make
sense in some situations, but since we have either SDL_RLEACCEL or
h/w accelerated colorkeying in SDL, we allready have the perfect
swiss army knive for this kind of stuff. Why hack weird software
blitters when there already is one that covers it all, and that
allows you to use tile formats that are also compatible with 2D
hardware acceleration? (Only OpenGL and Direct3D can efficiently
transform tiles while blitting. Anything with colorkey or alpha can
do diamonds.)

//David Olofson - Programmer, Composer, Open Source Advocate

.- The Return of Audiality! --------------------------------.
| Free/Open Source Audio Engine for use in Games or Studio. |
| RT and off-line synth. Scripting. Sample accurate timing. |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Sunday 25 May 2003 05.36, Atrix Wolfe wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi!
Interesting conversation, also i am going to get a little technical now

also if you are doing your game orthographicly, you could have square
pictures but draw them crookedly so it looks like // instead of like
|
|.

Mmh, i thought about that before, but is there any better way than, everytime
you load the image, doing a pixel-by-pixel-blit to an empty surface on which
the /__/-shaped image will be afterwards?

the screen. Drawing || graphics like // is VERY fast compared to
drawing triangle textures or crazy stuff like that.

that for shure is true, and if you make a conversion on load-time, there would
not even be a performance lag due to the || to // conversion.


Matthias Bach | GPG/PGP-Key-ID: 0xACA73EC9
www.marix-world.de | On Keyserver: www.keyserver.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE+0KvVlnJmS6ynPskRAvZTAKCLiHYHjvODmhZDnorg+f1iUaozXQCfaGlk
PTiJ94725B7T780qUthzMO4=
=HYjr
-----END PGP SIGNATURE-----Am Sonntag, 25. Mai 2003 05:36 schrieb Atrix Wolfe:

Hi!
Interesting conversation, also i am going to get a little technical
now

also if you are doing your game orthographicly, you could have
square pictures but draw them crookedly so it looks like /__/
instead of like

|__|.

Mmh, i thought about that before, but is there any better way than,
everytime you load the image, doing a pixel-by-pixel-blit to an
empty surface on which the /__/-shaped image will be afterwards?

I would say it’s both better and easier to just draw the tiles like
that right away.

Besides, if you create rectangular but “pre-sheared” surfaces at load
time, the whole point with using rectangular tiles is gone - unless
you have a particularly good reason for wanting to draw everything in
an incredibly weird looking format. :slight_smile:

the screen. Drawing || graphics like // is VERY fast
compared to drawing triangle textures or crazy stuff like that.

that for shure is true,

Nope, not unless “triangle textures or crazy stuff like that” means
rotation and stuff, like textured polygons. There’s no reason to do
that, though - and the below suggests that you realize that.

and if you make a conversion on load-time,
there would not even be a performance lag due to the || to //
conversion.

Right - but why mess with it then? It’s nearly always easier to draw
graphics directly the way it’s supposed to look.

//David Olofson - Programmer, Composer, Open Source Advocate

.- The Return of Audiality! --------------------------------.
| Free/Open Source Audio Engine for use in Games or Studio. |
| RT and off-line synth. Scripting. Sample accurate timing. |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Sunday 25 May 2003 13.41, Matthias Bach wrote:

Am Sonntag, 25. Mai 2003 05:36 schrieb Atrix Wolfe:

well… i really apreciate your replys (from all of you) but i must admit
that im a little confused now… as you started talking about polygons (my
intension is to make a 2D game, with no OpenGL.) and all that stuff.

may be we can make a little resume of all of this… what i had understand:

  1. Use tiles as they are. If i want Diamonds, just use Diamond pictures.
    right? No conversions.

  2. Well, about the triangles instead of diamonds, now i see that its not
    necesary, when i can use a diamond tile, wich its “Background” will be
    transparent.
    Also, when using diamonds ill have a lot of posibiliites, like, haveing 8
    movement directions for sprites (sprites will walk over the tiles). And also
    more perspective posibilites.

What i didnt understand:

About the surfaces used… do i need one surface for EACH tile?
If i do so, i will have a “background” surface, where i will put lot of
surfaces (tiles)

Or maybe i can have just one background surface, and then i can tell Where
to blit in that surface, every tile. But this may be its more confuding
even.

Well, as it seems i better go check some examples, and read more about
before asking again… its like more difficult than what i thought.

Thanks again for all the useful replies you gave me :))

bye

                       Eduardo Garcia Rajo (h)------------------------------------------------------------------

Visite: http://www.solucion-digital.com.ar
SOLUCION DIGITAL
Redes - Software - Servicios

----- Original Message -----
From: david@olofson.net (David Olofson)
To:
Sent: Sunday, May 25, 2003 11:32 AM
Subject: Re: [SDL] theory question

On Sunday 25 May 2003 13.41, Matthias Bach wrote:

Hi!
Interesting conversation, also i am going to get a little technical
now

Am Sonntag, 25. Mai 2003 05:36 schrieb Atrix Wolfe:

also if you are doing your game orthographicly, you could have
square pictures but draw them crookedly so it looks like /__/
instead of like

|__|.

Mmh, i thought about that before, but is there any better way than,
everytime you load the image, doing a pixel-by-pixel-blit to an
empty surface on which the /__/-shaped image will be afterwards?

I would say it’s both better and easier to just draw the tiles like
that right away.

Besides, if you create rectangular but “pre-sheared” surfaces at load
time, the whole point with using rectangular tiles is gone - unless
you have a particularly good reason for wanting to draw everything in
an incredibly weird looking format. :slight_smile:

the screen. Drawing || graphics like // is VERY fast
compared to drawing triangle textures or crazy stuff like that.

that for shure is true,

Nope, not unless “triangle textures or crazy stuff like that” means
rotation and stuff, like textured polygons. There’s no reason to do
that, though - and the below suggests that you realize that.

and if you make a conversion on load-time,
there would not even be a performance lag due to the || to //
conversion.

Right - but why mess with it then? It’s nearly always easier to draw
graphics directly the way it’s supposed to look.

file://David Olofson - Programmer, Composer, Open Source Advocate

.- The Return of Audiality! --------------------------------.
| Free/Open Source Audio Engine for use in Games or Studio. |
| RT and off-line synth. Scripting. Sample accurate timing. |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

[…]

What i didnt understand:

About the surfaces used… do i need one surface for EACH tile?

Not strictly, but it’s recommended when using SDL_RLEACCEL. Clipping
to blit a rectangle from within an RLE surface isn’t as efficient as
blitting RLE surfaces without clipping.

If i do so, i will have a “background” surface, where i will put
lot of surfaces (tiles)

A tile palette…?

Or maybe i can have just one background surface, and then i can
tell Where to blit in that surface, every tile. But this may be its
more confuding even.

Why, yes… There’s no other way of doing it, except using one surface
per tile. I’m not sure what you mean, really.

Well, as it seems i better go check some examples, and read more
about before asking again… its like more difficult than what i
thought.

Well, you’ll have to grasp the plain rectangular tiles first, but then
it’s really just four steps to diamond isometric:

1) Draw diamond shaped tiles instead of square tiles.
	*****        --*--
	*****        -***-
	*****   -->  *****
	*****        -***-
	*****        --*--

2) Enable colorkeyed blitting, to make the transparent
   areas of the tiles work properly.

3) When rendering, use half the distance between rows, and

4) Offset every other line half a tile width.

That’s about it, as far as basic rendering goes, at least.

//David Olofson - Programmer, Composer, Open Source Advocate

.- The Return of Audiality! --------------------------------.
| Free/Open Source Audio Engine for use in Games or Studio. |
| RT and off-line synth. Scripting. Sample accurate timing. |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Monday 26 May 2003 06.08, eDU! wrote:

Great, thanks you very much! =)

i have found some demos about it, and ill have some stuff to practice with
about maps :wink:

                       Eduardo Garcia Rajo (h)------------------------------------------------------------------

Visite: http://www.solucion-digital.com.ar
SOLUCION DIGITAL
Redes - Software - Servicios

----- Original Message -----
From: david@olofson.net (David Olofson)
To:
Sent: Monday, May 26, 2003 2:04 AM
Subject: Re: [SDL] theory question