# Game of snake problems

• 03-07-2012, 01:02 PM
mattooren
Game of snake problems
I just started with programming Java, but I have some issues programming the game Snake.

I programmed a piece of software which has to move the a snake consisting of 3 pieces one step in a direction. The problem is it equals the coordinats even after the method has ended, can someone help me.

The code:
Code:

void processMoving(String eventData){
if(eventData.equals("scherm verversen")){

afdrukkenCoordinateRow(snakeRow);

for(int i=snakeRow.numbersInRow;i>0;i--){
Coordinate hulpCoordinaat=snakeRow.row[i-1];
snakeRow.row[i]=hulpCoordinaat;
}

printCoordinateRow(snakeRow);
snakeRow.row[0].x+=1;
snakeRow.row[0]=moveFrontOfSnake(snakeRow.row[0]);
printCoordinateRow(snakeRow);
}
}

The first three lines of the output look like:
2,0 1,0 0,0 2,0 2,0 1,0 3,0 3,0 1,0

3,0 3,0 1,0 3,0 3,0 3,0 4,0 4,0 4,0

4,0 4,0 4,0 4,0 4,0 4,0 5,0 5,0 5,0

2,0 1,0 0,0 are the starting coordinates of the snake.
• 03-07-2012, 02:39 PM
Norm
Re: Game of snake problems
Quote:

The problem is it equals the coordinats
Can your explain what the values should be?
What variable are you talking about? There isn't enough code to understand the problem.

What does this problem have to do with a java applet?
• 03-07-2012, 07:48 PM
DarrylBurke
Re: Game of snake problems
Quote:

Originally Posted by mattooren
I just started with programming Java...

So post in the appropriate section. As already said, this has nothing to do with Applets.

Moving to New to Java.

db