Rocks generating from foreground and background.

With correct speeds and intervals.

I'm gonna change the concept though, I think making the interaction by
clicking will work better for this project in particular.
Rocks only come from the background.

Changing the concept to a First Person Arcade Style