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.


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
Graphics / Sprite masking with shader
« on: July 02, 2013, 03:20:02 am »
I have a tile map that I randomly generate using a vertex array. I have been wanting to add in destructible terrain, so I read http://en.sfml-dev.org/forums/index.php?topic=7427.15 which seemed promising. I've been messing around for a while trying to get a demo working, but can't seem to implement it correctly.

Could anyone give me the general flow of how to use RenderTexture and this Shader to change a map made from a vertexArray? Any hints in the right direction would be greatly appreciated.

Even a simple example without using a vertexArray would be helpful. Thank you.

Pages: [1]