This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
2
copy Rect() issues, am I derping?
Post Body
This should be simple. I have a list of Rect
s. I need the final Rect
, that will contain them all.
code https://github.com/ninmonkey/pygame-demos.git
If you un-comment line #165 it will print and draw the error. Somehow full.height
grows every loop. It should be local only to that function, and not be a reference. I tried full = Rect(self.rect)
and full = self.rect.copy()
but neither seem to work.
def _calc_offset(self):
# offsets for each line. Place each rect below the previous.
#full = Rect(self.rect)
full = self.rect.copy()
prev = Rect(self.rect)
for t in self.text_lines:
print(" line = ",full)
t.rect.topleft = prev.bottomleft
prev = t.rect.copy()
full = full.union(t.rect)
# verify containment
print("full.size=", full.size)
#print("self.size=", self.rect.size)
#bug: this line causes full to increase height every loop
#self.rect = full.copy()
if debug: pygame.draw.rect(self.screen, Color("pink"), full, 1)
if debug: pygame.draw.rect(self.screen, Color("green"), self.rect, 1)
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 11 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/pygame/comm...