One of the three days to learn shell Tetris: drawing the interface
Source: Internet
Author: User
One of the three days to learn about shell Tetris: drawing the interface-general Linux technology-Linux programming and kernel information. The following is a detailed description. [I = s] This post was last edited by kevin_2009 at, 2009-4-14
No way, the teacher asked me to finish the Tetris programming in shell in three days, so I could only do it,
By the way, I will share with you and work together to complete this interesting game.
The first step is to draw the interface:
First, we need to learn how to use the color in shell.
Let's take a look at the definition of the color in shell:
Code color
---------------------------------------
0 black
1? Color
2? Color
3? Color
4? Color
5 purple? Color
6 green? Color
7 white
-----------------------------------------
Use shell color
Next I will use a prompt example to explain the shell color.
In this way, all the prompts are displayed in green. Like this: [nico @ ebrain: ~] $
\ 033 declares the start of the escape sequence, and then [begins to define the color. The following 0 defines the default font width. I will introduce other available characters later. Escape Sequence strings must be enclosed by \ [and \] to prevent the text of escape sequences from occupying too much space in shell.
Next we will select the foreground color (here is 32, representing green ). 40 of the background color indicates black. If you do not want to change the text after the prompt to green, use \ 033 [0 m to close the escape sequence. \ 033 [0 m is the default color of shell. Both the foreground and background colors are available.
I believe that after the above learning, you have a better understanding of the color under shell, So let's continue to write about the Russian square.
From the player's point of view, the Tetris game. The game is made up of several basic shapes of bricks, which are lowered to the bottom of the window at a certain speed.
Bricks can be flipped and moved during the fall process. When there is a brick link at the bottom and occupies a whole row, it can be eliminated. So,
Our implementation is divided into two parts: the background processing part and the user interface display part.
Return to the interface design issue. To make the color easier to use, replace the characters in English:
The next step is to define an array to display the square. We know that there are eight kinds of squares, and each square has several transformation methods:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.