So i am making a farmer game, and i have this problem..
I took the trick-the-turtle scenario, and renamed the "tryEat" method to "collect".
I have 3 actors.. a Farmer, a House and Grain.
I wan't the player to control the farmer and go out and harvest some grain, and when the farmer has collected 20 grain, he is full and has to go store the grain in the house.
It all works, except he won't drop off the grain when he is at the house.
The problem is probably at the buttom of the code.
Help please (:
import greenfoot.*; public class Farmer extends Animal { private int grainCollected = 0; private int grainStored = 0; public void act() { if (Greenfoot.isKeyDown("D") ) { if (Greenfoot.isKeyDown("S") ) { setRotation(45); move(1); } else if (Greenfoot.isKeyDown("W") ) { setRotation(315); move(1); } else { setRotation(0); move(1); } } else if (Greenfoot.isKeyDown("A")) { if (Greenfoot.isKeyDown("S") ) { setRotation(135); move(1); } else if (Greenfoot.isKeyDown("W") ) { setRotation(225); move(1); } else { setRotation(180); move(1); } } else if (Greenfoot.isKeyDown("S")) { setRotation(90); move(1); } else if (Greenfoot.isKeyDown("W")) { setRotation(270); move(1); } if (canSee(Grain.class)) { if (grainCollected < 20) { collect(Grain.class); grainCollected ++; } if (canSee(House.class)) { grainStored = grainCollected + grainStored; grainCollected = 0; } } } }