Help with object orientated Java code for movement of snake.
I need to implement four methods for up, down, left and rightfor movement of the snake, well the head part at least that makere-use of a method that calculates a lot of this already. Themethod in need to call in is :
private void moveTo(int newHeadX, int newHeadY) //provided
{
int oldHeadX = getHeadXPos();
int oldHeadY = getHeadYPos();
int oldBodyX = getBodyXPos();
int oldBodyY = getBodyYPos();
if (checkX(newHeadX) && checkY(newHeadY))
{
head.setXPos(newHeadX);
head.setYPos(newHeadY);
delay(100);
body.setXPos(oldHeadX);
body.setYPos(oldHeadY);
delay(100);
tail.setXPos(oldBodyX);
tail.setYPos(oldBodyY);
delay(100);
}
else
{
System.out.println(“Snake cannot cross boundary!”);
}
Based on what i know about this, it should be a fairly shortpiece of code to implement as it mainly uses the above method, butcan’t for
PayPal Gateway not configured
PayPal Gateway not configured