Skip to content

Commit d8d97fd

Browse files
committed
Make project2 doc more readable
1 parent cfd028d commit d8d97fd

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

project2-doc.md

+23-23
Original file line numberDiff line numberDiff line change
@@ -49,112 +49,112 @@ e.g.
4949
定義了每一個階梯物件,
5050
5151
52-
#### `void rise()`
52+
#### void rise()
5353
每次執行 Game.cpp 的 `updating()` 函數中,會讓每個階梯執行一次 `rise()` 函數
5454
55-
#### `bool isOutOfScreen()`
55+
#### bool isOutOfScreen()
5656
Game 的 `updating()` 函數會對最上面的階梯呼叫此函數,檢查是否超出螢幕上方,如果超出會回傳 true
5757
58-
#### `void takeEffect()`
58+
#### void takeEffect()
5959
在玩家站上某一個階梯後,會呼叫該階梯的 `takeEffect()` 函數,此函數透過 `stair_type` 判斷自己的階梯種類,並做出對應的效果,詳細內容請參考 `Stair.cpp` 的函數實作
6060
6161
注意:若玩家一直站在該階梯上,`takeEffect()` 會被呼叫很多次
6262
63-
#### `Stair::Stair()`
63+
#### Stair::Stair()
6464
6565
定義了創造 stair`的過程
6666
6767
遊戲每隔 `STAIR_GENERATE_PERIOD` (定義在 `Parameter.h` 中) 次數,就會互叫這個建構者(constructor)創造一個新的 stair
6868
69-
#### `StairType stair_type`
69+
#### StairType stair\_type
7070
決定這個 stair 的種類,所有的種類定義在 `Stair.h`
7171
```cpp
7272
enum StairType {
7373
normal_stair, spike_stair, left_roll_stair, right_roll_stair,
7474
NUM_OF_STAIR_TYPE // This value is intented to keep the number of elements in this enum.
7575
};
7676
```
77-
#### `bool has_taken_effect`
77+
#### bool has_taken_effect
7878

7979
如果這個 stair 已經被呼叫或一次 `takeEffect()`,則此值為 `true`
8080

8181
因為只要玩家站上某一個階梯後,便會不停呼叫該階梯的 `takeEffect()` 函,因此可以善加利用這個變數來避免重複執行很多次效果
8282

83-
#### `int width()` and `int height()`
83+
#### int width() and int height()
8484

8585
回傳寬、高
8686

8787
## Player
8888

89-
#### `void moveLeft()` and `void moveRight()`
89+
#### void moveLeft() and void moveRight()
9090

9191
player 向左右移動時,呼叫此函數,並根據 `left_moving_speed`、`right_moving_speed` 移動
9292

93-
#### `void fall()`
93+
#### void fall()
9494

9595
player 沒有站在任何 stair 上,則執行 `fall()` 函數,根據 `falling_speed` 決定移動距離
9696

97-
#### `void rise()`
97+
#### void rise()
9898

9999
player 站在任一 stair 上,`updating()` 不會執行 `fall()` 而會執行 `rise()`,讓 player 位置上升
100100

101101

102-
#### `int width()` and `int height()`
102+
#### int width() and int height()
103103

104104
回傳寬、高
105105

106106
## Game
107107

108-
#### `void updating()`
108+
#### void updating()
109109

110110
本遊戲最重要的核心函數,每隔 `FRAME_DELAY` 毫秒會呼叫一次,處理所有遊戲邏輯
111111

112-
#### `int key`
112+
#### int key
113113

114114
紀錄玩家按過的按鍵,在 `updating()` 的前半段可以看到如何判斷按鍵
115115

116-
#### `int elapsed_frames`
116+
#### int elapsed\_frames
117117

118118
紀錄遊戲執行了幾次 `updating()` 函數,最大值為 2147483647,超過的話會變成負的
119119

120-
#### `Stair\* getStairWherePlayerStandingOn()`
120+
#### Stair\* getStairWherePlayerStandingOn()
121121

122122
檢查玩家是否站在螢幕中某一個 stair 上,若有則回傳該 stair 的指標,若無則回傳 `nullptr`
123123

124-
#### `void reset()`
124+
#### void reset()
125125

126126
在遊戲初次開始、玩家死亡時,會呼叫此函數
127127

128-
#### `void updatingStairs()`
128+
#### void updatingStairs()
129129

130130
`updating()` 最後的步驟,處理所有 stair 的移動、刪除、產生
131131

132132

133133
## 共通的函數
134134

135-
#### `int x()`、`int y()`
135+
#### int x()int y()
136136

137137
回傳此物件的 x, y 值,物件如果是長方形的話會回傳左上角的頂演座標
138138

139-
#### `void setPos(int new_x, int new_y)`
139+
#### void setPos(int new\_x, int new\_y)
140140

141141
將物件的位置設定到 `(new_x, new_y)` 座標上,**所有物件的移動都是仰賴這個函數**
142142

143-
#### `setZValue(int order)`
143+
#### setZValue(int order)
144144

145145
設定物件的 z 座標 z 座標越大會顯示的順序越前面,詳細定義在 `Parameter.h``ITEM_ORDER` 中,
146146

147-
#### `setPixmap(QPixmap("images/player.png").scaled(width, height))`
147+
#### setPixmap(QPixmap("images/player.png").scaled(width, height))
148148

149149
將目前的物件圖片換成 `images/player.png`,並把圖片縮放成指定的寬(width)高(height)
150150

151151
注意:Score, Health 不能使用此函數
152152

153-
#### `extern Game * game;`
153+
#### extern Game * game;
154154

155155
只要程式開頭全域變數的地方加上這個,並 `#include "Game.h"`,就能透過以下函數操作各個物件:
156156

157-
```
157+
```cpp
158158
game->health->getHealth()
159159
game->score->getScore()
160160
game->player->setPos(94, 87)

0 commit comments

Comments
 (0)