only check a certain part of a sprite for collisions

6 views
Skip to first unread message

Allen Lowe

unread,
Jul 20, 2010, 3:04:36 AM7/20/10
to rab...@googlegroups.com
I don't want the top half of my main sprite to collide with anything, if I lower the bounding_radius, it cuts collision area off of all sides. if I use aabb_collide, it collides perfectly around the whole box, any ideas???

Allen Lowe

unread,
Jul 21, 2010, 3:32:00 PM7/21/10
to Rabbyt

I suppose I could use a seperate sprite for the characters head, and
then use a little bit of math to keep them together in every frame.
But that adds a WHOLE lot of complexity because of how my character
works. I'd like to avoid doing that, any ideas anyone?

Allen Lowe

Matthew Marshall

unread,
Jul 21, 2010, 8:23:08 PM7/21/10
to Rabbyt
Your best bet is to do a more detailed collision check yourself, after
the rabbyt collision has done a more general check.

The main idea behind the rabbyt collision functions is this: If you
have X number of characters and Y number of obstacles, then you have
X*Y number of checks to do, which can be quite slow if you do a
detailed check for each one in pure python. So you first to a
bounding box (or bounding circle) collision check with rabbyt (which
is fast) and only do your detailed, pure-python check on the results
of the first check.

Another option: You aren't limited to passing sprites to the collision
function. Instead of passing your character sprite, create any object
with top, left, bottom, right attributes that correspond to the shape
you want.

Hope that helps.

MWM

Francesco Pischedda

unread,
Jul 22, 2010, 5:07:26 AM7/22/10
to rab...@googlegroups.com
a simple solution could be to setup three fake rectangles to define
the edges that you need (left,right, bottom) for the head and do the
collision tests using them

2010/7/22 Matthew Marshall <mat...@matthewmarshall.org>:

> --
> You received this message because you are subscribed to the Google Groups "Rabbyt" group.
> To post to this group, send email to rab...@googlegroups.com.
> To unsubscribe from this group, send email to rabbyt+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rabbyt?hl=en.
>
>

--
"Rendete ogni cosa il più semplice possibile, ma non di più" (Albert Einstein)

"You are what you choose today, not what you've chosen before"

"Unix IS user friendly. It's just selective about who its friend are"

Reply all
Reply to author
Forward
0 new messages