Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    JonathanZwiebel
    @JonathanZwiebel
    ok that seems to be one iteration through your stars
    so instead of having many many else if blocks
    You should log out next time
    @andrewqho
    yes
    what to do?
    JonathanZwiebel
    @JonathanZwiebel
    you could have a method where you enter the star count
    else if(17 <= starCount && starCount < 22){
                    for(int i = 0; i < 10; i++){
                        if(i%2 == 0){
                            px[i] = (int) (Math.cos(2.19911486+((i-1)*angle1))*ri)+(int)(.126*width)+(int)((starCount-17)*.126*width);
                            py[i] = (int) (Math.sin((2.19911486+((i-1)*angle1)))*ri)+(int)(.054*height*4);
                        }
                        else{
                            px[i] = (int) (Math.cos((Math.PI/2)+(i*angle1))*ro)+(int)(.126*width)+(int)((starCount-17)*.126*width);
                            py[i] = (int) (Math.sin(((Math.PI/2)+(i*angle1)))*ro)+(int)(.054*height*4);
                        }
                    }
                    g.fillPolygon(px,py,10);
                }
    these are literally the same with the exception of one number
    the 17 in place of the 11
    You should log out next time
    @andrewqho
    YES
    LIKE A GOD
    JonathanZwiebel
    @JonathanZwiebel
    so you make a method that does that except instead of the 11 or the 17
    you call it 'swag'
    int swag;
    You should log out next time
    @andrewqho
    int swag?
    wtf does that mean?
    JonathanZwiebel
    @JonathanZwiebel
    and then you can set swag using a big if else block
    so instead of those two things you have above
    you could have
    if(swag < 17)
    for(int i = 0; i < 10; i++){
    if(i%2 == 0){
    px[i] = (int) (Math.cos(2.19911486+((i-1)angle1))ri)+(int)(.126width)+(int)((starCount-swag).126width);
    py[i] = (int) (Math.sin((2.19911486+((i-1)
    angle1)))ri)+(int)(.054height4);
    }
    else{
    px[i] = (int) (Math.cos((Math.PI/2)+(i
    angle1))ro)+(int)(.126width)+(int)((starCount-swag).126width);
    py[i] = (int) (Math.sin(((Math.PI/2)+(iangle1)))ro)+(int)(.054height4);
    }
    }
    g.fillPolygon(px,py,10);
    }
    woops
    if(starCount < 17)
    swag = 11;
    else
    swag = 17;
    for(int i = 0; i < 10; i++){
    if(i%2 == 0){
    px[i] = (int) (Math.cos(2.19911486+((i-1)angle1))ri)+(int)(.126width)+(int)((starCount-swag).126width);
    py[i] = (int) (Math.sin((2.19911486+((i-1)angle1)))ri)+(int)(.054height4);
    }
    else{
    px[i] = (int) (Math.cos((Math.PI/2)+(iangle1))ro)+(int)(.126width)+(int)((starCount-swag).126width);
    py[i] = (int) (Math.sin(((Math.PI/2)+(iangle1)))ro)+(int)(.054height4);
    }
    }
    g.fillPolygon(px,py,10);
    }
    like that
    it sets the 'swag' at the top and then uses it
    throughout
    You should log out next time
    @andrewqho
    oh ok
    i'm not going to to do that now, but that's good for later I guess
    because I'm a god
    but i'm a lazy god
    JonathanZwiebel
    @JonathanZwiebel
    i was a lazy god
    and i regretted it
    so much homework today
    ok cya
    You should log out next time
    @andrewqho
    ok bye
    lol
    the struggle
    thanks though