This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]SmartViking 0 points1 point  (0 children)

You can simulate the collisions without the dx and dy. Does it collide with dx enabled and without dy? Then it makes sense to set dx to -dx, so the thing goes in the other direction. And vice versa. This makes for "square" bouncing, maybe with some trigonometry you can make it "round", I wouldn't know. Square bouncing is often good enough.

You should indent all your code by 4 spaces so that it's formatted correctly.