Discussion on Snake - Classic Android Game

24 comments found.

zunsky

zunsky Purchased

hi,how many levels can add? I add to 35levels,but the app shows error.It shows the code is too large.Pleaes help me.

zunsky

zunsky Purchased

Hi,how to add more levels? The game just can add 25 levels at most.Or it will not run over 25 levels.Pleaes help me.

Hi,

Yes, in fact java has a limit on a method size of 64kb. I’m guessing it gave you an error: Code too large in configuration.java.

This problem can however be easily fixed by dividing code in separate methods. You can divide the ARCADE_BLOCK_PATTERN array in multiple classes (files), naming it ARCADE_BLOCK_PATTERN1, ARCADE_BLOCK_PATTERN2,...

To elaborate more create a file named configurations1.java:

package com.neurondigital.snake;

public class Configuration1 {

    final static int[][][] ARCADE_BLOCK_PATTERN1 = new int[][][]{
            //level 1
            new int[][]{
              //level 1 level design in here (didn't include it here because of length)
            },
            //level 2
            new int[][]{
              //level 2 level design in here (didn't include it here because of length)
            }
}

In the file above add as many levels as you can, then continue in the next file:

package com.neurondigital.snake;

public class Configuration2 {

    final static int[][][] ARCADE_BLOCK_PATTERN2 = new int[][][]{
            //level 20
            new int[][]{
              //level 20 level design in here (didn't include it here because of length)
            },
            //level 21
            new int[][]{
              //level 21 level design in here (didn't include it here because of length)
            }
}

Then in configuration.java, instead of the whole long ARCADE_BLOCK_PATTERN array, put:

 public static int[][][] ARCADE_BLOCK_PATTERN  = new int[][][ARCADE_BLOCK_PATTERN1.length + ARCADE_BLOCK_PATTERN2.length]; 

Then in maingame.java in onCreate method, right when the app opens concatinate the arrays to ARCADE_BLOCK_PATTERN :

System.arraycopy(ARCADE_BLOCK_PATTERN1, 0, ARCADE_BLOCK_PATTERN   , 0, ARCADE_BLOCK_PATTERN1.length); 
System.arraycopy(ARCADE_BLOCK_PATTERN2, 0, ARCADE_BLOCK_PATTERN  , ARCADE_BLOCK_PATTERN1.length, ARCADE_BLOCK_PATTERN2.length);

Please note that the game should support as many levels as you add, however, the level button will become smaller, so don’t add too much.

Hope this helps. Do let me know if you need anything else. Regards, Melvin

zunsky

zunsky Purchased

HI,can you help me to add level to 300 levels?I will pay for you the new work with paypal.Please help me.

Hi, For customisations please send me an email to melvin@neurondigital.com.

does the project use libgdx?

Hi, No, it doesn’t use any external libraries.

Hello, is there a way I can increase the swipe sensitivity because as of now it requires some efforts to change the direction of the snake. Also is it possible to allow snakes pass through the walls and let it come out from the other side of the screen as was in the original snake game. Thanks

Hi,

The swipe sensitivity can be varied from nudge/screen.java, line 619:
        private final int SWIPE_DISTANCE_THRESHOLD = dpToPx(50);
        private final int SWIPE_VELOCITY_THRESHOLD = dpToPx(50);

Just change the number 50.

Unfortunately, there is no easy way to make the snake pass through the wall.

by
by
by
by
by
by