Pixel-Problem

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
DarkWood_Neo
Posts: 52
Joined: Thu Sep 04, 2003 7:45 pm
Location: Germany

Pixel-Problem

Post by DarkWood_Neo »

hello!

in my 2d iso strategy game i want to select a tile by mouse. thats almost works fine but the tiles overlap (in most cases only the transparent areas overlap). Now my question: How can I find out to which texture a pixel, that i get from the cursor position, belongs?

hope you understood my problem ;-)
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

I don't know the answer to your question but what I do know is a place you might find it. www.GameDev.net has a good selection of articles about 2D isometric games in their reference section, you could do a lot worse than read your way through them.
DarkWood_Neo
Posts: 52
Joined: Thu Sep 04, 2003 7:45 pm
Location: Germany

Post by DarkWood_Neo »

Its an engine specified problem. the tutorials and articles on gamedev.net aren't usefull.
Endar
Posts: 145
Joined: Mon Jun 14, 2004 7:59 am

Post by Endar »

Take a look at the API. There are some functions, one is called something like "getRayFrom2DCursor" or something like that, and that shoots a 3d line into the world starting from the 2d co-ordinates of the mouse cursor.

Take a look, because it's entirely possible that the function you need is already in the API.
"The reputation of a thousand years may be determined by the conduct of one hour."
-Japanese Proverb
DarkWood_Neo
Posts: 52
Joined: Thu Sep 04, 2003 7:45 pm
Location: Germany

Post by DarkWood_Neo »

it's a 2d game......and I use draw2dImage() to draw the tiles.
before i started this thread i had looked for a function in the API.....but there is no, neither for ITexture nor the cursor control....
StuCollier
Posts: 52
Joined: Tue Mar 30, 2004 12:16 pm

Post by StuCollier »

Is it better that you should be looking at your 2D map rather than selecting textures from the screen ?

i.e. translate your 3D cursor pos into 2D co-ordinates and look those up in your tilemap array.
StuC
Freeware games
www.ovine.net
DarkWood_Neo
Posts: 52
Joined: Thu Sep 04, 2003 7:45 pm
Location: Germany

Post by DarkWood_Neo »

1. the tile-images overlap. There ist a part of the images which is transparent and that part overlaps with other transparent ones.
2. I got the 2 position of the cursor by using a fuction of a ICursorControl instance.
3. the problem is that i don't know to which image the position belongs.

StuColliers tip isn't useful because i got the 2d coordinates of every image - but only the coordinates of the left upper corner.
StuCollier
Posts: 52
Joined: Tue Mar 30, 2004 12:16 pm

Post by StuCollier »

Are all your "tiles" not the same size ?

If not you must know the size of each of the tiles to place them on the screen ? - if so just create an array of x,y,x1,y1 ?
StuC
Freeware games
www.ovine.net
DarkWood_Neo
Posts: 52
Joined: Thu Sep 04, 2003 7:45 pm
Location: Germany

Post by DarkWood_Neo »

Every tile got the same size - they look like this tile.
And i know the size of every tile for sure - the problem is the overlapping transparent area. in the picture the black background is transparent.
DarkWood_Neo
Posts: 52
Joined: Thu Sep 04, 2003 7:45 pm
Location: Germany

Post by DarkWood_Neo »

does no one know a solution?
maybe i have to modify the engine :?.................?
kortyburnss

Post by kortyburnss »

This is a paste from the irr documentation :

virtual void* irr::video::ITexture::lock ( ) [pure virtual]

Lock function. Locks the Texture and returns a pointer to access the pixels



You could use that fonction to check if the collising texture's pixel is (or not) the transparent color. If no, then COLLISION.
Post Reply