Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - pk3741

Pages: [1]
1
General / VertexArray, tilemap and mouse on tile
« on: August 27, 2019, 05:29:49 pm »
Hello
I have a problem with checking which tile the mouse is on. I found one solution which is already implemented, but makes a huge drop down of fps ammount. I just make an adtional VertexArray and use "contains" method. Could u tell me maybe another way to do this?

I have VertexArray of 2304 elements which makes 576 tiles.
The structure is:


Code:
(click to show/hide)

And code of LoadTileMap function (i know it's not best and probably could be in one loop :D)
(click to show/hide)

@edit
Okey, i got an idea:
                sf::Vector2i mouse = sf::Mouse::getPosition(window);
                sf::Vector2f mouse_world = window.mapPixelToCoords(mouse);
                cout << int(mouse_world.x / 60) << " " << int(mouse_world.y / 60)<<  endl;
 
Dividing position by tilesize. But i dont know how to use this information to get to the proper tile and change for example its color.

Pages: [1]