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 - Sir Lulzalot

Pages: [1]
1
Feature requests / Re: VertexArray color attribute
« on: December 20, 2013, 07:19:57 pm »
There's no simpler solution, you have to iterate over all the vertices. Or color them in a shader.

I figured, thanks for the response! It's not a major thing, it's just pretesting before my graphic artist gets to work.

2
Feature requests / VertexArray color attribute
« on: December 20, 2013, 06:44:15 pm »
I'm currently using a VertexArray to allow the user to draw objects based on where they brush the cursor. Unfortunately for testing purposes I need to either toss a texture or shader to the RenderWindow::draw function if I want to differentiate which stroke is which since I want stroke count to both matter and which stroke does what matter as well.

If I want to change the color of a stroke currently, it'd either be the above method or iterating through the entire VertexArray changing the color of every vertex.

Maybe I'm wrong and I'm missing the simple version somewhere, but this would be a lovely addition.

3
You can use the size attribute of an object (more easily rectangles/squares) to determine where a character can be placed when colliding with other objects.

For example if you collide from the left (therefore your character is moving to the right) remember your point of origin is always top left. So you'd want your character's position to be objectCollided.getPosition().x-character.getPosition().x (maybe add a -1 depending on how you treat collisions) and the y coordinate can be exactly as it was before.

4
General / Using Mouse Position to Draw [SOLVED]
« on: December 20, 2013, 03:53:08 pm »
So I'm fairly new to SFML, but I've been pouring over the API documentation to try and understand perhaps where I went wrong in this design.

I'm attempting to integrate the user's mouse to draw symbols/objects on the screen. But currently when I draw the lines drawn are off from where the mouse pointer actually is. The drawing is consistent though, in that it's following exactly my motions. It just needs to not be off to the side as it is now.

Here's some code that would answer more questions than my words would.

//in main.cpp
        sf::Mouse theMouse;
        sf::Vertex thePoint;
        //All DigiDraw currently contains is a VertexArray named drawnArray.
        DigiDraw theDrawing;
        thePoint.position.x = (float)sf::Mouse::getPosition(window).x;
        thePoint.position.y = (float)sf::Mouse::getPosition(window).y;
        if(sf::Mouse::isButtonPressed(sf::Mouse::Left)){
            theDrawing.fillArray(thePoint);
        }
       window.draw(theDrawing.getArray());
//in digidraw.cpp
sf::VertexArray DigiDraw::fillArray(sf::Vertex thePoint){
    this->drawnArray.append(thePoint);
    return this->drawnArray;
}
 

 All I'm trying to do is get it to match the pointer exactly which I suppose should be in relation to the desktop not the window. I don't think floating the ints of a Vector2i to be put into a Vector2f should be causing this. Usually the drawing is only off on the x coordinate.

EDIT: Further testing reveals that as the pointer gets closer to the left side of the window, the difference of x axis position of what is drawn approaches the pointer's position.

EDIT2: So I removed the window relation I accidentally put in, but now it is consistently is down and to the left.

EDIT3: So I tested under fullscreen conditions and it's accurate there, which makes me think that maybe not being window relative is problematic. I readded the window relation but the x axis problem is still there.

EDIT4 (THE FIX): So apparently Video Mode for the window is the marauder here, I was at 1500,500 and decided to change it to 1000,500, and apparently my machine had modified the 1500,500 size to fit its screen, causing the erroneous result.

Pages: [1]
anything