is the following code good as a starting point for a snake game im woking on
package Snake2; import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.util.Random; public class Snake extends JPanel implements KeyListener{ int [][] occupied=new int[50][50]; WALL=0,SNAKE=1,FOOD=2,COLLISION=3,NORTH=4,SOUTH=5,EAST=6,WEST=7;//the numbers that represent each number public static final int ROW_COUNT=50,COLUMN_COUNT=50;//dimension constants: occupied int level=1; int score=0; boolean gameOver=false; int [][] inintailPosition={{10,11},{10,12},{10,13},{10,14},{10,15}}; int [] xSnake= new int[2500];//{10,10,10,10,10,....} int[] ySnake= new int[2500];//{11,12,13,14,15,.....} int zSnake=5;//length of snake, max size is 50*50=2500 JLabel scoreBoard= new JLabel("Score: 0"); JLabel levelBoard= new JLabel("Level: 1"); JLabel spaceBoard= new JLabel("Press space for next level"); JLabel gameOverBoard=new JLabel("Game Over: Press Space"); random= new random(); }
Join our real-time social learning platform and learn together with your friends!