   Sprite (player) move to mouse
  This is my first post, I'm sorry if its in the wrong section.I am working on a game called Swarm (its a very simple 2D game). The goal of the game is to avoid other sprites and eventually you will changed into the next level.So far I have my background drawn and my player sprite is also drawn in the center of the screen. So I was wondering how I could make it so my player moves to the mouses coordinates without clicking (basically I just hover my mouse and the sprite follows). I am using SDL and C++ using Bloodshed DEV-C++ v4.9.9.2. I am a complete beginner and am working off tutorials so far its working. If you require any information please do ask.To sum it up I need the sprite to rotate and while it moves (the sprite is a rectangle). I am reluctant to use arrows keys it may constraint movement, but if it is better I will be willing to try.   
  You can ask for the mouse position whenever you see fit: (Stolen from the SDL docs)int mouse_x, mouse_y;SDL_PumpEvents();  SDL_GetMouseState(&mouse_x, &mouse_y); Knowing the current position, orientation and velocity of your sprite and the updated destination (mouse_x and mouse_y), animation should be trivial. Do you know about the atan2 function in the standard library?   ;You can ask for the mouse position whenever you see fit: (Stolen from the SDL docs)int mouse_x, mouse_y;SDL_PumpEvents();  SDL_GetMouseState(&mouse_x, &mouse_y); Knowing the current position, orientation and velocity of your sprite and the updated destination (mouse_x and mouse_y), animation should be trivial. Do you know about the atan2 function in the standard library?Thanks for replying, I mean I know how to solve the problem in my had you know like get a basic understanding of what I have to type up. For example if I wanted to make it so my player hits a enemy he loses health I can think that up. The only problem is I don't know the actually code and syntax to use (ex. SDL_PumpEvents) I don't know what it will do, but some are self explanatory. Do you know how I could actually learn the code or is that just basic practice. Also learning terminology helps me a lot.   ;  If I understand you correctly then you are saying you know that you need a gameobject for your box in the middle of the screen. And then you poll the SDL event system for the position of the x , y of your mouse. and then update your gameobject(x , y ) to the same (x , y ) of your mouse. YOu just want a better understanding of how the things like the SDL API polls events and just the API calls in general. If that is the case then good things to do is use the SDL Docs/Refrence as a good point to read on. Also you can check out tutorials like SDL tutorials or Lazy Foo SDL tutorials. Also you can read other peoples code and see how they do things and it can help with understanding how/why to use certian API features and or coding practices.I hope that helps.   