Hi, I'm programming a game. It is a fake Pokémon. But I seem to have a little problem. My charachter won't stop moving if I hit a tree or house. Could you help me out please?
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 | { if (Greenfoot.isKeyDown ( "up" ) || Greenfoot.isKeyDown ( "w" )) { setLocation(getExactX(), getExactY()-moveSpeed); setImage( "roodkapjeachter.gif" ); if (isTouching(Tree. class )) { move( 0 ); } } if (Greenfoot.isKeyDown ( "down" ) || Greenfoot.isKeyDown ( "s" )) { setLocation(getExactX(), getExactY()+moveSpeed); setImage( "roodkapjevoor.gif" ); if (isTouching(Tree. class )) { move( 0 ); } } if (Greenfoot.isKeyDown ( "left" ) || Greenfoot.isKeyDown ( "a" )) { setLocation(getExactX()-moveSpeed, getExactY()); setImage( "roodkapjelinks.gif" ); if (isTouching(Tree. class )) { move( 0 ); } } if (Greenfoot.isKeyDown ( "right" ) || Greenfoot.isKeyDown ( "d" )) { setLocation(getExactX()+moveSpeed, getExactY()); setImage( "roodkapjerechts.gif" ); if (isTouching(Tree. class )) { move( 0 ); } } } } |