[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Collision bounds smaller than sprite image



Yeah, the more I think about it, the more I think that creating a
second rect and storing it as an attribute is the way to go.  All of
the graphical adjustments and movements will be performed with the
normal rect attribute, and the actual collision and bounds tests will
be done with the collision_rect.  I guess it's not really that hard,
but I was really exhausted after writing a strip -> cel routine :D


On Wed, 29 Dec 2004 03:32:20 -0500, Matt Bailey <mattb@xxxxxxxxxx> wrote:
> Well, it would be. Make the rect an attribute of the object. So instead
> of putting "object.rect" into a collision list (where "object" is our
> sprite), you'd put maybe "object.solid_rect" in the list instead (you'd
> get solid_rect by copying the main rect and mod'ing it as needed....or
> arbitrarily defining it from a custom rectstyle). Or if you needed the
> main sprite instance for stuff in the collision detection in addition to
> just the collision rect, you could add the whole sprite and hence allow
> access to any attribute you want (like, maybe some objects in your game
> would still be using the main render rect as the collide rect).
> 
>                           -Matt Bailey
> 
> andrew baker wrote:
> 
> >Well, that's kinda what I'm talking about, but I'm more thinking like
> >the collision rect should be contained within the object instance.
> >But, yeah, I like that distinction: collision_rect & render_rect.
> >
> >
> >On Wed, 29 Dec 2004 02:54:59 -0500, Matt Bailey <mattb@xxxxxxxxxx> wrote:
> >
> >
> >>Howdy Andrew,
> >>
> >>  I've been giving this a bit of thought recently, as I will need to be
> >>shifting the collision rect from where the render rect is on background
> >>tiles for my 2D side scroller. I haven't tackled it yet, but right now
> >>whenever I do collision detection I get all "solid" rects from a
> >>list......I figure in my sprite classes of tiles that have solid rects,
> >>I'll just make another rect and append it to the "solid rect" list
> >>instead of appending the sprite's "default" rect. I'm sure others have
> >>more "tested" methods, I'm eager to hear what anyone else has on this as
> >>well. :)
> >>
> >>             -Matt Bailey
> >>
> >
> >
> 
> 


-- 
Andrew Ulysses Baker
"failrate"