Archived

This topic is now archived and is closed to further replies.

brekehan

Tiling

Recommended Posts

I am attempting to write some simple tiling demos. I looked at most tutorials in the web and they explain the basics of how to load a texture on a quad and make an array for the world comprised of these quads. I was wondering if there was anything beyond that. Specificly classes and c++ style structures for tiles and groups of tiles so that I can organize texture loading and coords and such all into one nifty class. Also I need more info on how to make bitmaps appear on top of the tile with the proper transparency at unused portions. And finally how to pick in 2d. Thanx, Christopher

Share this post


Link to post
Share on other sites
Well, I think I classify as anyone ;-)
I''m afraid you''ll have to make your own level and tile class. They aren''t thard at all, unless your levels are going to be really complicated. Like you said, tiles are simply textured quads. The textre Coords can be a member of the tile class, and each tile has its own render function... etc etc etc.

Picking in 2D is easy, mostly because your mouse moves in 2D coordinates. Make a cursor class that keep track of a hot spot that is tested against the coordinates of the objects that are pickable. The rest is pretty much common sense, I''ll let you innovate from there.

valg3

Share this post


Link to post
Share on other sites
Ok but how can I restrict where a character can walk over the tile?

When a person click on screen I can find which rectangle
they clicked easy enough, but what if they clicked in a
transparent part of the rectangle? Should I keep a copy
of the bitmap stashed away in some variable for every object
and test alpha values? Isn''t that going to be expensive?

How do I keep track of what tiles are where if I scroll the
screen? The screen will then have parts of tiles and whole
tiles. If a player clicks say on the top portion how do I get
my program to say, ok thats part of tile [0][1] test there.

Thanx,
Christopher

Share this post


Link to post
Share on other sites
Ehmm that has nothing to do with OpenGL. I suggest you start reading some of the excellent articles on this very site. "Articles & Resources" - plenty of material on any issue.


2DNow - Specializing in yesterday''s technology today!

Share this post


Link to post
Share on other sites
lol where do you think I got all these questions from?
I have read every article on tiling and related issues
on this site and many others. I have searched google
extensively.

No where on this site does it explain how to restrict
movement over a tile.

I found one article on testing 2d picking but it really
doesn''t explain how to find out if the transparent part
was clicked or a filled in part. It simply says to keep
track of the order drawn and test. test what?

I saw nothing on actual scrolling of tiles just simple
2d arrays to keep id''s in. It was left up to the user
to do the math, shamefully I have no clue.

If I am missing something then please point out a specific
resource. It is my belief this has EVERYTHING to do with
OpenGL. What am I using the Windows API to do this stuff?

It maybe possible that I cannot find a resource to learn from
because I don''t even know what the topic would be. All I know
is OpenGL can do these things because I''ve seen OpenGL applications do them! You could at least be helpful enough
to say if I am looking for "alpha testing" or "masking" or
"blending" obviously even with the red book in front of me
I don''t know what I am looking for.

If you want me to take my questions elsewhere then be a kind lad
and tell me where.

Thanx,
Christopher

Share this post


Link to post
Share on other sites
Chill

Ok let''s look at your question:

You want transparency in tiles: either use alpha testing or alpha blending. This requires your images has an alpha channel (TGA files are good for this, format RGBA). One of the nehe tutorials explains this (and countless threads in this forum, just browse a bit)

If you truly want pixel-perfect detection of clicks within transparent or opaque areas of the tile, you can poll the alpha channel - seeing you have the graphics in memory already, this is inexpensive. Do not poll directly from videomemory, but use the copy of the tiles you loaded.

First determine which tile was clicked on, then examine it''s alpha channel at the point of the click. If the alpha is 0, it''s transparent.

2DNow - Specializing in yesterday''s technology today!

Share this post


Link to post
Share on other sites