資源簡介
消消樂項(xiàng)目,使用的visua studio2017 非常適合新手學(xué)習(xí),可以添增在c語言學(xué)習(xí)中的樂趣!
代碼片段和文件信息
#include
#include
#include
#include
#include
#include??//::GetKeyState函數(shù)的頭文件
//#define?KEY_DOWN(vk_c)?(GetAsyncKeyState(vk_c)&0x8000)//獲取鍵盤值,vk_c為字符的ACII碼
typedef?struct?weizhi
{
int?x;
int?y;
}position;
//歸并排序
void?merge(weizhi?arr[]?int?low?int?mid?int?high)?{
int?i?k;
weizhi?*tmp?=?(weizhi?*)malloc((high?-?low?+?1)?*?sizeof(weizhi));
//申請空間,使其大小為兩個
int?left_low?=?low;
int?left_high?=?mid;
int?right_low?=?mid?+?1;
int?right_high?=?high;
for?(k?=?0;?left_low?<=?left_high?&&?right_low?<=?right_high;?k++)?{??//?比較兩個指針?biāo)赶虻脑?br/> if?(arr[left_low].y?<=?arr[right_low].y)?{
tmp[k]?=?arr[left_low++];
}
else?{
tmp[k]?=?arr[right_low++];
}
}
if?(left_low?<=?left_high)?{??//若第一個序列有剩余,直接復(fù)制出來粘到合并序列尾
//memcpy(tmp+k?arr+left_low?(left_high-left_low+l)*sizeof(int));
for?(i?=?left_low;?i?<=?left_high;?i++)
tmp[k++]?=?arr[i];
}
if?(right_low?<=?right_high)?{
//若第二個序列有剩余,直接復(fù)制出來粘到合并序列尾
//memcpy(tmp+k?arr+right_low?(right_high-right_low+1)*sizeof(int));
for?(i?=?right_low;?i?<=?right_high;?i++)
tmp[k++]?=?arr[i];
}
for?(i?=?0;?i? arr[low?+?i]?=?tmp[i];
free(tmp);
return;
}
void?merge_sort(weizhi?arr[]?unsigned?int?first?unsigned?int?last)?{
int?mid?=?0;
if?(first? mid?=?(first?+?last)?/?2;?/*?注意防止溢出?*/
/*mid?=?first/2?+?last/2;*/
//mid?=?(first?&?last)?+?((first?^?last)?>>?1);
merge_sort(arr?first?mid);
merge_sort(arr?mid?+?1?last);
merge(arr?first?mid?last);
}
return;
}
//
void?init();??//?初始化界面
void?gamebegin();??//游戲開始界面
void?gameplay();???//玩游戲的具體過程
void?close();???//釋放資源
void?drawXuanzhe(position?COLORREF);//定義選擇邊框
void?drawTime(int);//時間定義
void?drawScore(int);//分?jǐn)?shù)定義
void?getsamecolorballs(position?COLORREF);?//獲取同色小球
int?isValid(position?COLORREF);?//判斷是否合法
void?ballsfall();//小球下降
//void?turn();//將坐標(biāo)替換位置
COLORREF?colorArr[6]?=?{?RGB(20000)RGB(02000)RGB(00200)
RGB(2002000)RGB(2000200)RGB(0200200)?};//六個顏色RGB值數(shù)組
//宏定義
weizhi?cur;
weizhi?ballpos[180];
int?index;
int?main()
{
init();??//?初始化界面
gamebegin();??//游戲開始界面
gameplay();???//玩游戲的具體過程
Sleep(3000);
close();???//釋放資源
return?0;
}
void?init()
{
initgraph(1000?700);
}
void?gamebegin()
{
//設(shè)置邊框
setlinecolor(RGB(50?50?50));
setlinestyle(PS_SOLID?10);
rectangle(255?45?745?655);
//設(shè)置小球樣式
setlinestyle(PS_SOLID);
srand((unsigned)time(NULL));
for?(int?x?=?280;?x?740;?x?+=?40)
{
for?(int?y?=?70;?y?650;?y?+=?40)
{
COLORREF?color?=?colorArr[rand()?%?6];
setfillcolor(color);
setlinecolor(color);
fillcircle(x?y?18);
}
}
//繪制光標(biāo)
cur.x?=?480;
cur.y?=?390;//初始化選擇邊框位置
drawXuanzhe(cur?RGB(255?255?255));
//時間
drawTime(30);
//分?jǐn)?shù)
drawScore(0);
}
void?drawXuanzhe(position?pos?COLORREF?color)
{
setlinecolor(color);
rectangle(pos.x?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????..A..H.?????35840??2019-02-26?23:58??練習(xí)項(xiàng)目\.vs\練習(xí)項(xiàng)目\v15\.suo
?????文件???34852864??2019-02-26?23:58??練習(xí)項(xiàng)目\.vs\練習(xí)項(xiàng)目\v15\Browse.VC.db
?????文件???40501248??2019-02-26?22:52??練習(xí)項(xiàng)目\.vs\練習(xí)項(xiàng)目\v15\ipch\AutoPCH\59fb01cc8a94fe5\練習(xí).ipch
?????文件?????120320??2019-02-26?23:32??練習(xí)項(xiàng)目\Debug\練習(xí)項(xiàng)目.exe
?????文件????1014460??2019-02-26?23:32??練習(xí)項(xiàng)目\Debug\練習(xí)項(xiàng)目.ilk
?????文件?????913408??2019-02-26?23:32??練習(xí)項(xiàng)目\Debug\練習(xí)項(xiàng)目.pdb
?????文件?????420864??2019-02-26?23:32??練習(xí)項(xiàng)目\練習(xí)項(xiàng)目\Debug\vc141.idb
?????文件?????159744??2019-02-26?23:32??練習(xí)項(xiàng)目\練習(xí)項(xiàng)目\Debug\vc141.pdb
?????文件??????44522??2019-02-26?23:32??練習(xí)項(xiàng)目\練習(xí)項(xiàng)目\Debug\練習(xí).obj
?????文件????????735??2019-02-26?14:55??練習(xí)項(xiàng)目\練習(xí)項(xiàng)目\Debug\練習(xí)項(xiàng)目.Build.CppClean.log
?????文件????????857??2019-02-26?23:32??練習(xí)項(xiàng)目\練習(xí)項(xiàng)目\Debug\練習(xí)項(xiàng)目.log
?????文件????????660??2019-02-26?23:32??練習(xí)項(xiàng)目\練習(xí)項(xiàng)目\Debug\練習(xí)項(xiàng)目.tlog\CL.command.1.tlog
?????文件??????27146??2019-02-26?23:32??練習(xí)項(xiàng)目\練習(xí)項(xiàng)目\Debug\練習(xí)項(xiàng)目.tlog\CL.read.1.tlog
?????文件????????396??2019-02-26?23:32??練習(xí)項(xiàng)目\練習(xí)項(xiàng)目\Debug\練習(xí)項(xiàng)目.tlog\CL.write.1.tlog
?????文件???????1088??2019-02-26?23:32??練習(xí)項(xiàng)目\練習(xí)項(xiàng)目\Debug\練習(xí)項(xiàng)目.tlog\li
?????文件???????3446??2019-02-26?23:32??練習(xí)項(xiàng)目\練習(xí)項(xiàng)目\Debug\練習(xí)項(xiàng)目.tlog\li
?????文件????????378??2019-02-26?23:32??練習(xí)項(xiàng)目\練習(xí)項(xiàng)目\Debug\練習(xí)項(xiàng)目.tlog\li
?????文件????????217??2019-02-26?23:32??練習(xí)項(xiàng)目\練習(xí)項(xiàng)目\Debug\練習(xí)項(xiàng)目.tlog\練習(xí)項(xiàng)目.lastbuildstate
?????文件???????7244??2019-02-26?23:32??練習(xí)項(xiàng)目\練習(xí)項(xiàng)目\練習(xí).cpp
?????文件???????7275??2019-02-24?00:30??練習(xí)項(xiàng)目\練習(xí)項(xiàng)目\練習(xí)項(xiàng)目.vcxproj
?????文件????????951??2019-02-23?22:20??練習(xí)項(xiàng)目\練習(xí)項(xiàng)目\練習(xí)項(xiàng)目.vcxproj.filters
?????文件????????165??2019-02-23?22:19??練習(xí)項(xiàng)目\練習(xí)項(xiàng)目\練習(xí)項(xiàng)目.vcxproj.user
?????文件???????1449??2019-02-23?22:19??練習(xí)項(xiàng)目\練習(xí)項(xiàng)目.sln
?????目錄??????????0??2019-02-26?22:42??練習(xí)項(xiàng)目\.vs\練習(xí)項(xiàng)目\v15\ipch\AutoPCH\59fb01cc8a94fe5
?????目錄??????????0??2019-02-24?00:23??練習(xí)項(xiàng)目\.vs\練習(xí)項(xiàng)目\v15\ipch\AutoPCH
?????目錄??????????0??2019-02-23?22:19??練習(xí)項(xiàng)目\.vs\練習(xí)項(xiàng)目\v15\ipch
?????目錄??????????0??2019-02-26?23:58??練習(xí)項(xiàng)目\.vs\練習(xí)項(xiàng)目\v15
?????目錄??????????0??2019-02-26?23:32??練習(xí)項(xiàng)目\練習(xí)項(xiàng)目\Debug\練習(xí)項(xiàng)目.tlog
?????目錄??????????0??2019-02-23?22:19??練習(xí)項(xiàng)目\.vs\練習(xí)項(xiàng)目
?????目錄??????????0??2019-02-26?23:32??練習(xí)項(xiàng)目\練習(xí)項(xiàng)目\Debug
............此處省略7個文件信息
評論
共有 條評論