I just published the snake game.
https://codegym.cc/projects/apps/36280
For some reason, Monty the snake isn't changing colour anymore when he eats the mushroom, or flashing when the invincibility is about to wear off, now that it's published. :(
It works perfectly when I run it from Intellij. Would anyone know why this is, so I can avoid this issue in future games?
Draw method below.
Ps sorry for the long-winded code - I guess I could have made a variable for the colour parameter!
public void draw(Game game){
for (GameObject part : snakeParts){
if (isAlive && !isPowerUp) {
if (snakeParts.indexOf(part) == 0)
game.setCellValueEx(part.x, part.y, Color.NONE, HEAD_SIGN, Color.LAWNGREEN, 75);
else game.setCellValueEx(part.x, part.y, Color.NONE, BODY_SIGN, Color.LAWNGREEN, 75);
}
else if (isPowerUp) {
if (SnakeGame.powerCount > 50) {
if (SnakeGame.colorFlash % 2 == 0) {
if (snakeParts.indexOf(part) == 0)
game.setCellValueEx(part.x, part.y, Color.NONE, HEAD_SIGN, Color.YELLOW, 75);
else game.setCellValueEx(part.x, part.y, Color.NONE, BODY_SIGN, Color.YELLOW, 75);
} else {
if (snakeParts.indexOf(part) == 0)
game.setCellValueEx(part.x, part.y, Color.NONE, HEAD_SIGN, Color.PINK, 75);
else game.setCellValueEx(part.x, part.y, Color.NONE, BODY_SIGN, Color.PINK, 75);
}
}
else {
if (snakeParts.indexOf(part) == 0)
game.setCellValueEx(part.x, part.y, Color.NONE, HEAD_SIGN, Color.YELLOW, 75);
else game.setCellValueEx(part.x, part.y, Color.NONE, BODY_SIGN, Color.YELLOW, 75);
}
}
else {
if (snakeParts.indexOf(part) == 0)
game.setCellValueEx(part.x, part.y, Color.NONE, HEAD_SIGN, Color.RED, 75);
else game.setCellValueEx(part.x, part.y, Color.NONE, BODY_SIGN, Color.RED, 75);
}
}
}