mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-15 17:25:32 +00:00
Added varying terrains, as suggested by zas
This commit is contained in:
parent
278b0428dc
commit
c50f5510f5
@ -50,7 +50,7 @@ aliasof=g
|
||||
[/terrain]
|
||||
|
||||
[terrain]
|
||||
image=grassland
|
||||
image=grassland,grassland,grassland,grassland,grassland,grassland-flowers
|
||||
name=grassland
|
||||
char=g
|
||||
green=200
|
||||
|
@ -1282,7 +1282,9 @@ SDL_Surface* display::getTerrain(gamemap::TERRAIN terrain,IMAGE_TYPE image_type,
|
||||
int x, int y, const std::string& direction)
|
||||
{
|
||||
const bool tower = (terrain == gamemap::TOWER);
|
||||
std::string image = "terrain/" + map_.get_terrain_info(terrain).image();
|
||||
std::string image = "terrain/" + (direction.empty() ?
|
||||
map_.get_terrain_info(terrain).image(x,y) :
|
||||
map_.get_terrain_info(terrain).default_image());
|
||||
|
||||
if(tower) {
|
||||
size_t i;
|
||||
|
@ -10,17 +10,19 @@
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#include "terrain.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
terrain_type::terrain_type() : image_("void"), type_(' '), letter_(' ')
|
||||
terrain_type::terrain_type() : images_(1,"void"), type_(' '), letter_(' ')
|
||||
{}
|
||||
|
||||
terrain_type::terrain_type(config& cfg)
|
||||
{
|
||||
image_ = cfg.values["image"];
|
||||
images_ = config::split(cfg.values["image"]);
|
||||
name_ = cfg.values["name"];
|
||||
const std::string& letter = cfg.values["char"];
|
||||
assert(!letter.empty());
|
||||
@ -35,9 +37,17 @@ terrain_type::terrain_type(config& cfg)
|
||||
colour_.read(cfg);
|
||||
}
|
||||
|
||||
const std::string& terrain_type::image() const
|
||||
const std::string& terrain_type::image(int x, int y) const
|
||||
{
|
||||
return image_;
|
||||
assert(!images_.empty());
|
||||
|
||||
return images_[(((x<<8)^3413402)+y^34984 + x*y)%images_.size()];
|
||||
}
|
||||
|
||||
const std::string& terrain_type::default_image() const
|
||||
{
|
||||
assert(!images_.empty());
|
||||
return images_.front();
|
||||
}
|
||||
|
||||
const std::string& terrain_type::name() const
|
||||
|
@ -24,7 +24,8 @@ public:
|
||||
terrain_type();
|
||||
terrain_type(config& cfg);
|
||||
|
||||
const std::string& image() const;
|
||||
const std::string& image(int x, int y) const;
|
||||
const std::string& default_image() const;
|
||||
const std::string& name() const;
|
||||
char letter() const;
|
||||
char type() const;
|
||||
@ -33,7 +34,8 @@ public:
|
||||
|
||||
bool is_alias() const;
|
||||
private:
|
||||
std::string image_, name_;
|
||||
std::vector<std::string> images_;
|
||||
std::string name_;
|
||||
|
||||
//the 'letter' is the letter that represents this
|
||||
//terrain type. The 'type' is the letter of the
|
||||
|
Loading…
x
Reference in New Issue
Block a user