# Thread: Game of snake problems

1. Member
Join Date
Mar 2012
Posts
1
Rep Power
0

## 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:
Java 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.
Last edited by Norm; 03-07-2012 at 02:39 PM. Reason: added code tags

2. ## Re: Game of snake problems

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?

3. ## Re: Game of snake problems

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

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•