Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - DarthBuzzKill

Pages: [1]
1
General / Re: Making a sprite rotate in the direction of the mouse position
« on: November 21, 2014, 12:47:55 pm »
Thanks a bunch Arcade! It's finally working now, I actually ran into another problem which was that my mouse position was relative to the screen and not the window, but now that that's fixed it's working.

2
General / Re: Making a sprite rotate in the direction of the mouse position
« on: November 21, 2014, 12:27:33 am »
Once you have a vector that represents the difference between the sprite and mouse position, you could then calculate the angle of the hypotenuse.

Hint 1: look for TOA.
Hint 2: you'll probably need atan (inverse tangent).
So you're talking about the vector going from the sprite to the mouse position, right? I'm still confused on what the 2nd vector needs to be, because obviously you need 2 vectors.

So if I'm using the dot product:
angle = atan2(distanceVectorY, distanceVectorX) - atan2(vectorY, vectorX));

I don't understand what the 2nd vector in the 2nd atan2() has to be defined as. It can't be a velocity vector or a unit vector, so what kind of vector should it be?

3
General / Making a sprite rotate in the direction of the mouse position
« on: November 21, 2014, 12:13:21 am »
So I need to narrow down just how to do this.

I keep seeing different answers which confuse me.

So I assume this means I need to create 2 vectors, one that goes from the sprite to the mouse position, and another that is the unit vector of the sprite, and then work out the cross product, and then get the angle using the cross product.

Is that correct? Or can I also use the dot product to find the angle? From what I've gathered, the Dot Product only takes two vectors that are in the (X, Y) format and are not unit vectors. This is what confuses me about the dot product, because I can only see how to calculate 1 vector when using dot instead of cross. with cross I simply use a unit vector in addition to the other vector. Whereas with dot you apparently can't use a unit vector to find the angle. So in that case, what other vector do I need to calculate, so I can find the angle between that one and the one going to the mouse position.

To add on, what I'm trying to say is: What vectors do I need to create and what product do I need to use to find the angle between those vectors?
The way I see it, no matter which product, I need a distance vector from the sprite to the mouse position. But the 2nd vector seems to differ between the 2 products. So what should the 2nd vector be?

Also, I wouldn't be surprised if thor had some functions to handle all this easily, but I want to do it manually at first.

4
General / How do I represent a mathematical 2D Vector in SFML C++?
« on: November 19, 2014, 06:43:36 pm »
Newbie question I know, but how do I do this in SFML? Since SF::Vectors are not mathematical vectors, just placeholders for multiple parameters.

5
General / Rotating the Y Axis with the rotation of a Sprite (C++)
« on: November 17, 2014, 09:09:49 pm »
How would I go about doing this in SFML? So if I have a ship that rotates, it's missiles should fire based on it's direction. If I can't rotate the Y axis with the sprite, what other method could I use to achieve this?

6
Thanks for the link. I actually fixed it anyway since I added to OpenAL32.dll file to the same folder as the .exe.

7
Full message as follows:

The program can't start because OpenAL32.dll is missing from your computer. Try reinstalling the program to fix this problem.   

This happened when I included the audio library and correctly setup a sound to play after placing it into my project's folder. Even after removing the audio file from the project folder and the audio library, it still gives me the error. Any suggestions?

I am using SFML 2.1

Pages: [1]
anything