In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "how to achieve 2048 Mini Game under the linux console", so the editor summarizes the following contents, detailed contents and clear steps, which can be used for reference. I hope you can get something after reading this article. Let's take a look at this "how to achieve 2048 Mini Game under the linux console" article.
Cut the crap and send me the code:
Main.c
The copy code is as follows:
# include "2048.h"
Int main ()
{
Start_game ()
Return 0
}
2048.h
The copy code is as follows:
# ifndef _ 2048_h_
# define _ 2048_h_
# include
# include
# include
# include
/ / # include
/ / # include
# define line 21
# define row 22
# define arr_l 4
# define arr_r 4
# define num_color 32
# define back 49
# define bold 31
Static int line_location=0
Static int row_location=0
Static int arr [4] [4] = {0}
Static char tmp [5] = "\ 0"
Static int end_flag=0
Static int score=0
Static int print_appear_flag=0
Static char start_ back0 [line] [row] = {
"@"
"@"
"@"
"@"
"@"
"@"
"@"
"@"
"@"
"@"
"@"
"@"
"@"
"@"
"@"
"@"
"@"
"@"
"@ score: @"
"@"
"@"
}
Int print_start ()
Char * itoc_2048 (int data)
Int print_num ()
Int mov_left ()
Int swap_if0l ()
Int swap ()
Int put_to (int line, int row)
# endif
2048.c
The copy code is as follows:
# include "2048.h"
Int start_game ()
{
System ("clear")
Printf ("\ 33 [? 25l")
Print_start ()
Ran_appear ()
Print_num ()
Print_score ()
Print_getchar ()
Printf ("\ 33 [? 25h")
}
Int print_getchar ()
{
Struct termios old,new
Int ch
Tcgetattr (0djinghold)
Tcgetattr (0djinghnew)
New.c_lflag = new.c_lflag & ~ (icanon | echo)
New.c_ cc [Vtime] = 0
New.c_ cc [vmin] = 1
Tcsetattr (0pr tcsanow.mcsanow.new)
While (1)
{
If (end_flag==1)
Break
Ch=getchar ()
If (ch=='\ 33')
{
Ch=getchar ()
If (ch==' [')
{
Ch=getchar ()
Switch (ch)
{
Case'asides:
Mov_up ()
Is_full ()
Break
Case'baked:
Mov_down ()
Is_full ()
Break
Case'cages:
Mov_right ()
Is_full ()
Break
Case'dcards:
Mov_left ()
Is_full ()
Break
Default:
Break
}
}
}
If (ch=='q')
Break
Fflush (null)
}
Tcsetattr (0rem tcsanowjinghold)
}
Int print_start ()
{
Int i,j
For (iSuppli)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.