Hi guys. Coming to the end of a game I am writing but I have hit a problem. The robot will move and fuel will be used, and then the program is to test whether their is a person in the same square to be picked up, if there is space in the robot's passenger bay. If not then it cannot pick anybody up. It then adds one to the score if you pick someone up, and then has to test if the robot is at the basecamp, and if it is, it has to drop off the passengers it is carrying so it can go and pick up more.
Here is the code for the relevant sections:
Any ideas????
public void passengerpickuptester(){ Actor person; //tests to see if there is a person on the same square person=getOneObjectAtOffset(0,0,person.class); if(person != null) { //there is a person on that square testifcanpickuppassenger(); //go and see if there is space to pick up a passenger } else{ //there is not a person in that square atbasecamp(); //go see if you are at the basecamp } } public void testifcanpickuppassenger() { Actor person; person=getOneObjectAtOffset(0,0,person.class); if(passengerscarrying<maximumcarrying){ World world; world=getWorld(); world.removeObject(person); passengerscarrying=passengerscarrying+1; scoringpassengers(); //score for the passenger you just picked up } else{ atbasecamp(); } } public void scoringpassengers(){ world worldWorld = (world) getWorld(); //counter2 shows how many passengers you are currently carrying at the bottom of the screen Counter2 counter2 = worldWorld.getCounter2(); counter2.bumpCount2(1); atbasecamp(); } public void atbasecamp(){ Actor basecamp; //this is the problem - when the robot lands on the basecamp it doesn't drop off passengers basecamp=getOneObjectAtOffset(0,0,basecamp.class); if(basecamp != null) { //there is a person on that square if(passengerscarrying>0){ world worldWorld = (world) getWorld(); Counter2 counter2 = worldWorld.getCounter2(); counter2.bumpCount2(-1); //need to sort this passengersleft=passengersleft-1; passengerscarrying=passengerscarrying-1; //basecampunload(); } else{ wintester(); } } else{ //there is not a person in that square wintester(); } }