Class gridpp::GridMaze¶
儲存牆面網格並繪製整座迷宮。
#include <GridMaze.h>
Inherits the following classes: gridpp::GridObject
Public Static Attributes¶
| Type | Name |
|---|---|
| constexpr int | kMaxHeight = 64 |
| constexpr int | kMaxWidth = 64 |
Public Functions¶
| Type | Name |
|---|---|
| GridMaze (int cols, int rows) 建立空白迷宮。 |
|
| bool | IsWall (int x, int y) const |
| virtual void | Render (GridEngine * engine) override 繪製物件。預設使用物件的素材、方向與顏色繪製所在格。 |
| void | SetWall (int x, int y, bool wall) 設定一格是否為牆。 |
| void | SetWallAsset (const std::string & asset) 所有牆使用同一素材;最後呼叫此函式會切換至單一素材模式。 |
| void | SetWallTiles (const std::string & isolated, const std::string & end, const std::string & straight, const std::string & corner, const std::string & tee, const std::string & cross) 設定自動拼接牆面使用的六種素材,並切換至自動拼接模式。 |
| int | height () const |
| int | width () const |
Public Functions inherited from gridpp::GridObject¶
| Type | Name |
|---|---|
| GridObject () = default |
|
| GridObject (std::string asset_name, int x, int y) |
|
| GridObject (const GridObject & other) 複本不屬於任何 GridEngine。 |
|
| void | Move (int dx, int dy) |
| virtual void | OnCollide (GridObject * other) 與另一個可見物件位於同一個有效網格座標時呼叫。 |
| virtual void | OnSpawn () 物件加入引擎後呼叫一次。 |
| virtual void | OnUpdate () 每幀更新時呼叫。 |
| virtual void | Render (GridEngine * engine) 繪製物件。預設使用物件的素材、方向與顏色繪製所在格。 |
| const std::string & | asset_name () const |
| int | direction () const |
| GridEngine * | engine () const |
| GridObject & | operator= (const GridObject & other) = delete |
| void | set_asset_name (const std::string & asset_name) |
| void | set_direction (int direction) 每增加 1 逆時針旋轉 90 度;輸入會正規化至 0 到 3。 |
| void | set_tag (const std::string & tag) |
| void | set_tint (Color tint) |
| void | set_visible (bool visible) 隱藏的物件仍會更新,但不會繪製或參與碰撞。 |
| void | set_x (int x) |
| void | set_y (int y) |
| void | set_z_index (int z_index) 數值越大越晚繪製;相同數值保持 Spawn 順序。 |
| const std::string & | tag () const 可用於碰撞時辨識物件。 |
| Color | tint () const |
| bool | visible () const |
| int | x () const |
| int | y () const |
| int | z_index () const |
| virtual | ~GridObject () = default |
Public Static Attributes Documentation¶
variable kMaxHeight¶
variable kMaxWidth¶
Public Functions Documentation¶
function GridMaze¶
建立空白迷宮。
Parameters:
cols迷宮欄數,範圍為 1 到 kMaxWidth。rows迷宮列數,範圍為 1 到 kMaxHeight。
Exception:
std::invalid_argument若尺寸超出範圍。
function IsWall¶
Parameters:
x網格 x 座標。y網格 y 座標。
Returns:
指定位置是否為牆;迷宮外一律回傳 true。
function Render¶
繪製物件。預設使用物件的素材、方向與顏色繪製所在格。
Parameters:
engine所屬引擎的借用指標。
Implements gridpp::GridObject::Render
function SetWall¶
設定一格是否為牆。
Parameters:
x網格 x 座標。y網格 y 座標。walltrue 表示牆,false 表示通道。
Exception:
std::out_of_range若座標位於迷宮外。
function SetWallAsset¶
所有牆使用同一素材;最後呼叫此函式會切換至單一素材模式。
function SetWallTiles¶
設定自動拼接牆面使用的六種素材,並切換至自動拼接模式。
inline void gridpp::GridMaze::SetWallTiles (
const std::string & isolated,
const std::string & end,
const std::string & straight,
const std::string & corner,
const std::string & tee,
const std::string & cross
)
Parameters:
isolated孤立牆素材。end端點素材。straight直線素材。corner轉角素材。teeT 形素材。cross十字素材。
function height¶
function width¶
The documentation for this class was generated from the following file GridMaze.h