Village number slider is now proportional in random map generation.
This commit is contained in:
parent
ac76ee6d79
commit
b8763a6d54
3 changed files with 18 additions and 10 deletions
|
@ -54,7 +54,7 @@ map_height=60
|
|||
iterations=1000
|
||||
hill_size=10
|
||||
max_lakes=40
|
||||
villages=800
|
||||
villages=25
|
||||
players=2
|
||||
min_lake_height=500
|
||||
lake_size=150
|
||||
|
|
|
@ -679,7 +679,9 @@ std::string default_generate_map(size_t width, size_t height,
|
|||
}
|
||||
|
||||
std::cerr << "placing villages...\n";
|
||||
|
||||
std::cerr << "villages: ";
|
||||
std::cerr << nvillages;
|
||||
std::cerr << "...\n";
|
||||
//place villages. We attempt to place nvillages, all at random locations.
|
||||
//After a location is chosen, we can through [village] tags to see
|
||||
//what kind of village we should place on that type of terrain. If no
|
||||
|
@ -687,8 +689,8 @@ std::string default_generate_map(size_t width, size_t height,
|
|||
//will be placed.
|
||||
std::set<location> villages;
|
||||
for(size_t village = 0; village != nvillages; ++village) {
|
||||
const int x = rand()%width;
|
||||
const int y = rand()%height;
|
||||
const int x = rand()%width/3+width/3;
|
||||
const int y = rand()%height/3+height/3;
|
||||
const std::string str(1,terrain[x][y]);
|
||||
const config* const child = cfg.find_child("village","terrain",str);
|
||||
if(child != NULL) {
|
||||
|
@ -833,7 +835,7 @@ map_generator* get_map_generator(const std::string& name)
|
|||
int main(int argc, char** argv)
|
||||
{
|
||||
int x = 50, y = 50, iterations = 50, hill_size = 50, lakes=3,
|
||||
nvillages = 500, nplayers = 2;
|
||||
nvillages = 25, nplayers = 2;
|
||||
if(argc >= 2) {
|
||||
x = atoi(argv[1]);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
default_map_generator::default_map_generator(const config& game_config)
|
||||
: width_(40), height_(40), iterations_(1000), hill_size_(10), max_lakes_(20),
|
||||
nvillages_(300), nplayers_(2), cfg_(NULL)
|
||||
nvillages_(25), nplayers_(2), cfg_(NULL)
|
||||
{
|
||||
const config* const cfg = game_config.find_child("map_generator","name",name());
|
||||
if(cfg != NULL) {
|
||||
|
@ -117,7 +117,7 @@ void default_map_generator::user_config(display& disp)
|
|||
gui::slider players_slider(disp,slider_rect);
|
||||
players_slider.set_min(2);
|
||||
players_slider.set_max(max_players);
|
||||
players_slider.set_value(2);
|
||||
if (players_slider.value() < 2 || players_slider.value() > 8) players_slider.set_value(2);
|
||||
|
||||
const int min_width = 20;
|
||||
const int max_width = 200;
|
||||
|
@ -156,8 +156,8 @@ void default_map_generator::user_config(display& disp)
|
|||
hillsize_slider.set_max(max_hillsize);
|
||||
hillsize_slider.set_value(hill_size_);
|
||||
|
||||
const int min_villages = 10;
|
||||
const int max_villages = 10000;
|
||||
const int min_villages = 0;
|
||||
const int max_villages = 50;
|
||||
|
||||
slider_rect.y = villages_rect.y;
|
||||
gui::slider villages_slider(disp,slider_rect);
|
||||
|
@ -221,6 +221,12 @@ void default_map_generator::user_config(display& disp)
|
|||
height_str << height_;
|
||||
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,height_str.str(),
|
||||
slider_right+horz_margin,height_rect.y);
|
||||
|
||||
std::stringstream villages_str;
|
||||
villages_str << nvillages_;
|
||||
villages_str << "/1000 tiles";
|
||||
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,villages_str.str(),
|
||||
slider_right+horz_margin,villages_rect.y);
|
||||
|
||||
close_button.draw();
|
||||
|
||||
|
@ -237,7 +243,7 @@ std::string default_map_generator::name() const { return "default"; }
|
|||
std::string default_map_generator::create_map(const std::vector<std::string>& args)
|
||||
{
|
||||
if(cfg_ != NULL)
|
||||
return default_generate_map(width_,height_,iterations_,hill_size_,max_lakes_,nvillages_,nplayers_,*cfg_);
|
||||
return default_generate_map(width_,height_,iterations_,hill_size_,max_lakes_,nvillages_*width_*height_/1000,nplayers_,*cfg_);
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue