monele wrote:Somehow... if we could do something like this :
Code: Select all
show marin smile at Position(xpos=400, ypos=220)
marin bubbles "Hey, over here!"
and have the bubble "attach" itself to the marin sprite (it fetches its position)... Mmm... we would need a way to give the type of bubble too... and a way to tell if it starts on the left, right, top, bottom of the marin sprite.
My first thought was similar - to tie the display of graphics to the character (I know, I know, I've gone on about this before...) in a descendant class of Character specially for use with speech bubbles - and have a 'head point' defined for each character sprite. Then, when you position the bubble, you can work out the angle from the centre of the bubble to the relevant character's head point and composite in the tail in that direction. If you draw the black of the outline as a filled ellipse, then draw a filled-black tail, then draw the white inner bubble over the top and the filled-white tail over that, compositing should be relatively easy. As a cute bonus, the tail would rotate around the edge of the bubble to follow a character that was moving from a non-moving bubble, or vice versa.
As an extension to that, you could perhaps have a collection of curved tail graphics that are chosen either randomly or based on the relative height/distance between the edge of the bubble and the character's head (and/or draw your own on the fly, I don't know what PyGame's curve-drawing is like), which are defined relative to the end-angle and the necessary ellipse radius to fit them in...
...or, if you're defining the point of each character's head and carrying that information around anyway (and have a vague idea of the space characters occupy by the bounding rectangle of their sprite), you could probably (with a lot more work) look ahead through the scene to see how many speech bubbles are going to be drawn before the next cleardown, work out how much space each one will take given the size of the font you're using, string them out evenly across the scene starting at the top-left and working to the bottom-right, zig-zagging down-left/right to lay the bubbles for each 'page' out... but that'd probably get really complicated fast if you were also moving elements around, and would need some kind of override for authors who wanted to place their own anyway...
You could probably get away with just assuming that the head comprises the top 1/4 of the sprite and is relatively central in most current cases, but the more you go for the above-style floating-comic-panels look the less likely that is to be the case, I guess.