[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Rect borders



Hello all,
I have a question for the community, I am a bit puzzled  :

The last element of a list is the length of the list minus one :

a = range(4)

a[len(a)-1] == 3

True

But for a rect, the last element of a line is length of the line :

import pygame

a = pygame.Rect(0,0,5,5)

a.right != a.width-1

True


a.right

5


Why a.right is not 4 (i.e a.width-1 ) ?

recI find this confusing :

a = pygame.Rect(0,0,5,5)

c = a.topleft

b = a.bottomright

a.collidepoint(b)

False

a.collidepoint(c)

True



I know this is documented but I don't understand the reasons behind this behavior.
And I like to understand the stuff that have bitten me. ;)


So, any input ?
L.