You could use anglelerp(350, 20, 0.5) to take into account wraparound.

If you're using 2:1 (width to height) isometric then here's a way to get it to bounce correctly:

1. first if you use the bounce action with events you can get the the before and after angles which then can be used to calculate the surface angle. A simple formula to calculate the bounce is "angle_out = 2*surface_angle - angle_in", which can be manipulated to "surface_angle = (angle_in + angle_out)/2".

2. That angle is the visual angle. To get the iso angle you take the angle and convert it to x and y components with trig. x=cos(angle), y=sin(angle). If we double the y then use the angle() expression on that it should give us the corrected surface angle. Basically "new_angle = angle(0, 0, cos(old_angle), 2*sin(new_angle))".

As an example looking at the image in the op, the bottom left edges of the diamonds are at 45 and 26.2 degrees. Then using the formula above we can convert 26.2 to 45.

3. Once we have the corrected surface angle we can calculate the bounce angle again with "angle_out = 2*surface_angle - angle_in". Completed pseudo example below:

- Code: Select all
`number ang_in=0`

number ang_out=0

number ang_surface=0

on ball collides with wall

--- set ang_in to ball.angle

--- ball: bounce off wall

--- set ang_out to ball.angle

--- set ang_surface to (ang_in+ang_out)/2

---set ang_surface to angle(0,0,cos(ang_surface), sin(ang_surface)*2)

--- ball: set angle to 2*ang_surface-ang_in

One caveat is the result isn't quite perfect because the bullet behavior seems to calculate an approximate surface angle. In my test it calculates the bottom left edge as 27.5 degrees instead of 26.5. As a side note it should be 26.5 because atan(y/x) or antan(1/2) is approximately 26.5. Anyways to get more precise surface angles we need to find the angle ourselves.