Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

100 Neutral

About LewisElliott

  • Rank
  1. I've done this and it doesnt work: http://pastebin.com/4HYTe6Yx it rotatates them but not in the right direction and some of them dissapear when they reach the center of the screen, might just give up on this. Before I do though, I'm calling that in the draw method which is called as many timers a second as possible, is that right?
  2. Thanks for the reply free world. I've been told I need to find the length, as the velocity is constantly updating. Also I want them to face the way they are travelling not just to face the coordinates of an object on the screen, which makes things a little more difficult? I will try that tomorrow dpadam, but my lecture said once I normalise the vector I take that and multiply it by the velocity, to get a unit vector, then pass that into atan2?
  3. Thanks for the reply, Having spoken with my lecturer he has confirmed with me I need to find the length of my vectors then use this to find the unit vector, then put that into atan2. So I'm using this to find the length: [font="Arial,"]public double length(Vector2d pV){ return Math.Sqrt(pV.X * pV.X + pV.Y * pV.Y);}[/font]and then in my draw: [font="Arial,"][/font][font=Arial,]double angle = 180.0 / 3.14 * Math.Atan2(bug.getVel().length(bug.getVel()) * bug.getVel().Y, bug.getVel().length(bug.getVel()) * bug.getVel().X);[/font] To find the unit vector I'm taking the length, then multiplying it by the current velocity.X or velocity.Y. Is that right? I've got a little more information here: http://stackoverflow.com/questions/8478259/rotating-an-image-to-face-the-direction-its-travelling-in-atan2-and-unit-vecto
  4. Thanks for the reply, presuming his currentWeapon is the weapons position I would have to do this: [font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"]double[/font][/font][/font][font="Consolas"][font="Consolas"] angle = 180.0 / 3.14 * [/font][/font][font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"]Math[/font][/font][/font][font="Consolas"][font="Consolas"].Atan(bug.getPos()-> bug.getVel().Y, bug.getPos()->bug.getVel().X); But that is giving me an error, how would I implement what you just said into that? I can use getPos to do: bug.getPos().X bug.getPos().Y Which returns the current X and Y values. Cheers [/font][/font]
  5. [font="Consolas"][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"]double[/font][/font][/font][font="Consolas"][font="Consolas"] angle = 180.0 / 3.14 * [/font][/font][font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"][font="Consolas"][color="#2b91af"]Math[/font][/font][/font][font="Consolas"][font="Consolas"].Atan(current_weapon-> bug.getVel().Y , current_weapon-> bug.getVel().X); [/font][/font][/font] What is: [font="Consolas"]current_weapon[/font] and what does: [font="Consolas"]-> mean?[/font] Cheers
  6. As I'm updating the position every second this won't work, I need to do the atan2 of the unit vectors of (getVelocity.Y, getVelocity.X). I just don't understand how to do that?
  7. “@DannyIrwin: @lewiselliott tune.” permission to turn it up? How're you feeling today?
  8. Pre lecture breakfast at spoons and there are already people drinking in here ...
  9. [font="Consolas"][font="Consolas"]Hi, I'm trying to make an image face the direction its going in. I'm using c sharp and opengl. I store both my bugs position and velocity as 2d vectors. Now I constantly update the position of the bug (as I cant see a way around that, can you?) so I think I need to do atan2 on the unit vectors of the velocity vector y, and velocity vector x, convert it to degrees, then rotate the bug by that but it hasn't been working, so I removed it. Can anyone show me how to do that? At the moment I'm trying to do that in the draw method in the world class, but I'm struggling with the unit vector part, does anyone have any suggestions/ input on how I could do this or a better way to do this? Here is my relevant code: http://pastebin.com/SH7NAu35 Thanks for your time, Lewis.[/font][/font]
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!