예제 #1
0
sanguis::creator::impl::result
sanguis::creator::impl::generators::maze(
	sanguis::creator::impl::parameters const &_parameters
)
{
	sanguis::creator::impl::reachable_grid initial_maze{
		sanguis::creator::impl::reachable_grid::dim(
			15u,
			15u
		),
		sanguis::creator::impl::reachable(false)
	};

	sanguis::creator::impl::filled_rect(
		sanguis::creator::rect{
			sanguis::creator::rect::vector{
				1u,
				1u
			},
			sanguis::creator::rect::dim{
				5u,
				5u
			}
		},
		[
			&initial_maze
		](
			sanguis::creator::pos const &_p
		){
			initial_maze[
				_p
			] =
				sanguis::creator::impl::reachable(true);
		}
	);

	sanguis::creator::impl::generate_maze(
		initial_maze,
		_parameters.randgen()
	);

	sanguis::creator::grid
	grid{
		sanguis::creator::impl::maze_to_tile_grid(
			initial_maze,
			1u,
			2u,
			sanguis::creator::tile::nothing,
			sanguis::creator::tile::concrete_wall
		)
	};

	sanguis::creator::opening_container_array const
	openings(
		sanguis::creator::impl::place_openings(
			grid,
			_parameters.randgen(),
			_parameters.opening_count_array()
		)
	);

	sanguis::creator::spawn_container const
	spawners{
		sanguis::creator::impl::place_spawners(
			_parameters.log(),
			grid,
			openings,
			20u,
			_parameters.randgen(),
			sanguis::creator::impl::enemy_type_container{
				sanguis::creator::enemy_type::wolf_black,
				sanguis::creator::enemy_type::wolf_brown,
				sanguis::creator::enemy_type::wolf_white,
				sanguis::creator::enemy_type::zombie00,
				sanguis::creator::enemy_type::zombie01,
				sanguis::creator::enemy_type::spider,
				sanguis::creator::enemy_type::skeleton,
				sanguis::creator::enemy_type::ghost,
				sanguis::creator::enemy_type::maggot
			},
			_parameters.spawn_boss()
		)
	};

	sanguis::creator::destructible_container const
	destructibles{
		sanguis::creator::impl::place_destructibles(
			grid,
			_parameters.randgen()
		)
	};

	sanguis::creator::background_grid const grid_bg(
		grid.size(),
		sanguis::creator::background_tile::asphalt
	);

	return
		sanguis::creator::impl::result(
			grid,
			grid_bg,
			openings,
			spawners,
			destructibles
		);
}
예제 #2
0
sanguis::creator::impl::result
sanguis::creator::impl::generators::graveyard(
	sanguis::creator::impl::parameters const &_parameters
)
{
	sanguis::creator::impl::reachable_grid
	initial_maze{
		sanguis::creator::grid::dim{
			9u,
			9u
		},
		sanguis::creator::impl::reachable(false)
	};

	sanguis::creator::impl::generate_maze(
		initial_maze,
		_parameters.randgen()
	);

	sanguis::creator::grid grid{
		sanguis::creator::impl::maze_to_tile_grid(
			initial_maze,
			1u,
			5u,
			sanguis::creator::tile::nothing,
			sanguis::creator::tile::hedge
		)
	};

	sanguis::creator::opening_container_array openings(
		sanguis::creator::impl::place_openings(
			grid,
			_parameters.randgen(),
			_parameters.opening_count_array()
		)
	);

	typedef
	fcppt::random::distribution::basic<
		sanguis::creator::impl::random::uniform_int<
			unsigned
		>
	>
	uniform_int2;

	auto fill_tile_random(
		fcppt::random::make_variate(
			_parameters.randgen(),
			uniform_int2{
				uniform_int2::param_type::min{
					0u
				},
				uniform_int2::param_type::max{
					10u
				}
			}
		)
	);

	typedef
	fcppt::random::distribution::basic<
		sanguis::creator::impl::random::uniform_int<
			sanguis::creator::tile
		>
	> uniform_tile_enum;

	sanguis::creator::background_grid grid_bg{
		grid.size(),
		sanguis::creator::background_tile::grass
	};

	// TODO: Draw this from a container
	auto random_dirt_grass(
		fcppt::random::make_variate(
			_parameters.randgen(),
			uniform_int2{
				uniform_int2::param_type::min{
					0u
				},
				uniform_int2::param_type::max{
					1u
				}
			}
		)
	);

	for(
		auto const pos
		:
		sanguis::creator::impl::interior_range(
			grid_bg
		)
	)
		pos.value() =
			random_dirt_grass()
			?
			sanguis::creator::background_tile::dirt
			:
			sanguis::creator::background_tile::grass;

	auto random_grave(
		fcppt::random::make_variate(
			_parameters.randgen(),
			uniform_tile_enum(
				uniform_tile_enum::param_type::min(
					sanguis::creator::tile::grave2
				),
				uniform_tile_enum::param_type::max(
					sanguis::creator::tile::grave5
				)
			)
		)
	);

	for(
		auto const cell
		:
		fcppt::container::grid::make_pos_ref_range(
			grid
		)
	)
	{
		if(
			cell.value()
			==
			sanguis::creator::tile::nothing
			&&
			fill_tile_random()
			== 0
			&&
			FCPPT_ASSERT_OPTIONAL_ERROR(
				fcppt::container::grid::at_optional(
					grid_bg,
					cell.pos()
				)
			).get()
			==
			sanguis::creator::background_tile::grass
		)
			cell.value() =
				random_grave();
	}

	sanguis::creator::spawn_container spawners{
		sanguis::creator::impl::place_spawners(
			_parameters.log(),
			grid,
			openings,
			10u,
			_parameters.randgen(),
			sanguis::creator::impl::enemy_type_container{
				sanguis::creator::enemy_type::zombie00,
				sanguis::creator::enemy_type::zombie01,
				sanguis::creator::enemy_type::skeleton,
				sanguis::creator::enemy_type::ghost
			},
			_parameters.spawn_boss(),
			sanguis::creator::tile::grave1
		)
	};

	return
		sanguis::creator::impl::result(
			std::move(
				grid
			),
			std::move(
				grid_bg
			),
			std::move(
				openings
			),
			std::move(
				spawners
			),
			sanguis::creator::destructible_container() // TODO
		);
}