I dont have any code because im pretty lost


1 2 3 4 5 6 7 8 9 | /** chase */ // the first code line below does what is described in the following commented lines // determine shortest turn direction to face chased // int angleDiff = getRotation()-(int)(Math.atan2(dy, dx)*180/Math.PI); // range: -359 to 359 // int anglet = (angleDiff+360+180)%360-180; // range: -180 to 179 (sign is turn direction) // turn and move // turn(16*rate*(int)Math.signum(anglet)); turn( 16 *rate*( int )Math.signum((getRotation()-( int )(Math.atan2(dy, dx)* 180 /Math.PI)+ 540 )% 360 - 180 )); move(rate/ 8 , getQR()); // between 'move(0.1)' to 'move(0.4)' for a non-QActor, which is not possible |
1 2 | private GreenfootImage originalImage; private int imageSizePct = 100 ; |
1 2 3 4 | public Fish() { originalImage = getImage(); } |
1 2 3 4 5 6 7 | public void grow( int pctChange) { imageSizePct += pctChange; GreenfootImage img = new GreenfootImage(originalImage); img.scale(img.getWidth()*imageSizePct/ 100 , img.getHeight()*imageSizePct/ 100 ); setImage(img); } |
1 | public MyWorld() |
1 | new Fish() |
1 | Fish fish = new Fish(); |
1 | addObject( new Fish(), 0 , 0 ); |