That was a very simplified version of it i'll admit but take for example update();
So if you created the boulders with different positions
1 2 3 4 5 6
| for(int i = 0; i < 3; i++) { Boulder b = new Boulder(this); b.setX(i*10); b.setY(i*10); boulders.add(); } |
Above would put them all in a diagonal line across your screen
Then for update Boulder would contain something like:
1 2 3 4
| public void update() { x += 1; y += -1; } |
of course in real world you would calculate velocity of the boulders instead of just move them across the screen.
Then to draw you would loop through them all like before and call draw:
1 2 3
| public void draw(Graphics g) { g.drawImage(image,x,y,width,height); } |
Oh by update and draw i mean the update and draw in your game loop