I am making a maze game, how can I make my actor go to the start (specific x and y coordinates) when they touch the wall (which in this case is a png black outline under actor not world)


1 | if (isTouching(Wall. class )) setLocation(specificX, specificY); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | public void act() { movement(); checkWalls(); } public void movement() { if (Greenfoot.isKeyDown( "right" )) move( 3 ); turn( 90 ); if (Greenfoot.isKeyDown( "down" )) move( 3 ); turn( 90 ); if (Greenfoot.isKeyDown( "left" )) move( 3 ); turn( 90 ); if (Greenfoot.isKeyDown( "up" )) move( 3 ); turn( 90 ); } public void checkWalls() { if (isTouching(Maze1. class )) setLocation( 481 , 360 ); } |