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

Author Topic: Question about Rect  (Read 2042 times)

0 Members and 1 Guest are viewing this topic.

SFMLNewGuy

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Question about Rect
« on: July 30, 2019, 07:38:11 am »
Hello,

I am currently reading a book called SFML Game Development. (pg. 76) (talks about view bounds)

When they talk about initializing the world, of course, as a rectangle upper-left lies at (0, 0). How come getting the top + height gets you the bottom right corner and height doesn't just return it? If I 'cout' the height, it is the dimension of the image, so I'm lost.

I came across this and I thought about collision detection, where you add left+width or top+height during bounds checking. Can anyone explain this further, I'd like to understand it better?

Thanks!


Geheim

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Email
Re: Question about Rect
« Reply #1 on: July 30, 2019, 03:43:22 pm »
Lets say your body height is 1.8m. If you now jump, your height doesn't change, right? However your top position does and if you add your height to it, you get to the bottom. It's the same thing with rects.

Collision works exactly like you said and is already implemented as you can see in the tutorials. Is there anything specific that you do not quite understand?
Failing to succeed does not mean failing to progress!

SFMLNewGuy

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Question about Rect
« Reply #2 on: August 07, 2019, 07:02:57 am »
Apology! I forgot I asked about this. I just found this bookmark. Thanks for the help, that is exactly what I needed to hear.

Cheers!