Please Answer within the next 24 hours if possible!
So the title is pretty self explanatory. I have to make a moving centipede for an assignment that can do this:
1.) Centipede comes in from the top of the screen. It is 12 segments long.
2.) Centipede descends from the center of the board and immediately begins moving towards the right of the board.
3.) When the centipede hits the right hand wall, it will move into the next row towards the bottom and start moving left. When it hits the left wall, it will move into the next row toward the bottom and start moving right.
I can make one object move no problem, but now I have to have 11 others play "follow the leader". I know I need an array to do this, and a boolean condition that checks for turns. But I have no idea how to approach this or where to put certain parts of code in. My only experience with arrays thus far is with making a proton wave image grow; that's images, not actual objects. Any help please? I have no idea where to start.
Also, I currently have each body part as a separate actor. Should each part instead be a subclass of Head (which is a subclass of Actor)?
EDIT: Here is some code I have so far. It's pretty unpolished, but the basic idea is correct, isn't it?
public void act()
{
move(15);
//if it hits wall, turn 90 degrees
if(getRotation() == 90) {
isBugTurning = true;
//if it is:
//check next element
//get element to turn
}
}

