Results 1 to 3 of 3
  1. #1
    mattooren is offline Member
    Join Date
    Mar 2012
    Posts
    1
    Rep Power
    0

    Default 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 01:39 PM. Reason: added code tags

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default 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. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,304
    Rep Power
    20

    Default Re: Game of snake problems

    Quote Originally Posted by mattooren View Post
    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
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Creating Snake Game: Few problems.
    By Nickv17 in forum New To Java
    Replies: 2
    Last Post: 01-21-2011, 04:59 AM
  2. Snake Game Applet
    By Growler in forum Java Applets
    Replies: 6
    Last Post: 07-11-2010, 02:47 PM
  3. Snake game in java
    By freaky in forum New To Java
    Replies: 5
    Last Post: 04-20-2010, 06:34 PM
  4. Snake Game
    By mustachMan in forum New To Java
    Replies: 2
    Last Post: 12-10-2009, 10:35 PM
  5. Snake game movement
    By BeerMonkey in forum New To Java
    Replies: 9
    Last Post: 11-27-2008, 12:48 PM

Posting Permissions

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