I am not sure what I am doing wrong.
Here is what I am trying to get:
but I am getting this instead:
The code I have is:
sf::ConvexShape *Temp = new sf::ConvexShape( 6 );
Temp->setPoint( 0 , sf::Vector2f( 0 , 0 ) );
Temp->setPoint( 1 , sf::Vector2f( 20 , 0 ) );
Temp->setPoint( 2 , sf::Vector2f( 20 , 40 ) ); //for some reason its assigning 20 , 30 instead
Temp->setPoint( 3 , sf::Vector2f( 40 , 40 ) );
Temp->setPoint( 4 , sf::Vector2f( 40 , 60 ) );
Temp->setPoint( 5 , sf::Vector2f( 0 , 60 ) );
When I'm saying squares below I'm talking about a 20 x 20 square top right corner
The first point would be 0 squares over and 0 squares down so 0 , 0
The second point would be 1 square over 0 squares down so 20 , 0
The third point would be 1 square over 2 squares down so 20 , 40
The fourth point would be 2 squares over 2 squares down so 40 , 40
The fifth point would be 2 squares over and 3 squares down so 40 , 60
the sixth point would be 0 squares over and 3 squares down so 0 , 60
The point that seems to be getting messed up is the 3rd point it is supposed to be at 20 , 40 but for some reason it looks like it is at 20 , 30. When I output the point though it says it is at 20 , 40 so I am really confused.
Here is complete code:
#include <SFML/Graphics/Shape.hpp>
#include <SFML/Graphics/ConvexShape.hpp>
#include <SFML/System/Vector2.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Window/VideoMode.hpp>
#include <SFML/Window/Event.hpp>
#include <iostream>
class Tetrominio
{
public:
Tetrominio( void ){}
virtual ~Tetrominio( void ){}
void Draw( sf::RenderWindow &Window ){ Window.draw( *Shape ); }
protected:
sf::Shape *Shape;
};
class L : public Tetrominio
{
public:
L( void );
~L( void );
};
L::L( void )
{
sf::ConvexShape *Temp = new sf::ConvexShape( 6 );
Temp->setPoint( 0 , sf::Vector2f( 0 , 0 ) );
Temp->setPoint( 1 , sf::Vector2f( 20 , 0 ) );
Temp->setPoint( 2 , sf::Vector2f( 20 , 40 ) );
Temp->setPoint( 3 , sf::Vector2f( 40 , 40 ) );
Temp->setPoint( 4 , sf::Vector2f( 40 , 60 ) );
Temp->setPoint( 5 , sf::Vector2f( 0 , 60 ) );
std::cout << "Third point: " << Temp->getPoint( 2 ).x << ',' << Temp->getPoint( 2 ).y << std::endl; //testing the point
Temp->setOrigin( 10 , 50 );
Temp->setPosition( 320 , 200 );
Shape = Temp;
}
L::~L( void )
{
if( Shape )
delete Shape;
}
int main()
{
const int Width = 640 , Height = 400 , BPP = 32;
const std::string Title = "Test";
sf::RenderWindow Window( sf::VideoMode( Width , Height , BPP ) , Title );
L test;
test.Draw( Window );
Window.display();
sf::Event Event;
while( Window.isOpen() )
{
while( Window.pollEvent(Event) )
{
if( Event.type == sf::Event::Closed )
Window.close();
}
}
}
---
Third point: 20,40
Any suggestions would be greatly appreciated