Using Java to Rotate an Object to Face the Mouse

Introduction: Using Java to Rotate an Object to Face the Mouse

If you have ever used Java's 2D API you probably have wanted to know how to make a character face your mouse. So you got on google and looked it up and guess what? THERE ARE NO RELEVANT RESULTS! Ah. So I spent an hour figuring out how to use trig to do just this in Java.

Step 1: Build a Simple Game

Ok simply use Java to make a JFrame called mainFrame. I made it its own class but you dont have to. Next make a Paint class. It should read-