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

2017/3/18

I need help with enemy movement

Skrylo Skrylo

2017/3/18

#
I'm making a Space Invaders Clone to learn some basics and made the basic movement of Space Invaders Enemys and it works well for one period but after that it stopps, if you could help me that would be great
if(a <= 433)
        {
            setLocation(getX()+3,getY());
            a = a + 1;
        }
        else if(b <= 30)
        {
            setLocation(getX(),getY()+3);
            b = b + 1;
        }
        else if(c <= 433)
        {
            setLocation(getX()-3,getY());
            c = c + 1;
        }
        else if(d <= 30)
        {
            setLocation(getX(),getY()+3);
            d = d + 1;
        }
        else if(d == 29)
        {
            a = 0;
            b = 0;
            c = 0;
            return;
        }
the code is inside the act method of the Enemy Classes
danpost danpost

2017/3/18

#
Each row of invader must be controlled from one central location -- in other words, they should not each control their own movement. On top of that, all rows of invaders must be controlled from one central location because if any row has an invader at the edge and needs the row to drop and move back across the other way, then all the rows need to drop and move back (in succession). My Space Invaders Movement Demo scenario shows one way to accomplish this.
You need to login to post a reply.