Thursday 8 October 2015

Snake Game

Functions used in Snake Game Project in C:

Many functions have been used in this Snake mini project. Here, I will just list them below and describe the functions “gotoxy”, “GotoXY” and “delay” as they are some of the most important functions used in this and many mini projects in C.
void record()
void load()
void Delay(long double)
void Move()
void Food()
void Print()
void Bend()
int Score()
void Boarder()
void Down()
void Left()
void Up()
void Right()
void ExitGame()
void gotoxy (int x, int y) – You need to understand this function as it is one of the most important one used in Snake Game mini project in C. This function allows you to print text in any place of screen. Using this function in Code::Blocks requires coding, but it can be directly used in Turbo C. Here is a code for this function in Code::Blocks.
Here, COORD coord= {0,0}; is a global variable. It sets the center of axis to the top left corner of the screen.
void GotoXY (int x, int y) – Here is the code for this function in Code::Blocks.
void delay(long double) – This function delays the execution. It can be used directly in Turbo C, but requires coding in Code::Blocks. The code is given below:
This mini project in C Snake game gives users a total of three lives to play the game. The life-count decreases as the snake hits the wall or its own body. In this mini project, you can even pause the game in the middle by pressing any key, and you can press any key again to continue.

No comments:

Post a Comment