Log In    Hi everyone,
I'm currently working on a game where multiple enemies (cubes) spawn in the corners of the screen, and then move towards the player. I also have what I call patterns, that are large rectangles moving along the screen. So I made this function that make the enemies collide with the pattern and bounce off it.
My problem is that some enemies just go through the pattern, or sometimes the opposite, bounce way too fast.
How would you guys handle stuff like this ?

 ```-- this is called each frame when updating the enemies -- r.x, r.y, r.w, and r.h are respectively the patterns location, width and height -- dx and dy is the patterns directions -- x,y, and s are respectively the enemies position and size -- vx, and vy are the enemies velocity on each axis if x+vxr.x+dx and y+s>r.y+dy and y+vyr.x+r.w then vx=abs(vx)*1.15 end if y+vyr.y+r.h then vy=abs(vy)*1.15 end end -- this is to try and set a maximum value to the bounce vx=min(abs(vx),bouncecap)*sgn(vx) vy=min(abs(vy),bouncecap)*sgn(vy)```
P#66353 2019-08-04 11:16