Comments (14)
大枠:クラス
丸 :メンバ変数
菱型:メソッド
四角:一時変数
実線:代入
破線:参照(引数に取る)
ディスプレイ表示時
graph LR
subgraph MenuDisplay
show{show}
set_content_names{set_content_names}
content_names((content_names))
end
subgraph Menu
contents((contents))
end
show -.-> content_names
set_content_names -.-> contents
set_content_names --> content_names
from rogue_game.
実行時
現状 Player
の use_item
を使ってるけどアイテム使用以外にもあるから
見直しが必要
Menu
側で実行できるのが理想ではあるがどうだか
graph LR
subgraph MenuDisplay
current_index((index))
end
subgraph Menu
contents((contents))
selected_content(selected_content)
end
current_index --> selected_content
contents --> selected_content
from rogue_game.
MenuContent
的なクラスが必要かもしれないな
from rogue_game.
contents を格納する変数
std::map<std::string, std::function<void(void)> > content_table = {
{"Content Name", std::bind(player_.use_item, Gold{100})},
};
みたいな感じでできるかいな
アイテム消費とか技発動とかの引数を統一出来たら解決するんだが
それか、プレイヤーのポインタ経由で実行するか
複雑になりそうでやだな
selected_index からイテレータ越しに
選択された content を取得するつもり
選択するとアクションが実行されるとき
*(selected_content_itr).second(); // player_.use_item(Gold{100});
content_table.erase(selected_content_itr);
選択すると次の Menu が展開されるとき
Menu
と MenuDisplay
わけてるから面倒くさそうな感じはする。
実行すると、
- MenuDisplay(引数で位置を指定済み)と Menu(content 格納済み) のインスタンスを生成
- キーボード入力のフォーカスを移す
必要がある。
void expand_menu(contents, position)
{
...
}
これを contents_table に格納するときは、
std::bind(expand_menu, contents, position); // std::function<void(void)>
という感じだろうか
つまり
メニュー操作表示から実行までが関数内で閉じていなければならないのか
ちょっとイメージがぼんやりしてるけど
from rogue_game.
Space と BackSpace の入力を無視すると考えやすい
流れ的には、
graph TB
desc1[Menu クラスの仕事]
desc2[MenuDisplay クラスの仕事]
style desc2 fill: #ff5
step1[外部から KeyState を受け取る]
step2.1[矢印キーにより current_index を変更]
step2.2[Enter キーで該当項目にバインドされた関数を実行]
step3.1[MenuDisplay で表示]
style step3.1 fill: #ff5
step3.2[MenuDisplay を非表示にする]
style step3.2 fill: #ff5
step1 --> step2.1
step1 --> step2.2
step2.1 --> step3.1
step2.2 --> step3.2
あれ、誰がダンジョンモードへの復帰を指示するんだろう
from rogue_game.
バインドされる関数に必要な引数
メニュー表示
- next_menu
攻撃
- player (攻撃力などを参照するため)
- current_map (敵の情報を参照するため)
アイテム
- player or inventory (アイテムの種類と個数を取得するため)
- current_map (敵にぶつけたりするため)
設定とか終了とか
- game_master ?
てか全部 player と current_map を参照すればよくね?ってなりそう
from rogue_game.
セレクトメニューをアイテム使用に使うくらいしか考えてなかったけど
思えばゲーム進行全体に干渉できてしまうから
その立ち位置から考え直した方がいいのかも知れない
from rogue_game.
lisp インタプリタ開発から何かしらヒントが得られると踏んでいる
from rogue_game.
GameMaster の挙動に干渉するなら現状では
return menu_content.at(“hoge”).second();
で、Mode::Huga
を返すみたいなのが手っ取り早いか
from rogue_game.
class Menu
{
public:
ContentsType contents;
Mode execute(std::string key, std::unique_ptr<Menu>& target_menu) const
{
return content.at(key).execute(target_menu);
}
};
class GameMaster
{
public:
std::unique_ptr<Menu> current_menu;
Mode select_menu()
{
KeyType key;
return current_menu.execute(key, current_menu);
}
std::unique_ptr<Menu> current_menu;
};
from rogue_game.
入れ子構造は出来たから、あとは各要素との連携
from rogue_game.
GameMaster と Menu の関係を見直したほうがいい
from rogue_game.
GameMaster と Menu の関係を見直したほうがいい
やっぱ外に出すべきだな
from rogue_game.
GameMaster のポインタ経由で操作したら動作した
あとは動作定義をどう分けて書くかだな
from rogue_game.
Related Issues (9)
- Action handler specification HOT 12
- Layer of map elements. HOT 1
- Class associations draft HOT 3
- Release plan
- Draft of development philosophy HOT 1
- List of game modes draft HOT 3
- Draft of GitPitch slide HOT 1
- Organization include files HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rogue_game.