python - How to Use the Pygame Rect -


i have been experimenting pygame, , have come across problem not find answer to. in this paste, basic game framework exhibited. how can complete ballsnapleft() definition correctly?

edit: not looking code completed, looking explain how 'rect' class(?) works, , how applied.

edit2: have tried use x , y coordinates so, think there simpler way can work, instead of using brute coordinates.

from making games python , pygame:

myrect.left int value of x-coordinate of left side of rectangle.

myrect.right int value of x-coordinate of right side of rectangle.

myrect.top int value of y-coordinate of top side of rectangle.

myrect.bottom int value of y-coordinate of bottom side.

because of these attributes return integers, that's why code isn't working.

also, if goal ballsnapleft() move ball position away player, ballrect.right = playerrect.left - distance change x coordinate of rect. make ball move in y coordinate like

def ballsnaptop():     ballrect.top = playerrect.bottom - distance 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -