Highlighting a tile

Right now I’m working on an isometric tile-based game, and I wanted to figure out how to make tiles get “highlighted” when my mouse gets dragged over it. I know one way is to create separate tiles that are brighter than the original, but is there any way to do it integrated in Java?

Just draw another transparent tile over the selected tile to make it “glow” or so. You can use additive blending if you want, that might give you a more glowy effect.

You should add a if statement inside of your for loop of the tiles checking if the mouse X / Y is inside of the tile, than adjust it properly:


		/* Basic for loop to render 2D tiles? */
		int tileSize = 32;
		int width = 400;
		int height = 400;
		for (int x = 0; x < width; x += tileSize) {
			for (int y = 0; y < height; y += tileSize) {
				if (Mouse.X >= x && Mouse.X <= x + width && Mouse.Y >= y && Mouse.Y <= y + height) {
					// Mouse is inside the tile, change the color of it.
				} else {
					// Mouse is not inside the tile, so render it normally.
				}
			}
		}

Hope it helps some mate, like you said you’re using isometric tiles (I’m not familiar with isometric tiles), but I’m guessing you’d have to translate the coords :cranky:

Yep, I’ve worked on that the whole entire day. But actually, it finds the tile that is hovered over, and makes that selected. Also, I used theagentd’s suggestion and it worked perfectly.

If you’re interested in my isometric-screen space equations, here it is : https://gist.github.com/4009942

Those might come in useful for someone. You should post them in a new thread in the Shared Code forum.