I'm currently trying to draw a simple polygon onto the screen. As of now I can't see anything on the screen.
I also need the xPoints and yPoints to be adjustable. How can I achieve that?
Will I have to reconstruct the MyWorld class in order for the new xPoints and yPoints to be visible? I don't want them to only update on construction of the World.
Inside of my Screen class, I have this code
And the MyWorld constructor is as follows:
1 2 3 4 5 6 7 8 | public void DrawScreen() { GreenfootImage screen = new GreenfootImage( 300 , 200 ); screen.setColor(Color.RED); int [] xPoints = { 0 , 0 , 10 , 10 }; int [] yPoints = { 10 , 0 , 0 , 10 }; screen.drawPolygon(xPoints, yPoints, 3 ); this .setImage(screen); } |
1 2 3 4 5 6 | public MyWorld() { super ( 600 , 400 , 1 ); Screen screen = new Screen(); screen.DrawScreen(); } |