This site requires JavaScript, please enable it in your browser!
Greenfoot back
compex
compex wrote ...

2018/3/19

Need help with program?

compex compex

2018/3/19

#
Hi, I have to make a program that involves a bunch of blue and red circles spawning in, but the catch is the red circles have to form a shape of a circle in the corner of the screen Like this here's the code I have right now
public void getrandom(){
        int x=Greenfoot.getRandomNumber(1001);
        int y=Greenfoot.getRandomNumber(1001);
        double d=Math.sqrt((x*x)+(y*y));
 
        for(int i = 0; i<100; i++) {
            if(d <= 1){
            blue_dot Blue = new blue_dot();
            getWorld().addObject(Blue, x,y);
            Blue.setImage(red);
            inside_d++;
            
        }else{
         blue_dot Blue = new blue_dot();
         getWorld().addObject(Blue, x,y);
         
         
            
            
        
    }}
}
danpost danpost

2018/3/19

#
It looks like you are placing 100 Blue_dot objects at the same location (on top of each other) in the world (whether their image is "red" or not). Either there is movement code missing or your logic/code is skewed.
compex compex

2018/3/19

#
danpost wrote...
It looks like you are placing 100 Blue_dot objects at the same location (on top of each other) in the world (whether their image is "red" or not). Either there is movement code missing or your logic/code is skewed.
Actually they all spread out across the world I just need help getting the red objects to form the half circle
danpost danpost

2018/3/19

#
compex wrote...
Actually they all spread out across the world I just need help getting the red objects to form the half circle
What is the for loop supposed to accomplish?
You need to login to post a reply.