Post

Visualizzazione dei post con l'etichetta coordinates

Tracking the mouse position

Immagine
For the purpose of this game, the only input device we need to manage is mouse. Basically, we just need a way to know which tile it's hovering on, and then take some action if we click while we're on it (Let's not worry about any buttons for now, we're going to handle user interface later). The steps to follow are: get the position of the mouse in screen space (x and y coordinates on our monitor) transform those coordinates to world position. This is based on where the camera is positioned. create a line perpendicular to our screen, starting from the mouse cursor. See if this line intersects any object. If that object is a hexagon, then that's the tile we're hovering on. Since I need to constantly check for the mouse position, I'm going to implement this in the Tick() method of my class, so that a check will be performed every frame: As you can see, I gave my PlayerController class a variable for the game state: player turn, player move...