Pixel Movement

by Forum_account
Pixel Movement
A pixel movement library for isometric and top-down maps.
ID:313602
 
Keywords: bump
I'm trying to make bouncy walls using bump(). However, a problem occurs when you bump into two walls at the same time (by bumping into the met corners of two): your velocity is flipped twice.

I can think of a couple ways to solve this, but none are particularly simple, i.e. they would probably create new bugs.
The library didn't always behave this way. When it started to detect both bumps I remember thinking about making the library only call bump once. I decided against it because it'd ignore some bumps - if you create a wall that causes damage when you bump into it, certain situations wouldn't register.

I ultimately left it in there. For this effect you can do something like this:

mob
bump(atom/a, d)
if(d == SOUTH && vel_y < 0)
vel_y *= -1


That way if you bump two walls, only the first time is vel_y < 0 so it only flips your velocity once.

The alternative is to change the library. The only thing I can think of is to have bump() and bumped() events - the library would call mob.bump(SOUTH) when you bump something in that direction and the default behavior would call atom.bumped(mob, SOUTH) for all the objects you bumped into.
Just for future reference, the solution I went with is the first. The alternative seems like a lot more unnecessary work put into the core.