There are multiple ways to make your game function how you want. My game has similar mechanics just side scroller instead of top to bottom, here's what I did.
2 backgrounds the size of your screen (the image should start and end matching so you can seamlessly put them onto the end of each other. Stack one on top of the other and pin them together. Move them upwards, which will give your ship the appearance of going down. When 1 back ground is completely above the page, unpin them, and move the top to the bottom, re-pin, repeat.
As for randomly generating set system || variable = int(random(100)+1) would give you a number 1 to 100. You can do it based on time Every x seconds where x is 1-3 seconds create a obstacle - these can be random too. Make several different obstacles and throw a throw a random check for 1 to (total number of obstacles) if 1 create x else if 2 create y etc. Then set the starting location and either pin it to the background or set its move or bullet speed more than that of the background to make it moving toward the player or less to move it away.
I believe this is one of the videos I used on the background creation:
youtube.com/watch