-
-
Notifications
You must be signed in to change notification settings - Fork 81
中級サンプル
Kasugaccho edited this page Apr 27, 2019
·
2 revisions
#include <DTL.hpp>
#include <array>
#include <bitset>
#include <cstddef>
int main() {
//X方向の大きさ
constexpr std::size_t width{ 33 };
//Y方向の大きさ
constexpr std::size_t height{ 17 };
//ダンジョン行列 (0で初期化)
std::array<std::bitset<width>, height> matrix{ {} };
//迷路を生成 (値1の通路を作成する)
dtl::MazeDig<bool>(1).draw(matrix, width, height);
//数値出力 (区切りは「,」)
dtl::OutputNumber<bool>(",").draw(matrix, width, height);
//文字出力 (値0の場合は「##」、値1の場合は「 」が出力される)
dtl::OutputString<bool>("##", " ").draw(matrix, width, height);
}
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,0,
0,0,0,1,0,0,0,1,0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0,
0,1,1,1,0,1,0,1,0,1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,0,1,0,1,1,1,0,1,0,
0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,
0,1,0,1,1,1,0,1,0,1,0,1,1,1,0,1,1,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,
0,1,0,0,0,0,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,0,
0,1,0,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,0,1,1,1,1,1,0,1,1,1,0,1,0,1,0,
0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,1,0,
0,1,0,1,0,1,0,1,1,1,1,1,1,1,0,1,0,1,0,1,1,1,0,1,1,1,0,1,0,1,0,1,0,
0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,
0,1,0,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,0,
0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,1,0,0,0,0,0,
0,1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,0,1,1,1,1,1,0,1,0,1,0,1,1,1,1,1,0,
0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,
0,1,1,1,0,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
##################################################################
## ## ## ## ## ## ##
###### ###### ## ## ## ## ## ########## ## ###### ## ##
## ## ## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ########## ###### ## ###### ## ###### ##
## ## ## ## ## ## ## ## ## ##
## ########## ## ## ## ################## ## ###### ######
## ## ## ## ## ## ## ## ## ## ##
## ## ## ###### ###### ## ## ###### ########## ## ## ##
## ## ## ## ## ## ## ## ## ## ## ##
## ###### ## ############## ###### ###### ###### ## ## ##
## ## ## ## ## ## ##
## ## ###### ################## ########## ## ## ##########
## ## ## ## ## ## ## ## ## ##
## ###### ###### ## ## ## ########## ## ########## ## ##
## ## ## ## ## ## ##
##################################################################
#include <DTL.hpp>
#include <array>
#include <cstddef>
#include <cstdint>
int main() {
//ダンジョン行列の要素型
using shape_t = std::uint_fast8_t;
//X方向の大きさ
constexpr std::size_t width{ 33 };
//Y方向の大きさ
constexpr std::size_t height{ 17 };
//ダンジョン行列 (0で初期化)
std::array<std::array<shape_t, width>, height> matrix{ {} };
//ブロックと枠付き点グリッドを生成 (値1==枠, 値2==点グリッド, 値3==ブロック, 確率0.8==個々のブロックの生成確率)
dtl::PointGridAndSomeBlocksWithBorder<shape_t>(1, 2, 3, 0.8).draw(matrix);
//数値出力 (区切りは「,」)
dtl::OutputNumber<shape_t>(",").draw(matrix);
//文字出力 (値0==「 」, 値1==「##」, 値2==「%%」, 値3==「//」が出力される)
dtl::OutputString<shape_t>(" ", "##", "%%", "//").draw(matrix);
}
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,3,3,3,3,3,3,0,3,0,3,3,3,3,3,3,0,3,0,3,0,3,3,3,3,3,3,3,3,3,3,3,2,
2,3,1,3,1,0,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,2,
2,3,0,3,3,3,3,3,3,0,3,3,0,0,3,3,3,0,3,0,0,3,0,3,3,3,3,3,0,3,3,3,2,
2,0,1,3,1,3,1,3,1,0,1,3,1,0,1,3,1,3,1,3,1,3,1,0,1,3,1,3,1,3,1,3,2,
2,3,0,0,3,3,3,3,3,3,3,3,3,3,3,0,3,0,3,3,3,0,0,0,3,3,3,0,3,3,0,3,2,
2,3,1,3,1,3,1,3,1,3,1,0,1,0,1,0,1,3,1,3,1,3,1,0,1,3,1,3,1,3,1,3,2,
2,3,3,3,0,3,3,3,3,3,3,3,3,0,3,3,3,3,3,3,3,3,0,3,3,3,3,0,0,0,3,0,2,
2,3,1,3,1,3,1,3,1,0,1,3,1,3,1,3,1,0,1,3,1,3,1,0,1,3,1,3,1,3,1,3,2,
2,3,0,3,3,3,3,3,3,3,3,3,3,3,3,3,0,3,0,3,3,3,3,0,3,3,3,3,3,3,3,3,2,
2,3,1,3,1,3,1,3,1,3,1,3,1,0,1,3,1,0,1,0,1,0,1,3,1,0,1,3,1,3,1,3,2,
2,3,3,3,3,3,3,0,3,3,3,3,3,3,0,3,3,3,3,3,3,3,3,3,3,3,0,3,3,3,3,0,2,
2,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,0,1,3,1,3,2,
2,3,3,3,3,3,3,0,3,3,0,3,3,3,3,3,3,0,0,3,3,0,3,3,3,3,3,3,3,3,3,3,2,
2,3,1,3,1,3,1,0,1,3,1,3,1,3,1,3,1,0,1,3,1,3,1,0,1,3,1,3,1,3,1,3,2,
2,3,3,3,3,3,3,3,3,3,3,3,3,0,3,0,3,0,0,0,3,3,3,3,3,0,3,3,3,3,3,0,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%//////////// // //////////// // // //////////////////////%%
%%//##//## ##//##//##//##//##//##//##//##//##//##//##//##//##//%%
%%// //////////// //// ////// // // ////////// //////%%
%% ##//##//##//## ##//## ##//##//##//##//## ##//##//##//##//%%
%%// ////////////////////// // ////// ////// //// //%%
%%//##//##//##//##//## ## ## ##//##//##//## ##//##//##//##//%%
%%////// //////////////// //////////////// //////// // %%
%%//##//##//##//## ##//##//##//## ##//##//## ##//##//##//##//%%
%%// ////////////////////////// // //////// ////////////////%%
%%//##//##//##//##//##//## ##//## ## ## ##//## ##//##//##//%%
%%//////////// //////////// ////////////////////// //////// %%
%%//##//##//##//##//##//##//##//##//##//##//##//##//## ##//##//%%
%%//////////// //// //////////// //// ////////////////////%%
%%//##//##//## ##//##//##//##//## ##//##//## ##//##//##//##//%%
%%//////////////////////// // // ////////// ////////// %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) 2018-2021 As Project.
Distributed under the Boost Software License, Version 1.0.(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)