GameMaker Advice Needed, Mouse Controls for a 4 directional Isometric World

Y

Yogen

Guest
Right, so I figured out keyboard controls for movement on an Isometric world. But I would like to add mouse controls as a feature that is easily accessible for the player, so they can decide on preference, without having to select control preference from a menu item.

That said, my thoughts are making an invisible target object that moves in direction of the mouse relative to the player. I would like to restrict directions to just 4 quadrants. I can't remember which part of Soh Cah Toa I need to use for this from Pythagoras.

I also have the idea, I want to restrict free camera movement, to the line of sight of the player. As in in darkness their limited night vision of 60 ft for instance restricts the camera to such a distance. I want the player to be able to right click and free drag the camera away from the player.

I could use some help with this and greatly appreciate any advice. Thank you.
 
R

robproctor83

Guest
For moving the player with the mouse, you just need to check which quadrant the mouse is in to determine which direction they should move. You can add an invisible move target if you like, but that isn't necessary and will likely lead to other issues so I wouldn't do that unless absolutely necessary or some other reason I don't know. But, when the user clicks their mouse will be in one of 4 direction quadrants to the player, so you just need to use point_direction(player_x,player_y,mouse_x,mouse_y) to get the direction that they clicks, and then just do something like if(dir < 45 || dir > 315) //they clicked right to see which quadrant it is in. Then, once you know the direction you just increase the speed in that direction by whatever the player speed is. I'm not sure that type of movement would be ideal with the mouse, but maybe it won't be so bad.

Regarding the free camera, if your using gms2 I would suggest using cameras. I don't have any code for you, but to get a good working system with what your asking is going to be tough. You could make an invisible object follow the mouse and then the camera follow that object, but you are going to need to fix a couple other issues with that. For example, when it switches form player to mouse follow unless you want the camera to instantly jump to the mouse you will need to animate the transition. The other issue is that you have to put a clamp around the player so that the camera can't pan past the player (unless you want that). So ya, good luck.
 
Y

Yogen

Guest
thank you so much. this isn't going to be so hard I feel. I was browsing my algorithms book and thought of using some tree algorithm for finding edges of sight
 
Top