資源簡介
在linux 環境下用C語言實現的俄羅斯方塊,用到了文件操作,列表的使用,顏色控制等的使用

代碼片段和文件信息
#include?
#include?
#include?
#include?
#include?“define.h“
#include?“typedef.h“
#include?“block.h“
#include?“con_fun.h“
#include?“enum.h“
#include?“mySignal.h“
#include?“link.h“
#include?
#include?
static?jmp_buf?env;
void?gameInit()
{
printf(“\033[0m“);
system(“clear“);
int?i??=?0j?=?0?;
int?user_state?=?0;
U_ATTR_STR?=?(USER_ATTR_PTR)malloc(sizeof(USER_ATTR));
if(U_ATTR_STR)
{
//---------int?screen?attr?the?start?value?of?Shape-----
SCREEN_ATTR.width?=?13;
SCREEN_ATTR.height?=?2;
//------------------------------
//-----next?coordinate?init-----
COOR_NEXT.next_x?=?38;
COOR_NEXT.next_y?=?13;
//------------------------------
//------limit?value?init---
S_LIMIT.left_max?=?3;
S_LIMIT.right_max?=?29;
S_LIMIT.bottom_max?=?26;
//-------------------------
//coordinate?init--------------------
SHAPE_C.new_x?=?SCREEN_ATTR.width;
SHAPE_C.new_y?=?SCREEN_ATTR.height;
SHAPE_C.old_x?=?SHAPE_C.new_x;
SHAPE_C.old_y?=?SHAPE_C.new_y;
U_ATTR_STR->u_score?=?0;
U_ATTR_STR->u_level?=?1;
//---------------------------------
//?the?max?value?of?right?side?
//init?the?mode?of?shape------
srand(time(NULL));
SHAPE_P.curr_num?=?rand()?%?7;
SHAPE_P.curr_mode?=?rand()?%?4;
SHAPE_P.next_num?=?rand()?%?7;
SHAPE_P.next_mode?=?rand()?%?4;
//shape?color
SHAPE_P.curr_color?=?40?+?rand()?%?7;
SHAPE_P.next_color?=?40?+?rand()?%?7;
//----------------------------
printScreen();
INPUT: user_state?=?setUserMessage();
switch(user_state)
{
case?1:
{
printGameFight();
sleep(1);
printStartScreen();
printNextShape(COOR_NEXT.next_xCOOR_NEXT.next_y);
printf(“\033[3;%dH?%s“39U_ATTR_STR->u_name);
printUserScore();
printUserLevel();
printf(“\033[%d;3H?you?can?go????????????\033[0m?“(ROW?-?1));
break;
}
case?2://display?score
{ printGameScore(0);
displayUserScoreForInput();
printf(“\033[%d;22H?“ROW?-?1?);
printf(“\033[%d;22H“ROW?-?1?);
goto?INPUT;
return;
}
case?3:
{
printf(“\033[%d;3H“ROW?+?1);
return?;
}
default:
{
return?;
}
}
printBlockShape(SHAPE_C.new_xSHAPE_C.new_y0);
handleOrientationKey();
}
else
{
printError(“game?init?fail“MALLOC_ERROR);
return;
}
}
static?void??handleUserInputScoreMsg(char?*msg?char?*out)
{
int?counter??=?0;
int?i?=?0?;
while(*msg)
{
if(*msg?==?‘?‘)
{
}
else
{
out[i++]?=?*msg;
}
msg++?;
}
}
int??setUserMessage()
{
game_kind??=?-1;
char?inbuf[20]?;
gets(inbuf);
if(strlen(inbuf)?==?1)
{
game_kind?=?inbuf[0];
}
else
{
}
while(?‘0‘?>??game_kind?||?game_kind?>?‘3‘)
{
if(strlen(inbuf)?==?1)
{
game_kind?=?inbuf[0];
break;
}
else
{
}
printf(“\033[%d;3H???????????????????????????????????\033[0m?“(ROW?-?1));
printf(“\033[%d;3H?please?input?<1?-?3>?:\033[0m?“(ROW?-?1));
gets(inbuf);
}
i
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-01-20?12:13??rblock\
?????目錄???????????0??2013-01-20?12:07??rblock\con_fun\
?????文件????????8405??2013-01-20?12:07??rblock\con_fun\con_fun.c
?????文件???????16304??2013-01-20?12:07??rblock\con_fun\con_fun.o
?????文件?????????169??2013-01-19?15:33??rblock\con_fun\Makefile
?????文件???????46769??2013-01-20?12:13??rblock\exe.bin
?????目錄???????????0??2013-01-20?11:31??rblock\include\
?????文件???????10341??2013-01-20?11:31??rblock\include\block.h
?????文件?????????185??2013-01-19?15:33??rblock\include\con_fun.h
?????文件?????????385??2013-01-20?10:04??rblock\include\define.h
?????文件?????????107??2013-01-19?15:33??rblock\include\enum.h
?????文件?????????885??2013-01-20?10:36??rblock\include\li
?????文件?????????788??2013-01-19?15:33??rblock\include\mySignal.h
?????文件?????????493??2013-01-20?10:17??rblock\include\print.h
?????文件????????1066??2013-01-20?09:47??rblock\include\typedef.h
?????目錄???????????0??2013-01-20?11:32??rblock\main\
?????文件???????????0??2013-01-19?15:33??rblock\main\main
?????文件??????????79??2013-01-19?15:33??rblock\main\main.c
?????文件?????????784??2013-01-20?11:32??rblock\main\main.o
?????文件?????????238??2013-01-19?15:33??rblock\main\Makefile
?????文件?????????500??2013-01-20?11:01??rblock\Makefile
?????目錄???????????0??2013-01-20?11:32??rblock\msgfile\
?????文件?????????102??2013-01-20?10:59??rblock\msgfile\Makefile
?????文件??????????27??2013-01-20?12:13??rblock\msgfile\userfile
?????目錄???????????0??2013-01-20?11:32??rblock\mySignal\
?????文件????????6564??2013-01-19?15:33??rblock\mySignal\a.out
?????文件?????????166??2013-01-19?15:33??rblock\mySignal\Makefile
?????文件????????1157??2013-01-19?15:33??rblock\mySignal\mySignal.c
?????文件????????2100??2013-01-20?11:32??rblock\mySignal\mySignal.o
?????目錄???????????0??2013-01-20?11:32??rblock\print\
?????文件?????????164??2013-01-19?15:33??rblock\print\Makefile
............此處省略12個文件信息
- 上一篇:運動會C語言實現
- 下一篇:C++課程設計 賓館管理系統 完整的報告
評論
共有 條評論