Developers' Diary



The text box rendering system in Soft Landing is fairly complex. We have some conversation bubbles that offset themselves with a bit of randomness, to get your eyes moving around the scene just a little bit, so you’re not just staring at one point on the screen all day. We also resize the bubbles to be just the right height to accommodate the amount of text they need to hold. Once such movements and resizings have happened, we need to move the pygame Rect for the bubble’s text bounds so that it matches the new Rect for the whole Guy. For a while I was doing this like so: =

Simple, and it worked fine. Then last night, I made a small change to a seemingly unrelated part of the code for such Interface Guys, and the textRect simply stopped responding to such assignments. I could move the textRect around by giving it absolute positions, but it simply wouldn’t move for the main Rect. It took a long while to troubleshoot, and I ended up with this ugliness:

self.textRect = self.textRect.move(self.rect.centerx - self.textRect.centerx, self.rect.centery - self.textRect.centery)

Not pretty, but it works fine. I have run into a few weird situations like this with pygame, and I suppose I should report them, but I’m not sure how much help it would be without providing the whole project to the developer. But it’s fun to track down such problems and keep trying various approaches until the code works. Coding is fun because there’s always some other way to come at the problem, some way to *make* it work.

Anyway, getting these refinements into the novel system means there are pretty much no significant system changes to make for the demo. We just have to get the content into the game. Ah, wait, we still need to figure out how bosses should fall apart when you shoot them…

One response to 'Centering'.

Comments and pings are currently closed for 'Centering'.
  1. 1 pimento
    Posted on April 2nd, 2007 at 3:18. About 'Centering'.

    Miniature toast squares.