In this project we are going to develop a game called “Smart Snake” by using java. Normally the "Snake Game" we used to play back in our childhood worked on the idea that the snake had to be controlled by the player which tried to eat food & increase its length as long as it was alive and the game was over when it had a collision with its body. But in our version, We are going to develop a game which is a bit different from the usual Snake Game. In this game, there is a snake which moves automatically and intelligently to eat the food that is controlled by the player. If snake bites itself before eating the food then the player wins and if the snake eat the food then the game is over.
This function initialize the GUI & start the game by calling function startgame().
This function start the timer;
This function draw the components of the game such as snake & apple;
This function defined an arbitrary position for the apple;
This function moves the apple towards user defined direction;
This function moves the snake smartly & intelligently to catch the apple;
This function check whether the apple is eaten by snake or not;
It checks whether the snake collides with it’s any body parts. And also checks whether the snake crosses the border in the game window.
It returns whether the game is over or not. The game is over when the snake eats the apple then the timer is stopped and the game score is printed in the screen by this GameOver function.