返回列表 發帖

[3/2 作業2]動畫及遊戲設計_二 讓賽馬場畫面動起來

本帖最後由 李泳霖 於 2024-3-9 10:40 編輯

使畫面動起來



  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int s[]= {0,0,0,0};
  7.     string a[]= {"◆","★","▲","●"};
  8.     cout<<"「好事成雙」賽馬場"<<endl;
  9.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  10.     for(int i=0; i<=4; i++)
  11.         cout<<a[i]<<endl;
  12.     system("pause");
  13.     system("cls");
  14.     while(true)
  15.     {
  16.         cout<<"比賽進行中"<<endl;
  17.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  18.         int r=rand()%4;
  19.         s[r]++;
  20.         for(int i=1; i<=s[0]; i++)
  21.             cout<<" ";
  22.         cout<<a[0]<<endl;
  23.         for(int i=1; i<=s[1]; i++)
  24.             cout<<" ";
  25.         cout<<a[1]<<endl;
  26.         for(int i=1; i<=s[2]; i++)
  27.             cout<<" ";
  28.         cout<<a[2]<<endl;
  29.         for(int i=1; i<=s[3]; i++)
  30.             cout<<" ";
  31.         cout<<a[3]<<endl;
  32.         _sleep(100);
  33.         system("cls");
  34.         if(s[r]>=72)
  35.             break;
  36.     }
  37.     system("pause");
  38.     return 0;
  39. }
複製代碼



附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊
istak.teach2@gmail.com

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見
istak.teach2@gmail.com

TOP

返回列表