The Daily Click ::. Forums ::. Klik Coding Help ::. top-down mouse controlled scrolling

Post Reply  Post Oekaki 

Posted By Message



VIP Member
19th September, 2007 at 14:54:32 -

I've got the player controlled using the arrow/wsad keys. Aiming is done with the mouse. This setup should be familiar with just about everyone.

I want it so the camera is always centered at a point between the player and the cross-hairs. Furthermore, that cross-hairs cannot move beyond a certain distance away from the player.

I've successfully completed this aiming/scrolling system but its extremely imperfect. The biggest problem is if the player attempts to move the mouse beyond the fixed radius, everything starts shaking and rotating towards 0 degrees.

If theres some sort of established way of doing this that I'm not aware of, please share.





Evil Faker

19th September, 2007 at 15:39:24 -

if the distance between the cross-hair and player is less than the maximum distance, allow it to move and rotate, otherwise just make it rotate on the fixed radius using trigonometry.

X position: rcos(a)
Y position: rsin(a)
(relative to the player)

"r" is the maximum radius and "a" is the angle between the player and the crosshair.

My signature is never too big!!!

Post Reply



Worth A Click