# 小恐龍第一周進度 ## 先將上周的 GitHub Repository pull 下來 - 先在桌面創立一個資料夾 ![image](https://hackmd.io/_uploads/S1HytyUp6.png) - 打開資料夾 ![image](https://hackmd.io/_uploads/HJA1F18aT.png) - 複製路徑 ![image](https://hackmd.io/_uploads/Sypet18Ta.png) - 打開 cmd ![image](https://hackmd.io/_uploads/H1UfFkLTT.png) - 輸入 cd "複製的路徑" ![image](https://hackmd.io/_uploads/HkaGYJ8TT.png) - 輸入 git init ![image](https://hackmd.io/_uploads/ByE7K1UTT.png) - 輸入 git pull "自己的 GitHub URL" master ![image](https://hackmd.io/_uploads/BJYEY18pT.png) - 上周的進度,就會出現在你創立的資料夾內 ![image](https://hackmd.io/_uploads/r11HtJUp6.png) ## 小恐龍第一周進度 1. 完成 init 函式 3. 完成 display 函式 4. 在 main 呼叫 init && display ## 將寫完的程式碼 push 上去 main - 若在資料夾有 x64 的存在請刪除掉 ![image](https://hackmd.io/_uploads/SyUBKJUTp.png) - cd "資料夾的位置" ![image](https://hackmd.io/_uploads/r1ZIYyUTT.png) - git add . ![image](https://hackmd.io/_uploads/r1dIY1La6.png) - git commit -m "init&&display" ![image](https://hackmd.io/_uploads/S1OPKkUp6.png) - git remote add origin "GitHub上的URL" ![image](https://hackmd.io/_uploads/rke_FyIaT.png) - git pull origin main -\-allow-unrelated-histories (我們這次嘗試傳到main裡面) ![image](https://hackmd.io/_uploads/SJfiFy8aa.png) - git checkout -b main ![image](https://hackmd.io/_uploads/r1pot18aa.png) - git push origin main ![image](https://hackmd.io/_uploads/B143tkITa.png) ![image](https://hackmd.io/_uploads/ryonYJLap.png) ## 刪除遠端的分支 做完將 master 移到 main 後,master 分支就派不上用場可以刪除掉了 - git push origin -\-delete master --- ## 上課的進度Code ```c= #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <Windows.h> #include <time.h> #define ROAD_LENGTH 50 //路面長度 #define DINO_PLACE 6 //小恐龍在路面上的第幾格 struct dino { char road[ROAD_LENGTH + 1]; //字串結尾需要'\0' int jump_Time_Left; //小恐龍掉到地面的時間 int score; //得到的分數 int wait_Time; //每次迴圈等待的時間 int barrier_Chance; //放置障礙物的機率 //剩下看各位有需要甚麼 }; typedef struct dino Dino; Dino* init(void) { //Dino MyDino; //Dino* MyDinoPtr = &MyDino; Dino* MyDinoPtr = (Dino*)malloc(sizeof(Dino)); if (MyDinoPtr != NULL) { MyDinoPtr->jump_Time_Left = 0; MyDinoPtr->barrier_Chance = 10; MyDinoPtr->score = 0; MyDinoPtr->wait_Time = 150; for (int i = 0; i < ROAD_LENGTH; i++) { MyDinoPtr->road[i] = '_'; } MyDinoPtr->road[ROAD_LENGTH] = '\0'; } return MyDinoPtr; } void display(Dino* MyDinoPtr) { system("cls"); //空中 printf("\n\n\t"); for (int i = 0; i < ROAD_LENGTH; i++) { if (i == DINO_PLACE && MyDinoPtr->jump_Time_Left > 0) printf("o"); else printf(" "); } printf("\n\t"); //地面 printf("\n\n\n"); for (int i = 0; i < ROAD_LENGTH; i++) { if (i == DINO_PLACE && MyDinoPtr->jump_Time_Left == 0) printf("o"); else printf("%c", MyDinoPtr->road[i]); } printf("\n\n\n"); printf("\t\tyour socre is: %d", MyDinoPtr->score); return; } int main() { Dino* MyDinoPtr = init(); display(MyDinoPtr); while (true) { Sleep(MyDinoPtr->wait_Time); display(MyDinoPtr); } return 0; } ```