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

2020/1/14

levels in space invaders

Sebastiano Sebastiano

2020/1/14

#
public void act() 
    {
        if(killcount == 24)
        {
            killcount = 0;
            World myWorld = getWorld();
            MyWorld world = (MyWorld)myWorld;
            Status lvl = world.getStatus();
            lvl.addStatus();
            if(lvl == 2)
            {
            getWorld().addObject (new Octopus(), 300, 300);
            getWorld().addObject (new Octopus(), 375, 300);
            getWorld().addObject (new Octopus(), 450, 300);
            getWorld().addObject (new Octopus(), 525, 300);
            getWorld().addObject (new Octopus(), 600, 300);
            getWorld().addObject (new Octopus(), 225, 300);
            getWorld().addObject (new Octopus(), 150, 300);
            getWorld().addObject (new Octopus(), 75, 300);
            getWorld().addObject (new Squid(), 75, 225);
            getWorld().addObject (new Squid(), 150, 225);
            getWorld().addObject (new Squid(), 225, 225);
            getWorld().addObject (new Squid(), 300, 225);
            getWorld().addObject (new Squid(), 375, 225);
            getWorld().addObject (new Squid(), 450, 225);
            getWorld().addObject (new Squid(), 525, 225);
            getWorld().addObject (new Squid(), 600, 225);
            getWorld().addObject (new Crab(), 150, 150);
            getWorld().addObject (new Crab(), 75, 150);
            getWorld().addObject (new Crab(), 225, 150);
            getWorld().addObject (new Crab(), 300, 150);
            getWorld().addObject (new Crab(), 375, 150);
            getWorld().addObject (new Crab(), 450, 150);
            getWorld().addObject (new Crab(), 525, 150);
            getWorld().addObject (new Crab(), 600, 150);
            Difficulty difficulty = world.getDifficulty();
            difficulty.addDifficulty();
           }

        }
    }
so in this once you kill all the enemies it changes to lvl 2 and the enemys are spawned however this code doesnt work. each level i want the enemys to spawn higher than the last set and im really lost
danpost danpost

2020/1/15

#
Sebastiano wrote...
<< Code Omitted >> so in this once you kill all the enemies it changes to lvl 2 and the enemys are spawned however this code doesnt work. each level i want the enemys to spawn higher than the last set and im really lost
Not sure what you mean by "higher than the last set". Please explain in detail.
KylesGallery KylesGallery

2020/1/15

#
Like whats happening when it attempts to spawn the actors?
You need to login to post a reply.