Developer   Tutorials   Snake   Summary

Summary

In this tutorial we have created Snake game for smartphones with touch displays using Moscrif features. The snake moves around the playground and eats two different types of foods. Small food is worth 10 score points and the large one is worth 20 points. Player can change the direction of the snake by tapping on the screen.

This tutorial was focused on the game2d library. It provides the environment for game development using Moscrif. The game2d library is similar to Cocos2d library, but it is also available for Android and Bada. 

Our game cosists of two scenes - menu and game scene. These scenes contains all other objects used in the game. Our scenes are extended from Scene class and pushed to the game by push function.

In the menu we use GameButton class to create three buttons, which allow the user to start new game, continue previous game or quit the game. The game buttons are added to the scene by add function.

In the game we create all game elements by using Sprite class. Sprite is the base class for game elements. Instance of this class can be added to the scene as well, by using add function. Sprite object can also contain more frames. These can be displaying gradually by nextFrame or  prevFrame functions, thus creating nice animation.

 Snake   Summary