Курсовая работа: Гра Змійка опис програми
public void resetLives(){
lives = startLives;
}
public void increment(SnakeElement lastElem) {
SnakeElement temp[];
temp = new SnakeElement[colElements];
for (int i = 0; i<colElements; i++) {
temp[i] = new SnakeElement(0,0);
temp[i] = elem[i];
}
colElements++;
elem = new SnakeElement[colElements];
for (int i = 0; i<colElements-1; i++) {
elem[i] = new SnakeElement(0,0);
elem[i] = temp[i];
}
elem[colElements-1] = new SnakeElement(0,0);
elem[colElements-1] = lastElem;
elem[colElements-1].xSpeed = lastElem.xSpeed;
elem[colElements-1].ySpeed = lastElem.ySpeed;
}
public void move(){
for (int i = colElements-1; i>0; i--){
elem[i].setSpeed(elem[i-1].xSpeed, elem[i-1].ySpeed);
elem[i].move();
}
elem[0].xSpeed = xNextSpeed;
elem[0].ySpeed = yNextSpeed;
elem[0].move();