• Create Account

Member Since 05 May 2012
Offline Last Active Dec 01 2013 09:39 PM

### #4941090AI and Interfaces + Inheritance

Posted by on 17 May 2012 - 08:18 PM

You are on the right track. Polymorphism can be a great way to implement special cases without having complex if-else logic.

### #4939929C++ - do you use STL in your game?

Posted by on 13 May 2012 - 06:58 PM

Thanks, guys. I got some experience writing my own linked lists and trees in the past, so I think I'm going to go with the collections provided by the C++ standard library.

### #4939912Mouse click on isometric map

Posted by on 13 May 2012 - 05:03 PM

First, let me make sure I understand your question. You want to have the user click the mouse, and be able to tell which tile they clicked on. The problem is, you can only get the mouse coordinates in screen space, and your tile data is stored in world space. Is that right?

I've read about how to do this before, and the problem can be solved with ray casting. I have never actually implemented it, but I can give you a high-level idea of how i think it might work.

Somewhere in your code, you must be storing the camera's position and the direction it is looking. If the player were to click in the exact center of the screen, you could imagine a ray coming out of the camera's position, travelling in the direction the camera is looking. If the ray were long enough, you could compute which tile that ray intersected (if any).

Now let's say the player does not click in the exact center of the screen. Imagine a plane centered on the camera's position, perpendicular to the direction the camera is looking. Wherever the player clicked would correspond to some point on that plane. If there were a ray coming out of that point, in a direction parallel to the camera's direction, you could compute which tile that ray intersects (if any).

PARTNERS