I'm trying to create a loop that will paint 300 random stars(2 pixel dots) onto my World subclass Space. I'm finding it impossible to understand Loops without any Layman's terms (on the internet) explaining what the code means or stands for. So far I have:
...I'm not so much interested in the answer, but the path to finding it. Any help would be appreciated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | public Space() { super ( 600 , 400 , 1 ); GreenfootImage background = getBackground(); background.setColor(Color.BLACK); background.fill(); createStars(); } public void createStars() { GreenfootImage background = getBackground(); background.setColor(Color.BLACK); background.fill(); background.setColor(Color.WHITE); background.fillOval(Greenfoot.getRandomNumber( 600 ),Greenfoot.getRandomNumber( 400 ), 2 , 2 ); } |