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

2020/2/14

if counter

TakedaYeet TakedaYeet

2020/2/14

#
i want to know if i can execute a command if a counter is at a certain amount. this is my code for the counter (in a different class)
private void KILL()
    {
        if(isTouching(human1.class))
        {
            if (getWorld() instanceof MyWorld)
            {
                removeTouching(human1.class);
                bumpCounter(1);
                Greenfoot.playSound ("scream1.1.mp3");
                if(counter == 0) {
                    Greenfoot.setWorld (level3.class);
                }
            }
            if (getWorld() instanceof level2)
            {
                removeTouching(human1.class);
                bumpCounter(1);
                Greenfoot.playSound ("scream1.1.mp3");
            }
            if (getWorld() instanceof level3)
            {
                removeTouching(human1.class);
                bumpCounter(1);
                Greenfoot.playSound ("scream1.1.mp3");
            }
        }
    }
    private void bumpCounter(int amount)
    {
        if (getWorld() instanceof level2)
            {
            level2 world;
            world = (level2)getWorld();
            Counter counter;
            counter = (Counter)world.getObjects(Counter.class).get(0);
            counter.add(amount);
            
        }
        if (getWorld() instanceof MyWorld)
            {
            MyWorld world;
            world = (MyWorld)getWorld();
            Counter counter;
            counter = (Counter)world.getObjects(Counter.class).get(0);
            counter.add(amount);
        }
        if (getWorld() instanceof level3)
            {
            level3 world;
            world = (level3)getWorld();
            Counter counter;
            counter = (Counter)world.getObjects(Counter.class).get(0);
            counter.add(amount);
        }
    }
TakedaYeet TakedaYeet

2020/2/14

#
please help
danpost danpost

2020/2/14

#
TakedaYeet wrote...
please help
Need Counter class codes (at minimum).
You need to login to post a reply.