Hey again.
If you have seen my previous discussion post, I was talking about making a space invaders like game. I still have one last problem that comes with it and it is basically the movement of the enemy ships. In Space Invaders the enemies are in a block and they move together as if they're one character however in my game I want each enemy to be its on and not follow that "chunk" movement.
It's really hard to explain but basically I am trying to make snake like pattern. When the first enemy in the "chain" reaches the right of the screen it goes down and then turns left and the enemies behind it follow the pattern when they reach the sides of the screen.
Currently, I have my attempt which for some reason only lowers the side enemies and moves in the chunk formation.
This is the code that is giving me all the trouble, the rest seem to work perfectly and shouldn't be causing any problems.
private void EnemyMovement() { for (int i = 0; i < enemy.length; i++) { if (enemy[i].getWorld() != null) { if (enemy[i].getX() < 605 && enemy[i].getX() > 595) { enemyLeft = true; enemy[i].setLocation(594, enemy[i].getY()+20); } else if (enemy[i].getX() > -5 && enemy[i].getX() < 5) { enemyLeft = false; enemy[i].setLocation(6, enemy[i].getY()+20); } if (!enemyLeft) { enemy[i].setLocation(enemy[i].getX() +1, enemy[i].getY()); } if (enemyLeft) { enemy[i].setLocation(enemy[i].getX() -1, enemy[i].getY()); } } } }