2019 Spring Report of the second course the actual experiment

Spring 2019 Second course the actual lab report
a: pilot project name
Snake Game Studios
II: Functional Description pilot project
to write code, capable of running the game, the preparation of the game reached base function, in this game, is through Snake stop eating, so that it can keep growing up, the order of running the game, if you hit the border, for the game fails
III: project description module structure:
IF (kbhit ()) // determine whether there input
{
iNPUT = getch (); // move according to different input by the user does not have to enter a carriage return
IF (iNPUT == 'a')
{
moveDirection =. 3; // left position
moveSnakeByDirection ();
}
the else IF (iNPUT == 'D')
{
moveDirection =. 4; // position right
moveSnakeByDirection ();
}
the else IF (INPUT == 'W')
{
moveDirection =. 1; // shift position
moveSnakeByDirection ();
}
the else IF (INPUT == 'S')
{
moveDirection = 2; // down position
moveSnakeByDirection ();
}
}
This code used to implement the snake movement, to control the game results
for (I = 0; I <High; I ++)
{
for (J = 0; J <the Width; J ++)
{
IF (Canvas [I] [J] == 0)
the printf ( ""); // output space
the else IF (Canvas [I] [J] == -. 1)
the printf ( "#"); // output frame #
the else IF (Canvas [I] [J] ==. 1)
the printf ( "@"); // output snakehead @
else IF (Canvas [I] [J]>. 1)
the printf ( " "); // output snake
else IF (Canvas [I] [J] == - 2)
the printf ( "F."); // output food F.
}
the code used to build the basis of game elements,
F (Canvas [newHead_i] [newHead_j]> 0 | | Canvas [newHead_i] [newHead_j] == - 1)
{
printf ( "game over \ the n-!");
at Sleep (2000);
System ( "PAUSE");
exit(0);
Judge running the game, if there hit the wall, then output the game fails, then output option
four: to achieve interface display

Five: Code managed connection
https://gitee.com/langziya/fish_pond.git
VI: summary of experimental
this time writing code, I and my team who have always thought that writing code is still required to complete the individual alone, according to others code, everyone has a different method for each person, it's moving snake that period, I feel no need to use the book, mainly because we have written another point is incorrect, or that it should not be a piece of code

Guess you like

Origin www.cnblogs.com/langz594212/p/10956654.html