anonymousse wrote...
That worked thank you. If I would change the dimensions to 'super(24, 24, 25), would that mean that my cells are in a dimension of 25 then?

1 2 | super ( 8 , 8 , 125 ); for ( int y= 0 ; y< 8 ; y++) for ( int x= 0 ; x< 8 ; x++) |
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 | public void act() { move(); } public void move() { move( 0 ); if (Greenfoot.isKeyDown( "left" )) { move(- 1 ); } if (Greenfoot.isKeyDown( "right" )) { move( 1 ); } // setRotation( 90 ); if (Greenfoot.isKeyDown( "up" )) { move(- 1 ); } if (Greenfoot.isKeyDown( "down" )) { move( 1 ); } setRotation( 0 ); } } |
1 2 3 4 5 6 7 8 9 10 11 | public void move() { String key = Greenfoot.getKey(); int dx = 0 , dy = 0 ; // the offsets from current location if ( "up" .equals(key)) dy--; if ( "down" .equals(key)) dy++; if ( "left" .equals(key)) dx--; if ( "right" .equals(key)) dx++; setLocation(getX()+dx, getY()+dy); // check for illegal movement here and reset location adding negative offsets } |