### 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.

### Topics - mathme

Pages: [1]
1
##### General / Angle between two vectors
« on: July 16, 2013, 09:37:22 pm »
I have been trying out different methods all day to calculate the angle between 2 vectors. I've browsed countless forums and read way too many stackoverflow questions. No matter what method I implement I keep getting the same result.

The angle I'm getting is only good in the bottom right quadrant of the player, and is only exactly correct at 45 degrees.

I've tried the dot product way with acos, I've tried the atan2 method with delta X and delta Y. I just can't seem to get a working function.

The goal is to be able to aim a bullet from the player to the mouse.

Does anyone have a function that works to do this?

2
##### Graphics / VertexArray of points
« on: July 04, 2013, 12:28:10 am »
I am making a vertexArray of points to draw my map. Each point is a pixel on the screen.

drawArray.setPrimitiveType(sf::Points);
drawArray.resize((ScreenHeight * ScreenWidth));
int size = 0;
for(int x = 0; x < ScreenWidth; x++)
{
for(int y = 0; y < ScreenlHeight; y++)
{
if(MapVector[x][y].isPixel)
{
sf::Vector2f pixelPos(x,y);
drawArray[size].color = sf::Color::Magenta;
drawArray[size].position = pixelPos;
size++;
}
}
}

Then at the end of populating this vertexArray called "drawArray" I draw it to the screen just using window.draw(drawArray)

Any ideas on why this just gives me a black screen?

3