I know that you have to use getbackground () drawline for a straight line with the world class if I understand it but I do not know how to start it
Thank you for your help


1 | getBackground().drawPolygon( int [] { 5 , 10 , 15 , 20 }, int [] { 25 , 30 , 35 , 40 }, 5 ); |
1 | getWorld().getBackground().drawLine(getX(), getY(), getX()+dx, getY()+dy); |
1 2 3 4 5 | if (Greenfoot.mouseMoved( null )) { MouseInfo mouseInfo = Greenfoot.getMouseInfo(); setLocation(mouseInfo.getX(), mouseInfo.getY()); } |
1 | getWorld().getBackground().drawLine(getX(), getY(), getX()+dx, getY()+dy); |
1 2 3 4 5 6 7 | if (Greenfoot.mouseMoved( null )) { MouseInfo mouseInfo = Greenfoot.getMouseInfo(); int x=getX(), y=getY(), dx=mouseInfo.getX()-x, dy=mouseInfo.getY()-y; getWorld().getBackground().drawLine(x, y, x+dx, y+dy); setLocation(x+dx, y+dy); } |