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 - Wanderer

Pages: [1]
1
Graphics / Custom Shape - VertexArray - reposition are not correct
« on: October 31, 2016, 05:10:35 pm »
Hi, I am new with sfml and have problem.
I create array with random numbers and it will be reprent by graph. If array will have 100 numbers there will be 100 random nubers. Each rectangle represent the array number. If array[1] have number 2, rectangle is small, if array[2] have number 20 (and if this is maximum number), then rectangle will have maximum height.
Graph is created with CustomShape and VertexArray - all that is working.
I try control each rectangle individualy and it works.

And now I want create live graph when algorythm will be computing, graph will be changend realtime. But I have problem with it, I have code something like that:

// outside is code for compare array[A] > array[B]
//and when A > B is true then this code is executed.

p = i *4; // position of A
p2 = z * 4; // position of B

// this rectangle will be moved to the right
arrayObject[p].position += sf::Vector2f(x, 0); // x = width of graph / count of rectangles
arrayObject[p+1].position += sf::Vector2f(x, 0);
arrayObject[p+2].position += sf::Vector2f(x, 0);
arrayObject[p+3].position += sf::Vector2f(x, 0);

// this rectangle will be moved to the left
arrayObject[p2].position += sf::Vector2f(-x, 0); // x = width of graph / count of rectangles
arrayObject[p2+1].position += sf::Vector2f(-x, 0);
arrayObject[p2+2].position += sf::Vector2f(-x, 0);
arrayObject[p2+3].position += sf::Vector2f(-x, 0);
Resul it strange, not all rectangles are moving to the desired position. I think not all rectangles are moved.
I checked algorythm for comparing number, and this algorythm is right, result is numbers from 0 to higher.
Is there something I make wrong?

Pages: [1]