Help: rain type effect

Questins

*questions

I am wondering if anyone has a code that makes a rain type effect that…

A) makes triangles or lines fall from the ceiling

B) allows for collisions with a sprite

Hey Ldsguy1. The code example called “Bit Invader” may have what you are looking for. It has a kind of star-field simulation running as the background of the scene. You could inspect the code to see what generates the white streaks the fall from the top of the screen. You could make them look like rain I think.

Well I don’t want it for the rain. I would like say sharp rocks falling from the ceiling and the goal is to dodge them. Should I just work with that same class? How would I track if a guy touches them or not?

The easiest way to track collisions is to simply look at coordinates.

For example, if you had a Vec2 representing both rock and person, then you could just check the distance between the two of them to see if they’ve collided. It’s not a pixel v. pixel solution, but it’s fast and makes it easy to test multiple objects quickly.

In code, something like: if math.abs(man.x - rock.x) < 10 and math.abs(man.y, rock.y) <10 then…

Would give you a simple check.

Sounds like I need to study more before I embark on this project then. Ok thanks for the help.