41
42
|| <a href=Rect.html>Rect</a> ||
42
43
<a href=Sound.html>Sound</a> ||
43
44
<a href=Surface.html>Surface</a> ||<br>
44
<br>|| <a href=pygame_cursors.html>cursors</a> ||
45
<a href=pygame_sprite.html>sprite</a> ||
46
<a href=pygame_version.html>version</a> ||<br>
45
<br>|| <a href=pygame_color.html>color</a> ||
46
<a href=pygame_cursors.html>cursors</a> ||
47
<a href=pygame_sprite.html>sprite</a> ||<br>
49
50
</td></tr></table></td></tr></table>
58
59
Rect contains helpful methods, as well as a list of
59
60
modifiable members:
60
top, bottom, left, right, topleft, topright,
61
bottomleft, bottomright, size, width, height,
62
center, centerx, centery, midleft, midright, midtop,
63
midbottom. When changing thesemembers, the rectangle
61
<table border="0" cellspacing=0 cellpadding=0 width=66%><tr valign=top><td align=left><ul><li>top<li>bottom<li>left<li>right</ul></td>
62
<td align=left><ul><li>topleft<li>topright<li>bottomleft<li>bottomright</ul></td>
63
<td align=left><ul><li>midleft<li>midright<li>midtop<li>midbottom</ul></td>
64
<td align=left><ul><li>center<li>centerx<li>centery</ul></td>
65
<td align=left><ul><li>size<li>width<li>height</ul></td>
67
When changing these members, the rectangle
64
68
will be moved to the given assignment. (except when
65
69
changing the size, width, or height member, which will
66
70
resize the rectangle from the topleft corner)
68
72
The rectstyle arguments used frequently with the
69
73
Rect object (and elsewhere in pygame) is one of
70
the following things. First, an actual Rect
71
object. Second, a sequence of [xpos, ypos, width,
72
height]. Lastly, a pair of sequences, representing
73
the position and size [[xpos, ypos], [width,
74
height]]. Also, if a method takes a rectstyle
75
argument as its only argument, you can simply pass
76
four arguments representing xpos, ypos, width,
75
<table border=0 cellspacing=0 cellpadding=0 width=80%>
76
<tr align=left valign=top><td align=left valign=middle width=20%><blockquote> </blockquote></td><td align=left valign=top><ul>
77
<li>an actual Rect object.
78
<li>a sequence of [xpos, ypos, width, height].
79
<li>a pair of sequences, representing the position and size [[xpos, ypos], [width,height]].
80
<li>if a method takes a rectstyle argument <b>as its <i>only</i> argument</b>, you can simply pass four arguments representing xpos, ypos, width, height.
81
</ul>and perhaps most importantly:
82
<ul><li>A rectstyle argument can also be <b><strong>_any_ python object</b> with an attribute named <b>'rect'.</b></strong>
83
</ul></td></tr></table>
181
195
begin with, you will get a rectangle with 0 size.
182
196
</ul><br> <br>
198
<a name=collidedict><font size=+2><b>collidedict
199
</b></font><br><font size=+1><tt>
200
Rect.collidedict(dict if rectstyle keys) -> key/value pair
202
Returns the key/value pair of the first rectangle key
203
in the dict that overlaps the base rectangle. Once an
204
overlap is found, this will stop checking the
205
remaining list. If no overlap is found, it will
208
Remember python dictionary keys must be immutable,
209
Rects are not immutable, so they cannot directly be,
210
dictionary keys. You can convert the Rect to a tuple
211
with the tuple() builtin command.
214
<a name=collidedictall><font size=+2><b>collidedictall
215
</b></font><br><font size=+1><tt>
216
Rect.collidedictall(rectstyle list) -> key/val list
218
Returns a list of the indexes that contain
219
rectangles overlapping the base rectangle. If no
220
overlap is found, it will return an empty
223
Remember python dictionary keys must be immutable,
224
Rects are not immutable, so they cannot directly be,
225
dictionary keys. You can convert the Rect to a tuple
226
with the tuple() builtin command.
184
229
<a name=collidelist><font size=+2><b>collidelist
185
230
</b></font><br><font size=+1><tt>
186
231
Rect.collidelist(rectstyle list) -> int index