• entries
246
175
• views
154483

# rebounds - Membrane Massacre

137 views

To HopeDagger:

i've been analyzing collisions in your game and i don't have any reasonable answer to what you're doing, yet. its obvious to me that your ship's collision shape is a circle. you've made it so that the ship's collision circle can eat the walls of the map in certain circumstances:

- you can fly through very thin bits of wall
- if you fly very close to a wall, you can eat it a little bit as you fly by

i can smooth a corner by just flying along it. when i go fullbore at a wall and drift into it, i bounce off in a direction that isn't usually unreasonable. how the hell are you doing that?! i honestly can't figure it out. the reason i haven't ever done a game like this is because i could never figure out a good way to guess the rebound direction. i know how to check to see IF you're touching, and i know how to get a rebound angle if the wall is represented with vectors, but i could never figure out a decent way to guess what the wall's angle was with bitmaps.

i think you mentioned that you hadn't either.

the solution is to figure out what the normal of the surface you'd be rebounding off of would be, right? i'm guessing at a possible solution here, but lets pretend we can figure out an average point of contact between our sphere and the wall. lets take a small area around that point and look at the bitmap data there. for every solid wall pixel in that area, we could make a vector from the pixel to the ship's center, couldn't we? lets suppose we did that and we took an average of those vectors and pretended that it was the perpendicular to the wall.. using our original average point and this new perpendicular, would that be unreasonable to figure out the reflection vector with?

there's no way for me to know unless i actually write a test and see it with my own eyes. maybe that'll be tomorrow's exercise ^_^

[edit:

a couple of last thoughts before bedtime. scattered pixels would try to average themselves into a wall, so thats something i have to look at too. just ploughing through loose pixels and erasing them isn't an unreasonable solution to me.. you must be using the contact area sum as a part of the rebound/erase decision..]

You could use edge detection to figure out either the perpendicular or the parallel vectors of the walls - I use that in my vision research. Although I haven't fully analysed Membrane Massacre to reverse engineer what HopeDagger is doing (been too busy working on my own game [smile]), I figure he's using some sort of boolean mask for the walls, so if you can gain access to the data you can use a simple edge detector to run over that mask to get the perpendicular vector field (that's just an array of vectors) of the edges. You'd have to redo the vector field when the environment changes though, at least for the bit that's changed.

I don't know how well it would work in practice - although I've coded up Canny edge detectors for reasonably fast applications I've never tried using it in a game. Probably worth a try though.

Oooh, it's even easier than you think. You'll have to wait for the post-mortem. [smile]

(But you're right on about using a contact area sum :P)

## Create an account

Register a new account