Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Create rectangle from two points  (Read 1095 times)

0 Members and 1 Guest are viewing this topic.

The Strangled Bear

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Create rectangle from two points
« on: November 17, 2013, 05:07:33 am »
Hi.
I can't seem to create a RectangleShape using simply two points to define it. I can define one point as it's position, (thereby defining it's top left corner) but that only gets me halfway.

Specifically I am trying to implement a drag box for a simple RTS game, so it would be very convenient to create the box from just two mouse positions (the inital mouse position, and the position where the mouse is currently), which I already have variables for.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Create rectangle from two points
« Reply #1 on: November 17, 2013, 10:10:31 am »
rectangle.setSize(p2 - p1);
Laurent Gomila - SFML developer