打字小遊戲

2021-07-10 14:32:47 字數 1392 閱讀 4393

呵呵,這是我人生的第乙個寫的程式::

打字遊戲!!

其實並不難:

#include 

#include

#include

#include

#include

using

namespace

std;

// 隨機生成數字、大寫字母、小寫字母

char randomchar()

if (type == 1)

return rand() % 26 + 'a';

}// 將游標移到控制台(x,y)處。

void gotoxy(int x, int y)

int main()

for (int i = 1; i <= 2 * n; i++)

bool gameover = 0;//判斷是否遊戲結束

while (gameover == 0)

}sleep(1000 - n * 100);//按難度定義字元掉落速度

for (int i = 1; i <= 2 * n; i++)

if (gameover)

}if (gameover)//如果沒有這個判斷,那麼當字元掉落到終點線時,如果使用者沒有按鍵,則遊戲不會結束

char userhit = getch();

for (int i = 1; i <= 2 * n; i++)}}

setconsoletextattribute(hout,

foreground_red |

foreground_green |

foreground_blue |

foreground_intensity); //白色

gotoxy(20 - 2 * n + 2, 0);

cout

<< "很遺憾,遊戲結束!\n您當前得分為:";

setconsoletextattribute(hout,

foreground_red |

foreground_intensity); //紅色

cout

<< score;

setconsoletextattribute(hout,

foreground_red |

foreground_green |

foreground_blue |

foreground_intensity); //白色

cout

<< "分\n\n是否再挑戰一次? y/n\n";

string str;

cin >> str;

if (str == "n" || str == "n")

else

}return

0;}

小專案 打字小遊戲

include include include include include define n 20 static void randomstring char str,int len static char mygetchar static void gamerunning time t sta...

C 實現打字小遊戲(一)

先附上兩張截圖 這裡主要是針對c 計時器的使用 初始時間我們定為三分鐘這裡用label標籤來顯示英文本母 public void initlabel private char getlet 這樣就完成了標籤的初始化,然後使用計時器來控制降落速度 if let1.bottom this height ...

JS簡單打字小遊戲demo

打字遊戲 title style html,body main font fstyle head body div id main div body script varwords a b c d e f g h i j k l m n o p q r s t u v w x y z varwinw...