so for school i have to make a little red riding hood game and most of it is working but... there are trees in the game and the wolf can't go through the tree, it needs to turn to another direction when it hits/sees the tree. so in my wolf class act i now have this:
but now the wolf just does a 180 and i want the wolf to turn to a random direction. The wolf already turns at the world edge to a random direction with:
but if i try the getRandomNumber with if (isTouching(Tree.class)) it doesn't work. Sorry if this is a dumb question i'm still learning. I tried to search the internet but i'm lost.
thanks.
if (isTouching(Tree.class)){ setRotation(180); }
public void turnAtEdge() { int max=90; if(atWorldEdge()) { if(getX() > 570) { max = getRandomNumber(180,200); } if(getY() > 570) { max = getRandomNumber(260,290); } if(getY() < 30) { max = getRandomNumber(60,80); } if(getX() < 30) { max = getRandomNumber(-30,30); } setRotation(max); } }