Step 5 Snakes head and its random positions In this step we shall manage the random positions of the snakes head for every new start of the game.
Looks like a game now.
Y) dead kado ballon The above function checks all body part positions except that of the head (Note, var i:int 1).
14, remember now you have many frames but just, zoom in and start drawing!X (ageWidth headWidth) dead else if(direction left head.Y partsArr.y ) newFood If the positions of any part are found to be the same, the newFood function calls itself.There is still plenty of scope for improving this game including graphic design, keep increasing the speed of the snake (by decreasing the span amount) after a regular interval, etc.Write comments with your suggestions and, if possible, motivation.If you observe there are three vars, 1) var keyFrame:int; 2) var frameNum:int 0; /current frame num 3) var span:int 20; /num of frames between two keyframes To understand what span is, we shall use the Flash timeline animation.



This step is not that necessary for the game, but placing tiles in the background will give a visual sense to the player.
Conclusion In this Flash tutorial we saw the complete process of creating a basic game like Hungry Snake.
Now it is more controllable.
For such an action you might think we will need to create new instance of food every time and position it on the stage.
Well if you observe, in the moveHead function we have a statement as: frameNum; This constantly increments frameNum.So let us create the dead function as follows: /If snake does not obey the game rule he will die function dead void running false; moveHead Y_down, changeDirection One more important step and the restrictions will.In this Flash tutorial, we will go step by step in creating the AS3 game and learn how to build its code in the below steps.First, we will create a MovieClip to display the Game Over message.We shall add some restrictions to the snakes movement in the next step.