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

4 days ago

if counter

TakedaYeet TakedaYeet

4 days ago

#
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

4 days ago

#
please help
danpost danpost

4 days ago

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