Page 1 of 1

Pixel-Problem

Posted: Sun Jul 18, 2004 8:32 am
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 ;-)

Posted: Sun Jul 18, 2004 9:34 am
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.

Posted: Mon Jul 19, 2004 10:38 am
by DarkWood_Neo
Its an engine specified problem. the tutorials and articles on gamedev.net aren't usefull.

Posted: Mon Jul 19, 2004 12:22 pm
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.

Posted: Mon Jul 19, 2004 3:56 pm
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....

Posted: Tue Jul 20, 2004 10:26 am
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.

Posted: Wed Jul 21, 2004 7:56 am
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.

Posted: Wed Jul 21, 2004 12:45 pm
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 ?

Posted: Wed Jul 21, 2004 8:11 pm
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.

Posted: Fri Jul 23, 2004 7:40 am
by DarkWood_Neo
does no one know a solution?
maybe i have to modify the engine :?.................?

Posted: Sun Aug 08, 2004 9:46 pm
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.