-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
134 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef INCLUDED_DUNGEON_TEMPLATE_LIBRARY_C99 | ||
#define INCLUDED_DUNGEON_TEMPLATE_LIBRARY_C99 | ||
//:::::----------::::::::::----------:::::// | ||
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
|
||
#include "DungeonBinarization.h" | ||
#include "DungeonNoise.h" | ||
#include "DungeonOutput.h" | ||
#include "DungeonRandom.h" | ||
#include "DungeonStandard.h" | ||
|
||
#include "FractalIsland.h" | ||
#include "MazeDig.h" | ||
#include "SimpleRogueLike.h" | ||
|
||
#endif //Included Dungeon Template Library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
//2値化処理 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
#include "DungeonRandom.h" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
#include <stddef.h> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
#include <stddef.h> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
//全てのマスを0で埋める | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
#include <stdlib.h> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
#include <stdlib.h> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
#include <stdlib.h> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
#include <stdlib.h> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef INCLUDED_DUNGEON_TEMPLATE_LIBRARY | ||
#define INCLUDED_DUNGEON_TEMPLATE_LIBRARY | ||
//:::::----------::::::::::----------:::::// | ||
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
|
||
#include "DungeonBinarization.hpp" | ||
#include "DungeonNoise.hpp" | ||
#include "DungeonOutput.hpp" | ||
#include "DungeonRandom.hpp" | ||
#include "DungeonStandard.hpp" | ||
|
||
#include "FractalIsland.hpp" | ||
#include "MazeDig.hpp" | ||
#include "RogueLike.hpp" | ||
#include "SimpleRogueLike.hpp" | ||
#include "SimpleTerrain1.hpp" | ||
#include "SimpleVoronoiIsland.hpp" | ||
|
||
#endif //Included Dungeon Template Library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
#include <cstddef> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
#include <cstddef> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
#include <cstddef> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
#include <cstdint> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,34 +4,36 @@ | |
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
#include <cstddef> | ||
|
||
//Dungeon Template Library Namespace | ||
namespace dtl { | ||
|
||
//全てのマスを0で埋める | ||
template<typename STL_> | ||
constexpr void dungeonInit(STL_& stl_) noexcept { | ||
for (std::size_t i{}; i < stl_.size(); ++i) | ||
for (std::size_t j{}; j < stl_[i].size(); ++j) | ||
j = 0; | ||
stl_[i][j] = 0; | ||
} | ||
|
||
//全てのマスを指定した数値で埋める | ||
template<typename Int_, typename STL_> | ||
constexpr void dungeonInit(STL_& stl_, const Int_ value_) noexcept { | ||
for (std::size_t i{}; i < stl_.size(); ++i) | ||
for (std::size_t j{}; j < stl_[i].size(); ++j) | ||
j = value_; | ||
stl_[i][j] = value_; | ||
} | ||
|
||
//全てのマスを0で埋める | ||
template<typename STL_> | ||
constexpr void dungeonInit_RangeBasedFor(STL_& stl_) noexcept { | ||
for (auto&& i : stl_) | ||
for (auto&& j : i) | ||
j = 0; | ||
} | ||
|
||
//全てのマスを指定した数値で埋める | ||
template<typename Int_, typename STL_> | ||
constexpr void dungeonInit_RangeBasedFor(STL_& stl_, const Int_ value_) noexcept { | ||
for (auto&& i : stl_) | ||
|
@@ -49,10 +51,10 @@ namespace dtl { | |
return true; | ||
} | ||
|
||
// | ||
//値が全て一致しているか確認する | ||
template<typename STL_> | ||
constexpr bool dungeonArrayCheck(const STL_& stl_) noexcept { | ||
if (stl_.size()==0 || stl_.front().size()==0) return false; | ||
if (stl_.size() == 0 || stl_.front().size() == 0) return false; | ||
const auto& stl_value{ stl_.front().front() }; | ||
for (std::size_t i{}; i < stl_.size(); ++i) | ||
for (std::size_t j{}; j < stl_[i].size(); ++j) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
#include <cstddef> | ||
|
@@ -17,9 +18,10 @@ namespace dtl { | |
template<typename Int_> | ||
class FractalIsland { | ||
public: | ||
FractalIsland() = default; | ||
//コンストラクタ | ||
constexpr FractalIsland() noexcept = default; | ||
template<typename STL_> | ||
constexpr explicit FractalIsland(STL_& world_map, std::size_t seed_ = 0, const std::int_fast32_t max_value_ = 255) { | ||
constexpr explicit FractalIsland(STL_& world_map, std::size_t seed_ = 0, const std::int_fast32_t max_value_ = 255) noexcept { | ||
create(world_map, seed_, max_value_); | ||
} | ||
//ワールドマップ生成 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
#include <cstddef> | ||
|
@@ -22,17 +23,18 @@ namespace dtl { | |
template<typename Int_> | ||
class MazeDig { | ||
public: | ||
MazeDig() = default; | ||
//コンストラクタ | ||
constexpr MazeDig() noexcept = default; | ||
template<typename STL_> | ||
constexpr explicit MazeDig(STL_& data, const Int_ v1_, const Int_ v2_) { | ||
constexpr explicit MazeDig(STL_& data, const Int_ v1_, const Int_ v2_) noexcept { | ||
mazeDig_Create(data, v1_, v2_); | ||
} | ||
template<typename STL_> | ||
constexpr explicit MazeDig(STL_& data, const Int_ v1_) { | ||
constexpr explicit MazeDig(STL_& data, const Int_ v1_) noexcept { | ||
mazeDig_Create(data, v1_, static_cast<Int_>(maze_dig_type_way)); | ||
} | ||
template<typename STL_> | ||
constexpr explicit MazeDig(STL_& data) { | ||
constexpr explicit MazeDig(STL_& data) noexcept { | ||
mazeDig_Create(data, static_cast<Int_>(maze_dig_type_wall), static_cast<Int_>(maze_dig_type_way)); | ||
} | ||
private: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
#include <cstddef> | ||
|
@@ -42,9 +43,9 @@ namespace dtl { | |
class RogueLike { | ||
public: | ||
//コンストラクタ | ||
RogueLike() = default; | ||
constexpr RogueLike() noexcept = default; | ||
template<typename STL_> | ||
constexpr explicit RogueLike(STL_& stl_, const std::size_t way_max_) { | ||
constexpr explicit RogueLike(STL_& stl_, const std::size_t way_max_) noexcept { | ||
create(stl_, way_max_); | ||
} | ||
//マップ生成 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
#include <cstdint> | ||
|
@@ -44,19 +45,19 @@ namespace dtl { | |
//マップの道 [部屋ID(前)][繋がる先の部屋ID(後) , (0.X座標 , 1.Y座標) , (前)側の通路の位置 , (後)側の通路の位置] | ||
std::vector<std::array<std::size_t, 4>> dungeon_road{}; | ||
public: | ||
|
||
SimpleRogueLike() = default; | ||
//コンストラクタ | ||
constexpr SimpleRogueLike() noexcept = default; | ||
template <typename STL_> | ||
SimpleRogueLike(STL_& stl_, const std::size_t division_min = 3, const std::size_t division_rand_max = 4, const std::size_t room_min_x = 5, const std::size_t room_rand_max_x = 2, const std::size_t room_min_y = 5, const std::size_t room_rand_max_y = 2) { | ||
constexpr explicit SimpleRogueLike(STL_& stl_, const std::size_t division_min = 3, const std::size_t division_rand_max = 4, const std::size_t room_min_x = 5, const std::size_t room_rand_max_x = 2, const std::size_t room_min_y = 5, const std::size_t room_rand_max_y = 2) noexcept { | ||
create(stl_, division_min, division_rand_max, room_min_x, room_rand_max_x, room_min_y, room_rand_max_y); | ||
} | ||
|
||
//ローグライク生成関数 | ||
template <typename STL_> | ||
void create(STL_& stl_, const std::size_t division_min = 3, const std::size_t division_rand_max = 4, const std::size_t room_min_x = 5, const std::size_t room_rand_max_x = 2, const std::size_t room_min_y = 5, const std::size_t room_rand_max_y = 2) noexcept { | ||
constexpr void create(STL_& stl_, const std::size_t division_min = 3, const std::size_t division_rand_max = 4, const std::size_t room_min_x = 5, const std::size_t room_rand_max_x = 2, const std::size_t room_min_y = 5, const std::size_t room_rand_max_y = 2) noexcept { | ||
if (stl_.size() == 0 || stl_.front().size() == 0) return; | ||
//マップの区分け数 (部屋の個数) 0~nまでの部屋ID | ||
const std::size_t mapDivCount{ division_min + (std::size_t)rnd(1,(std::int_fast32_t)division_rand_max) }; //マップの区分け数 (部屋の個数) 0~nまでの部屋ID | ||
const std::size_t mapDivCount{ division_min + (std::size_t)rnd(1,(std::int_fast32_t)division_rand_max) }; //マップの区分け数 (部屋の個数) 0~yまでの部屋ID | ||
|
||
dungeon_division.resize(mapDivCount); | ||
dungeon_room.resize(mapDivCount); | ||
|
@@ -149,12 +150,12 @@ namespace dtl { | |
dungeon_room[i][0] = dungeon_division[i][2] + 1; | ||
dungeon_room[i][1] = dungeon_division[i][3] + 1; | ||
} | ||
std::size_t l{ (std::size_t)rnd(1,(std::int_fast32_t)(dungeon_division[i][0] - dungeon_room[i][0] - 5)) + 2 }; | ||
std::size_t m{ (std::size_t)rnd(1,(std::int_fast32_t)(dungeon_division[i][1] - dungeon_room[i][1] - 5)) + 2 }; | ||
const std::size_t l{ (std::size_t)rnd(1,(std::int_fast32_t)(dungeon_division[i][0] - dungeon_room[i][0] - 5)) + 2 }; | ||
const std::size_t n{ (std::size_t)rnd(1,(std::int_fast32_t)(dungeon_division[i][1] - dungeon_room[i][1] - 5)) + 2 }; | ||
dungeon_room[i][0] += l; | ||
dungeon_room[i][2] += l; | ||
dungeon_room[i][1] += m; | ||
dungeon_room[i][3] += m; | ||
dungeon_room[i][1] += n; | ||
dungeon_room[i][3] += n; | ||
|
||
for (std::size_t j{ dungeon_room[i][2] }; j < dungeon_room[i][0]; ++j) | ||
for (std::size_t k{ dungeon_room[i][3] }; k < dungeon_room[i][1]; ++k) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#ifndef INCLUDED_DUNGEON_TEMPLATE_LIBRARY_SIMPLE_TERRAIN1 | ||
#define INCLUDED_DUNGEON_TEMPLATE_LIBRARY_SIMPLE_TERRAIN1 | ||
//:::::----------::::::::::----------:::::// | ||
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
#include <cstddef> | ||
#include "DungeonRandom.hpp" | ||
|
||
//Dungeon Template Library Namespace | ||
namespace dtl { | ||
|
||
template<typename Int_> | ||
class SimpleTerrain1 { | ||
public: | ||
//ƒRƒ“ƒXƒgƒ‰ƒNƒ^ | ||
constexpr SimpleTerrain1() noexcept = default; | ||
template<typename STL_> | ||
constexpr explicit SimpleTerrain1(STL_& stl_, const Int_ v1_, const std::size_t v2_ = 2) noexcept { | ||
create(stl_, v1_, v2_); | ||
} | ||
template<typename STL_> | ||
constexpr void create(STL_& stl_, const Int_ v1_, const std::size_t v2_ = 2) noexcept { | ||
|
||
for (std::size_t i{}; i < stl_.size(); i += v2_) { | ||
for (std::size_t j{}; j < stl_[i].size(); j += v2_) { | ||
stl_[i][j] = static_cast<Int_>(v1_); | ||
} | ||
} | ||
|
||
} | ||
|
||
|
||
}; | ||
|
||
} | ||
|
||
#endif //Included Dungeon Template Library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
// Dungeon Template Library // | ||
// Made by Gaccho. // | ||
// This code is licensed under CC0. // | ||
// [email protected] // | ||
//:::::----------::::::::::----------:::::// | ||
|
||
#include <cstddef> | ||
|
@@ -26,9 +27,9 @@ namespace dtl { | |
class SimpleVoronoiIsland { | ||
public: | ||
//コンストラクタ | ||
SimpleVoronoiIsland() = default; | ||
constexpr SimpleVoronoiIsland() noexcept = default; | ||
template<typename STL_> | ||
constexpr explicit SimpleVoronoiIsland(STL_& stl_, const std::size_t count_ = 100, const double rbool_ = 0.4, const Int_ land_ = 1, const Int_ sea_ = 0) { | ||
constexpr explicit SimpleVoronoiIsland(STL_& stl_, const std::size_t count_ = 100, const double rbool_ = 0.4, const Int_ land_ = 1, const Int_ sea_ = 0) noexcept { | ||
create(stl_, count_, rbool_, land_, sea_); | ||
} | ||
template<typename STL_> | ||
|