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

2017/4/12

World wont change

Skrylo Skrylo

2017/4/12

#
I made a bossfight in my game, wich should work like this: the enemy shoots 1, 2 or 3 bullets at you and you have to dodge and shoot at him, if you hit him 30 times you won, a little cheap animation shows up and after this you sgould reach the winning world wich is like a credit card but the problem is that the background won't appear and everything in the world frezzes, I tried to remove the delays and animation after the battle but it hasn't worked either. Here is my code (without the delays and animations)
if(Life != 0)
         {
            setImage("Cage.png");
            getImage().scale(320,320);
            attack = Greenfoot.getRandomNumber(3);
            i++;
            if(i == 50)
            {
                if(attack == 0)
                {
                    getWorld().addObject(new bill(), getX(), getY()+60);
                }
                else if(attack == 1)
                {
                    getWorld().addObject(new bill(), getX()+240, getY()+60);
                    getWorld().addObject(new bill(), getX()-240, getY()+60);
                }
                else if(attack == 2)
                {
                    getWorld().addObject(new bill(), getX(), getY()+60);
                    getWorld().addObject(new bill(), getX()+240, getY()+60);
                    getWorld().addObject(new bill(), getX()-240, getY()+60);
                } 
                i = 0;
            } 
            if(isTouching(Shoot.class))
            {
                removeTouching(Shoot.class);
                Life = Life - 1;
            }
            if(left <=180)
            {
                setLocation(getX()+6,getY());
                left = left + 1;
            }
            else if(right <= 180)
            {
                setLocation(getX()-6,getY());
                right = right + 1;
            }
            else
            {
                left = 0;
                right = 0;
            }
        }
        if(Life == 0)
        {
            Greenfoot.setWorld(new winner());
        }
all the variables are declared above, I hope you can help me
Skrylo Skrylo

2017/4/12

#
I found my failure myself, it was not in this class, but thanks if you tried to help
You need to login to post a reply.