當前位置:編程學習大全網 - 源碼下載 - 掃雷插件源代碼c

掃雷插件源代碼c

最基本的snake代碼#include#include//基本類型定義。支持類型定義功能。用戶界面功能圖形設備界面功能。#include//用戶按鍵盤(控制臺)產生的相應操作#include//日期時間頭文件# definelen 30 # define wid 25 int snake[len][wid]= { 0 };//數組的元素表示蛇charSna_Hea_Dir='a '的各個部分;//記錄黑魚的移動方向intSna_Hea_X,Sna _ Hea _ Y;//記錄蛇頭的位置int snake _ Len = 3;//記錄蛇鐘的長度_ tNow _ Time//記錄當前時間,以便自動移動intWait _ Time//記錄自動運動的時間間隔:intelat _ apple = 1;//吃蘋果意味著1 int level;int all _ Score =-1;int apple _ Num =-1;handleh console = GetStdHandle(STD _ OUTPUT _ HANDLE);//獲取標準輸出的句柄//Handle:標記應用中的不同對象和同壹類對象的不同實例以便於操作,voidgotoxy(intx,inty)//設置光標位置{COORDpos={x,y };//定義壹個字符在控制臺屏幕上的坐標PossetConsoleCursorPosition(HConsole,POS);//定位光標位置的函數} void hede _ cursor()//隱藏光標固定函數{ console _ cursor _ info cursor _ info = { 1,0 };SetConsoleCursorInfo(hConsole & amp;cursor _ info);}voidSetColor(intcolor)//設置顏色{ setconsoletextattribute(h console,color);//是設置字體顏色和背景顏色的API的函數格式:SetConsoleTextAttribute (handle,color);}voidPrint_Snake()//打印蛇頭和蛇的頸尾{intiy,ix,colorfor(iy = 0;iynul”);退出(0);}voidMove_Snake()//讓蛇移動{intix,iy;for(IX = 0;ix0){if(Snake[ix][iy]!= Snake _ Len)Snake[IX][iy]+= 1;else snake[IX][iy]= 0;} } Snake[Sna _ Hea _ X][Sna _ Hea _ Y]= 1;//處理蛇頭}voidGet_Input()//控制蛇的移動方向{ if(kb hit()){ switch(getch()){ Case 87:SNA _ HEA _ dir = ' w ';打破;案例83:Sna _ Hea _ Dir = ' s ';打破;情況65:Sna _ Hea _ Dir = ' a ';打破;案例68:Sna _ Hea _ Dir = ' d ';打破;默認:break} } if(clock()-Now _ Time & gt;=Wait_Time)//蛇到了Time { Clear _ Snake();move _ Snake();print _ Snake();現在_時間=時鐘();}}voidInit()//初始化{system("標題貪婪的毛毛蛇");system(" modecon:cols = 80 lines = 25 ");Hide_Cursor()。gotoxy(61,4);printf(" YouScore:");gotoxy(61,6);printf(" you level:");gotoxy(61,8);printf(" the length:");gotoxy(61,10);printf(" the speed:");gotoxy(61,12);printf(" AppleNum:");intifor(I = 0;i50)Wait _ Time-= 50;else if(Wait _ Time & gt;10)Wait _ Time-= 10;else wait _ Time-= 1;} } int main(void){ Init();srand((無符號)時間(空));//設置隨機數的種子Now _ Time = clock();intspeed1=1000,speed2,a;printf(" \ n ");Printf("請輸入您想要的速度\ n ");scanf("%d ",& ampspeed 2);level = 1;wait _ Time = speed 1-speed 2;Printf("請輸入您想要的蘋果數量\ n ");scanf("%d ",& ampa);while(a-)Rand _ Apple();while(1){ if(Eat _ Apple){ ++ Apple _ Num;rand _ Apple();lev _ Sys();pri _ News();}Get_Input()。睡眠(10);} return0}
  • 上一篇:如何打包和部署air應用程序
  • 下一篇:app制作要多少錢?
  • copyright 2024編程學習大全網