Hi i'm trying this code but it tells me: java.lang.IllegalArgumentException : bound must be positive...
It's at line 29.. I want to get a randomNumber from 0 to i, I don't see how it could be negative. Thank you for helping^^
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | import greenfoot.*; import java.awt.Color; public class Deformator extends SmoothMover { Color [][] pixels = new Color[ 140 ][ 50 ]; private int counter; GreenfootImage deformation = new GreenfootImage( 140 , 50 ); public Deformator() { counter = 0 ; } public void act() { movements(); for ( int i = 0 ; i< 140 ; i++) { for ( int j = 0 ; j< 50 ; j++) { pixels [i][j] = getWorld().getColorAt( this .getX()- 70 +i, this .getY()- 25 +j); } } for ( int i = 0 ; i< 140 ; i++) { for ( int j = 0 ; j< 50 ; j++) { deformation.setColorAt( 139 -i, 49 -j, pixels[Greenfoot.getRandomNumber(i)][j]); setImage(deformation); } } } public void movements() { if ( this .getX()> 70 ) { move(- 1 ); } } } |