Gluttony Snake and Tetris Software
In the first class of the C language course, the teacher provided a C language flying Tetris to let us feel that the C language course we learned was mainly the practice of all kinds of sentences, and this time we used what we had learned to feel a practical system. I feel very novel and have a great interest in the course of c language.
The first step in making a c file is to install the C-FREE software, and then write the source code. Although the interface is simple, and the operation is not smooth. But it has shown his secret.
Analysis of the program, I feel that it is not too complicated, that is, the combination of simple sentences learned last semester, but used very well. First, let's take a look at several statements used:
1. The first is the statement printf displayed on the screen.
2. The other is to judge switch--case with multiple conditions.
Application method
Switch (tetris- > flag)
{
Case 1:
{
A [tetris-> x] [tetris- > ymur1] = b [1]
A [tetris-> Xuan 2] [tetris- > YMUI 1] = b [2]
A [tetris-> Xero2] [tetris- > y] = b [3]
Break
}
Case 2:
{
A [tetris-> xmuri 2] [tetris- > y] = b [1]
A [tetris-> Xerox 2] [tetris- > y] = b [2]
A [tetris-> Xero4] [tetris- > y] = b [3]
Break
}
Case 3:
{
A [tetris-> x] [tetris- > ymur1] = b [1]
A [tetris-> x] [tetris- > ymur2] = b [2]
A [tetris-> x] [tetris- > yuan1] = b [3]
Break
}
Case 4:
{
A [tetris-> xmuri 2] [tetris- > y] = b [1]
A [tetris-> Xerox 2] [tetris- > y] = b [2]
A [tetris-> x] [tetris- > yuan1] = b [3]
Break
}
Case 5:
{
A [tetris-> x] [tetris- > ymur1] = b [1]
A [tetris-> x] [tetris- > yuan1] = b [2]
A [tetris-> xmuri 2] [tetris- > y] = b [3]
Break
}
Case 6:
{
A [tetris-> x] [tetris- > ymur1] = b [1]
A [tetris-> xmuri 2] [tetris- > y] = b [2]
A [tetris-> Xero2] [tetris- > y] = b [3]
Break
}
Case 7:
{
A [tetris-> x] [tetris- > ymur1] = b [1]
A [tetris-> x] [tetris- > yuan1] = b [2]
A [tetris-> Xero2] [tetris- > y] = b [3]
Break
}
Case 8:
{
A [tetris-> x] [tetris- > yuan1] = b [1]
A [tetris-> xmuri 2] [tetris- > y] = b [2]
A [tetris-> Xero2] [tetris- > yuan1] = b [3]
Break
}
Case 9:
{
A [tetris-> x] [tetris- > ymur1] = b [1]
A [tetris-> xmuri 2] [tetris- > y] = b [2]
A [tetris-> Xmuri 2] [tetris- > Yizhi1] = b [3]
Break
}
Case 10:
{
A [tetris-> x] [tetris- > ymur1] = b [1]
A [tetris-> xmuri 2] [tetris- > ymuri 1] = b [2]
A [tetris-> Xero2] [tetris- > y] = b [3]
Break
}
Case 11:
{
A [tetris-> x] [tetris- > yuan1] = b [1]
A [tetris-> Xuan 2] [tetris- > YMUI 1] = b [2]
A [tetris-> Xero2] [tetris- > y] = b [3]
Break
}
Case 12:
{
A [tetris-> x] [tetris- > ymur1] = b [1]
A [tetris-> x] [tetris- > yuan1] = b [2]
A [tetris-> xmuri 2] [tetris- > ymuri 1] = b [3]
Break
}
Case 13:
{
A [tetris-> xmuri 2] [tetris- > y] = b [1]
A [tetris-> Xmuri 2] [tetris- > Yizhi1] = b [2]
A [tetris-> Xero2] [tetris- > y] = b [3]
Break
}
Case 14:
{
A [tetris-> x] [tetris- > ymur1] = b [1]
A [tetris-> x] [tetris- > yuan1] = b [2]
A [tetris-> Xero2] [tetris- > yuan1] = b [3]
Break
}
Case 15:
{
A [tetris-> xmuri 2] [tetris- > y] = b [1]
A [tetris-> Xuan 2] [tetris- > YMUI 1] = b [2]
A [tetris-> Xero2] [tetris- > y] = b [3]
Break
}
Case 16:
{
A [tetris-> x] [tetris- > yuan1] = b [1]
A [tetris-> x] [tetris- > ymur1] = b [2]
A [tetris-> Xuan 2] [tetris- > YMUI 1] = b [3]
Break
}
Case 17:
{
A [tetris-> xmuri 2] [tetris- > y] = b [1]
A [tetris-> xmuri 2] [tetris- > ymuri 1] = b [2]
A [tetris-> Xero2] [tetris- > y] = b [3]
Break
}
Case 18:
{
A [tetris-> x] [tetris- > ymur1] = b [1]
A [tetris-> x] [tetris- > yuan1] = b [2]
A [tetris-> Xmuri 2] [tetris- > Yizhi1] = b [3]
Break
}
Case 19:
{
A [tetris-> xmuri 2] [tetris- > y] = b [1]
A [tetris-> Xero2] [tetris- > yuan1] = b [2]
A [tetris-> Xero2] [tetris- > y] = b [3]
Break
}
}
}
Used to control left and right movement and access to menus
3. Definition of game window
Void make_frame ()
{
HANDLE hOut = GetStdHandle (STD_OUTPUT_HANDLE)
Gotoxy (hOut,FrameX+Frame_width-5,FrameY-2)
Printf (Tetris)
Gotoxy (hOut,FrameX+2*Frame_width+3,FrameY+7)
Printf ("* next square:")
Gotoxy (hOut,FrameX+2*Frame_width+3,FrameY+13)
Printf ("*")
Gotoxy (hOut,FrameX+2*Frame_width+3,FrameY+17)
Printf ("↑ key: variant")
Gotoxy (hOut,FrameX+2*Frame_width+3,FrameY+19)
Printf ("blanks: pause the game")
Gotoxy (hOut,FrameX+2*Frame_width+3,FrameY+15)
Printf ("Esc: quit the game")
Gotoxy (hOut,FrameX,FrameY)
Printf ("╔")
Gotoxy (hOut,FrameX+2*Frame_width-2,FrameY)
Printf ("╗")
Gotoxy (hOut,FrameX,FrameY+Frame_height)
Printf ("╚")
Gotoxy (hOut,FrameX+2*Frame_width-2,FrameY+Frame_height)
Printf ("╝")
A [FrameX] [FrameY+Frame_height] = 2
A [FrameX + 2*Frame_width-2] [FrameY+Frame_height] = 2
For (iTunes 2)