This site requires JavaScript, please enable it in your browser!
Greenfoot back
mattjames
mattjames wrote ...

2013/9/12

Help please!

1
2
mattjames mattjames

2013/9/26

#
Hi again guys! Changed the code slightly so in its current state it will work and reduce the counter, however it is the square above the basecamp (which is at 6,3). So, I increase the required value by one, however now it doesnt work, and when you inspect locationytwo it is still at 2, even tho intY (location) is equal to three. Please help.
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class robottrackslarge here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class robot extends Actor //need to score passengers, add second level
{
    private int choice;
    public void addedToWorld(World w)  
    {  
        world worldWorld = (world) w;  
        Counter3 counter3 = worldWorld.getCounter3(); 

        choice = counter3.getCount();  
    }  
    private Counter2 theCounter2;
    private Counter theCounter;
    public int maximumcarrying=0; //maximum the robot can carry
    private int score=0;
    private int scorelevelone=150;//this sets the score
    private int scoreleveltwo=150;
    private boolean win=false;
    private int targetscore; //may need to remove this
    private int level=1;
    private int passengersleft=4; //number of passengers the robot needs to drop off
    private int passengerscarrying=0; //number of passengers the robot is carrying
public int locationX;
public int locationY;
public boolean tester;
public boolean testertwo=false;
public int locationxtwo;
public int locationytwo;

    /**
     * Act - do whatever the robot wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {

        maximumcarryingsetter();// Add your action code here.
    }  
    //maybe try using a boolean to see whether the game has been won

     public void maximumcarryingsetter(){ //this will decide whether to keep the counter at 150 or lower it to 130
        if (choice==1){
            maximumcarrying=1;
             wintester();

        }
        if (choice==2){
                        maximumcarrying=2;
             wintester();

        }
        if (choice==3){
                        maximumcarrying=3;
            wintester();

        }
        if (choice==4){
                        maximumcarrying=1;
            wintester();

        }
        if (choice==5){
                       maximumcarrying=2;
            wintester();

        }
        if (choice==6){
                        maximumcarrying=3;
            wintester();

        }
        if (choice==7){
                        maximumcarrying=1;
            wintester();

        }
        if (choice==8){
                        maximumcarrying=2;
            wintester();

        }
        if (choice==9){
                        maximumcarrying=3;
            wintester();

        }

    }
    public void setcounter(){ //this will decide whether to keep the counter at 150 or lower it to 130
        if (level==2){

            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-20);
            scoretester();
        }
        else{
            scoretester();

        }

    }

    public void wintester(){ //this will test if the game is won
        if(win==false){
            scoretester();

        }
        else{
            win=false;
            setcounter(); //set the counter to 130 then begin level two

        }

    }

    public void scoretester(){ //this part checks to see that the game hasnt been won yet and links to wintester()
        world worldWorld = (world) getWorld();
        Counter counter = worldWorld.getCounter();

        if (passengersleft==0&&counter.getCount()>0){
            win=true;
        }
        else if(counter.getCount()<1&& 
        passengersleft>0){
            //display failure code and send to main menu.

        }
        else if(counter.getCount()>0&&
        passengersleft>0){
            canmove();

        }

    }

    public void canmove(){
        int locationy =getY();
        int testedlocationy;
        testedlocationy=locationy+1;

        if(testedlocationy>9){

            movementnotdown();

        }
        else{
            movement();
        }
    }

    public void movement()
    {
        if(Greenfoot.isKeyDown("right"))
        { 

            move(1);
            Greenfoot.delay(10);
            floortesterIce();

        }
        else if(Greenfoot.isKeyDown("left"))
        {
            move(-1);
            Greenfoot.delay(10);
            floortesterIce();

        }
        else if(Greenfoot.isKeyDown("up"))
        {
            setLocation(getX(),getY()-1);
            Greenfoot.delay(10);
            floortesterIce();

        }
        else if(Greenfoot.isKeyDown("down"))
        {
            setLocation(getX(),getY()+1);
            Greenfoot.delay(10);
            floortesterIce();
        }
    }

    public void movementnotdown()
    {
        if(Greenfoot.isKeyDown("right"))
        {
            move(1);
            Greenfoot.delay(10);
            floortesterIce();

        }
        else if(Greenfoot.isKeyDown("left"))
        {
            move(-1);
            Greenfoot.delay(10);
            floortesterIce();
        }
        else if(Greenfoot.isKeyDown("up"))
        {
            setLocation(getX(),getY()-1);
            Greenfoot.delay(10);
            floortesterIce();
        }

    }

    public void floortesterIce()
    {
        Actor Ice;    
        Ice=getOneObjectAtOffset(0,0,Ice.class);
        if(Ice != null) {
            //this needs to go

            scoringmovementice();

        }
        else{
            floortestergrass();
        }
    }

    public void floortestergrass()
    {
        Actor grass;    
        grass=getOneObjectAtOffset(0,0,grass.class);

        if(grass != null) {

            scoringmovementgrass();

        }
        else{
            floortesterrock();
        }
    }

    public void floortesterrock()
    {
        Actor rock;    
        rock=getOneObjectAtOffset(0,0,rock.class);

        if(rock != null) {

            scoringmovementrock();

        }
        else{
            canmove();
        }
    }

    public void scoringmovementgrass(){

        if (choice==1){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-3);
            passengerpickuptester();

        }
        if (choice==2){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-4);
            passengerpickuptester();

        }
        if (choice==3){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-5);
            passengerpickuptester();

        }
        if (choice==4){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-3);
            passengerpickuptester();

        }
        if (choice==5){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-4);
            passengerpickuptester();

        }
        if (choice==6){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-5);
            passengerpickuptester();

        }
        if (choice==7){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-1);
            passengerpickuptester();

        }
        if (choice==8){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-2);
            passengerpickuptester();

        }
        if (choice==9){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-3);
            passengerpickuptester();

        }

    }

    public void scoringmovementrock(){

        if (choice==1){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-3);
            passengerpickuptester();

        }
        if (choice==2){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-4);
            passengerpickuptester();

        }
        if (choice==3){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-5);
            passengerpickuptester();

        }
        if (choice==4){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-3);
            passengerpickuptester();

        }
        if (choice==5){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-4);
            passengerpickuptester();

        }
        if (choice==6){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-5);
            passengerpickuptester();

        }
        if (choice==7){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-2);
            passengerpickuptester();

        }
        if (choice==8){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-3);
            passengerpickuptester();

        }
        if (choice==9){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-4);
            passengerpickuptester();

        }
    }
    public void scoringmovementice(){

        if (choice==1){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-1);
            passengerpickuptester();

        }
        if (choice==2){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-2);
            passengerpickuptester();

        }
        if (choice==3){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-3);
            passengerpickuptester();

        }
        if (choice==4){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-3);
            passengerpickuptester();

        }
        if (choice==5){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-4);
            passengerpickuptester();

        }
        if (choice==6){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-5);
            passengerpickuptester();

        }
        if (choice==7){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-3);
            passengerpickuptester();

        }
        if (choice==8){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-4);
            passengerpickuptester();

        }
        if (choice==9){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-5);
            passengerpickuptester();

        }
    }
    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();
        }
        else{ //there is not a person in that square
            atbasecamp();

        }
        
    }

    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 counter2 = worldWorld.getCounter2();
        counter2.bumpCount2(1);
        atbasecamp();

    } 

    public void atbasecamp(){
        testertwo=true;
         locationytwo =getY();


         locationxtwo =getX();



        Actor Basecamp;    
        Basecamp=getOneObjectAtOffset(0,0,Basecamp.class);
        if(locationxtwo==6&&locationytwo==2) { //works if you set the y to two but one above the needed square.
            //there is a basecamp on that square
             tester=true;
             System.out.println("hello");
            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();

        }
    }
//Basecamp != null
    //public void basecampunload(){ this is all old i just dont want to lose it yet :-(
        //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();

       // }

    //}

}
danpost danpost

2013/9/26

#
I am, or you, or neither, a little confused; would not the square above the basecamp be 6,1 if the basecamp was as 6,2 ?
mattjames mattjames

2013/9/26

#
Sorry, the basecamp is at 6, 3, the code above shows it working when it drops them off at the square above.
danpost danpost

2013/9/26

#
For an example of how the code can be simplified, the following method is equivalent to yours:
public void maximumcarryingsetter()
{
    maximumcarrying = (choice+2)%3+1;
    wintester();
}
Your 'scoringmovement...' methods can be simplified the same way using an 'if' statement to adjust, for example:
public void scoringmovementgrass()
{
    int bump = -((choice+2)%3+3);
    if (choice > 6) bump += 2;
    ((Counter)((world) getWorld()).getCounter()).bumpCount(bump);
    passengerpickuptester();
}
mattjames mattjames

2013/9/26

#
Those will save me a lot of code thank you!
mattjames mattjames

2013/9/27

#
Now can anybody fix the problem?
danpost danpost

2013/9/27

#
Post your latest (condensed) code. Maybe someone will be able to follow it better. I would also suggest that you remove all your scoringmovement... methods and all your floortester... methods and put them all together in one method called either floortester or scoringmovement . I came up with the following code for the class, however this does not contain your latest changes and still has the holes you had in your original post:
import greenfoot.*;

public class Robot extends Actor
{
    private int choice;
    private Counter2 theCounter2; // passengers carrying
    private Counter theCounter; // score
    public int maximumcarrying; //maximum the robot can carry
    private int scorelevelone = 150;//this sets the score
    private int scoreleveltwo = 150;
    private int level = 1;
    private int passengersleft = 4; //number of passengers the robot needs to drop off
    private int passengerscarrying = 0; //number of passengers the robot is carrying

    public void addedToWorld(World w)  
    {  
        world worldWorld = (world) w;
        theCounter = worldWorld.getCounter();
        theCounter2 = worldWorld.getCounter2();  
        choice = worldWorld.getCounter3().getCount();
        maximumcarrying = (choice+2)%3+1;  
    }

    public void act() 
    {
        scoretester();
    }

    public void scoretester()
    {
        if (passengersleft == 0 && theCounter.getCount() > 0)
        {
            level++;
            if (level==2) theCounter.bumpCount(-20);
            if (level == 3) Greenfoot.stop();
            setCounter();
        }
        else if (theCounter.getCount() < 1 && passengersleft > 0)
        {
            //display failure code and send to main menu.
        }
        else if (theCounter.getCount() > 0 && passengersleft > 0) movement();
    }

    public void movement()
    {
        int dx = 0, dy = 0;
        if (Greenfoot.isKeyDown("right")) dx++;
        if (Greenfoot.isKeyDOwn("left")) dx--;
        if (Greenfoot.isKeyDown("up")) dy--;
        if (Greenfoot.isKeyDown("down")) dy++;
        if (getY()+dy > 9) dy = 0;
        if (dx == 0 && dy == 0) return;
        setLocation(getX()+dx, getY()+dy);
        Greenfoot.delay(10);
        floortester();
        passengerpickuptester();
        atbasecamp();
    }

    public void floortester()
    {
        if (getOneObjectAtOffset(0, 0, Ice.class) != null)
        {
            int bump = -((choice+2)%3+1)-2;
            if (choice < 4) bump += 2;
            theCounter.bumpCount(bump);
        }
        else if(getOneObjectAtOffset(0, 0, grass.class) != null)
        {
            int bump = -((choice+2)%3+1)-2;
            if (choice > 6) bump += 2;
            theCounter.bumpCount(bump);
        }
        else if(getOneObjectAtOffset(0, 0, rock.class) != null)
        {
            int bump = -((choice+2)%3+1)-2;
            if (choice > 6) bump += 1;
            theCounter.bumpCount(bump);
        }
    }

    public void passengerpickuptester()
    {
        Actor person = getOneObjectAtOffset(0, 0, person.class);
        if (person == null) return;
        if (passengerscarrying < maximumcarrying)
        {
            getWorld().removeObject(person);
            passengerscarrying++;
            theCounter2.bumpCount2(1);
        }
    }

    public void atbasecamp()
    {
        Actor basecamp = getOneObjectAtOffset(0, 0, Basecamp.class);
        if (basecamp == null) return
        if (passengerscarrying > 0)
        {
            theCounter2.bumpCount2(-1); //need to sort this
            passengersleft--;
            passengerscarrying--;
        }
    }
}
fruitflies424 fruitflies424

2013/9/28

#
Hi Matt (I'm guessing that's your name). I have read through your issue and I am fairly certain it is the same/similar to one I have experienced before when using a grid system and location detection for altering variables. The most annoying element is that the code seems to compile because there is no error, and hence I believe it is logical. I have reworked your code and below is my version. On testing, I don't seem to find any problems with it. Let me know if you do. (If the problem persists, you may want to try the same code with a completely new project).
[code]import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class robottrackslarge here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class robot extends Actor //need to score passengers, add second level
{
    private int choice;
    public void addedToWorld(World w)  
    {  
        world worldWorld = (world) w;  
        Counter3 counter3 = worldWorld.getCounter3(); 

        choice = counter3.getCount();  
    }  
    private Counter2 theCounter2;
    private Counter theCounter;
    public int maximumcarrying=2; //maximum the robot can carry
    private int score=0;
    private int scorelevelone=150;//this sets the score
    private int scoreleveltwo=150;
    private boolean win=false;
    private int targetscore; //may need to remove this
    private int level=1;
    private int passengersleft=3; //number of passengers the robot needs to drop off
    private int passengerscarrying=0; //number of passengers the robot is carrying
public int locationX;
public int locationY;
public boolean tester;


    /**
     * Act - do whatever the robot wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {

        maximumcarryingsetter();// Add your action code here.
    }  
    //maybe try using a boolean to see whether the game has been won

     public void maximumcarryingsetter(){ //this will decide whether to keep the counter at 150 or lower it to 130
        if (choice==1){
            maximumcarrying=1;
             wintester();

        }
        if (choice==2){
                        maximumcarrying=2;
             wintester();

        }
        if (choice==3){
                        maximumcarrying=3;
            wintester();

        }
        if (choice==4){
                        maximumcarrying=1;
            wintester();

        }
        if (choice==5){
                       maximumcarrying=2;
            wintester();

        }
        if (choice==6){
                        maximumcarrying=3;
            wintester();

        }
        if (choice==7){
                        maximumcarrying=1;
            wintester();

        }
        if (choice==8){
                        maximumcarrying=2;
            wintester();

        }
        if (choice==9){
                        maximumcarrying=3;
            wintester();

        }

    }
    public void setcounter(){ //this will decide whether to keep the counter at 150 or lower it to 130
        if (level==2){

            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-20);
            scoretester();
        }
        else{
            scoretester();

        }

    }

    public void wintester(){ //this will test if the game is won
        if(win==false){
            scoretester();
            Thread.sleep(50000);

        }
        else{
            win=false;
            setcounter(); //set the counter to 130 then begin level two

        }

    }

    public void scoretester(){ //this part checks to see that the game hasnt been won yet and links to wintester()
        world worldWorld = (world) getWorld();
        Counter counter = worldWorld.getCounter();

        if (passengersleft==0&&counter.getCount()>0){
            win=true;
        }
        else if(counter.getCount()<1&& 
        passengersleft>0){
            //display failure code and send to main menu.

        }
        else if(counter.getCount()>0&&
        passengersleft>0){
            canmove();

        }

    }

    public void canmove(){
        int locationy =getY();
        int testedlocationy;
        testedlocationy=locationy+1;

        if(testedlocationy>9){

            movementnotdown();

        }
        else{
            movement();
        }
    }

    public void movement()
    {
        if(Greenfoot.isKeyDown("right"))
        { 

            move(1);
            Greenfoot.delay(10);
            floortesterIce();

        }
        else if(Greenfoot.isKeyDown("left"))
        {
            move(-1);
            Greenfoot.delay(10);
            floortesterIce();

        }
        else if(Greenfoot.isKeyDown("up"))
        {
            setLocation(getX(),getY()-1);
            Greenfoot.delay(10);
            floortesterIce();

        }
        else if(Greenfoot.isKeyDown("down"))
        {
            setLocation(getX(),getY()+1);
            Greenfoot.delay(10);
            floortesterIce();
        }
    }

    public void movementnotdown()
    {
        if(Greenfoot.isKeyDown("right"))
        {
            move(1);
            Greenfoot.delay(10);
            floortesterIce();

        }
        else if(Greenfoot.isKeyDown("left"))
        {
            move(-1);
            Greenfoot.delay(10);
            floortesterIce();
            Thread.sleep(5000);
        }
        else if(Greenfoot.isKeyDown("up"))
        {
            setLocation(getX(),getY()-1);
            Greenfoot.delay(10);
            floortesterIce();
        }

    }

    public void floortesterIce()
    {
        Actor Ice;    
        Ice=getOneObjectAtOffset(0,0,Ice.class);
        if(Ice != null) {
            //this needs to go

            scoringmovementice();

        }
        else{
            floortestergrass();
        }
    }

    public void floortestergrass()
    {
        Actor grass;    
        grass=getOneObjectAtOffset(0,0,grass.class);

        if(grass == null) {

            scoringmovementgrass();

        }
        else{
            floortesterrock();
        }
    }

    public void floortesterrock()
    {
        Actor rock;    
        rock=getOneObjectAtOffset(0,0,rock.class);

        if(rock == null) {

            scoringmovementrock();

        }
        else{
            canmove();
        }
    }

    public void scoringmovementgrass(){

        if (choice==1){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-3);
            passengerpickuptester();

        }
        if (choice==2){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-4);
            passengerpickuptester();

        }
        if (choice==3){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-5);
            passengerpickuptester();

        }
        if (choice!=4){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-3);
            passengerpickuptester();

        }
        if (choice==5){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-4);
            passengerpickuptester();

        }
        if (choice==6){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-5);
            passengerpickuptester();

        }
        if (choice==7){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-1);
            passengerpickuptester();

        }
        if (choice==8){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-2);
            passengerpickuptester();

        }
        if (choice!=9){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-3);
            passengerpickuptester();

        }

    }

    public void scoringmovementrock(){

        if (choice==1){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-3);
            passengerpickuptester();

        }
        if (choice==2){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-4);
            passengerpickuptester();

        }
        if (choice==3){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-5);
            passengerpickuptester();

        }
        if (choice==4 || choice==1){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-3);
            passengerpickuptester();

        }
        if (choice==5){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-4);
            passengerpickuptester();

        }
        if (choice==6){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-5);
            passengerpickuptester();

        }
        if (choice==7){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-2);
            passengerpickuptester();

        }
        if (choice==8){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-3);
            passengerpickuptester();

        }
        if (choice==9){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-4);
            passengerpickuptester();

        }
    }
    public void scoringmovementice(){

        if (choice==1){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-1);
            passengerpickuptester();

        }
        if (choice==2){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-2);
            passengerpickuptester();

        }
        if (choice==3){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-3);
            passengerpickuptester();

        }
        if (choice==4){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-3);
            passengerpickuptester();

        }
        if (choice==5){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-4);
            passengerpickuptester();

        }
        if (choice==6){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-5);
            passengerpickuptester();

        }
        if (choice==7){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-3);
            passengerpickuptester();

        }
        if (choice==8){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-4);
            passengerpickuptester();

        }
        if (choice==9){
            world worldWorld = (world) getWorld();
            Counter counter = worldWorld.getCounter();
            counter.bumpCount(-5);
            passengerpickuptester();

        }
    }
    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();
        }
        else{ //there is not a person in that square
            atbasecamp();

        }
        
    }

    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 counter2 = worldWorld.getCounter2();
        counter2.bumpCount2(1);
        atbasecamp();

    } 

    public void atbasecamp(){

        Actor Basecamp;    
        Basecamp=getOneObjectAtOffset(0,0,Basecamp.class);
        if(Basecamp != null) {
            //there is a basecamp on that square
             tester=true;
             System.out.println("hello");
            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();

        }
    }

    //public void basecampunload(){ this is all old i just dont want to lose it yet :-(
        //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();

       // }

    //}

}
Good luck! FruitFlies
mezboycalday mezboycalday

2013/10/1

#
once again jones plz help
You need to login to post a reply.
1
2