mirror of
https://git.kittycat.homes/zoe/codename-routes.git
synced 2024-08-15 03:18:26 +00:00
improve generation even more
This commit is contained in:
parent
4daf1fe0ff
commit
929e296fb7
3 changed files with 46 additions and 43 deletions
Binary file not shown.
|
@ -1,9 +1,9 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
export var xsize = 1048
|
export var xsize = 142
|
||||||
export var ysize = 1048
|
export var ysize = 142
|
||||||
var zsize = 10
|
var zsize = 10
|
||||||
export var cityname = "dsfdsfdsfdsfsfkdsjfksdjf"
|
export var cityname = "käse"
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
StateServer.generate_world(xsize, ysize, zsize, cityname)
|
StateServer.generate_world(xsize, ysize, zsize, cityname)
|
||||||
|
|
|
@ -9,7 +9,6 @@ pub struct World {
|
||||||
pub zsize: usize,
|
pub zsize: usize,
|
||||||
tiles: Vec<Vec<Vec<tiles::Tiletypes>>>,
|
tiles: Vec<Vec<Vec<tiles::Tiletypes>>>,
|
||||||
seed: String,
|
seed: String,
|
||||||
tileattributes: tiles::Attributelists,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl World {
|
impl World {
|
||||||
|
@ -34,50 +33,36 @@ impl World {
|
||||||
let mut rng = gen::get_rng(self.seed.to_owned());
|
let mut rng = gen::get_rng(self.seed.to_owned());
|
||||||
let noisemap = gen::get_noise(&mut rng, (self.xsize, self.ysize));
|
let noisemap = gen::get_noise(&mut rng, (self.xsize, self.ysize));
|
||||||
|
|
||||||
// return array with all changed tiles, needs rework
|
|
||||||
let mut ret: Vector3Array = Vector3Array::new();
|
let mut ret: Vector3Array = Vector3Array::new();
|
||||||
for x in 0..self.xsize {
|
for x in 0..self.xsize {
|
||||||
for y in 0..self.ysize {
|
for y in 0..self.ysize {
|
||||||
ret.push(Vector3::new(x as f32, y as f32, 0.0));
|
ret.push(Vector3::new(x as f32, y as f32, 0.0));
|
||||||
if noisemap.get_value(x, y) > 0.5 {
|
if noisemap.get_value(x, y) > 0.4 {
|
||||||
self.tiles[x][y][0] = tiles::Tiletypes::Rock;
|
ret.append(&self.stack_tiles(
|
||||||
self.tiles[x][y][1] = tiles::Tiletypes::Rock;
|
4,
|
||||||
ret.push(Vector3::new(x as f32, y as f32, 1.0));
|
tiles::Tiletypes::Grass,
|
||||||
self.tiles[x][y][2] = tiles::Tiletypes::Rock;
|
tiles::Tiletypes::Dirt,
|
||||||
ret.push(Vector3::new(x as f32, y as f32, 2.0));
|
(x, y),
|
||||||
self.tiles[x][y][3] = tiles::Tiletypes::Rock;
|
));
|
||||||
ret.push(Vector3::new(x as f32, y as f32, 3.0));
|
} else if noisemap.get_value(x, y) > 0.3 {
|
||||||
if noisemap.get_value(x, y) > 0.6 {
|
ret.append(&self.stack_tiles(
|
||||||
self.tiles[x][y][4] = tiles::Tiletypes::Rock;
|
3,
|
||||||
ret.push(Vector3::new(x as f32, y as f32, 4.0));
|
tiles::Tiletypes::Grass,
|
||||||
}
|
tiles::Tiletypes::Dirt,
|
||||||
if noisemap.get_value(x, y) > 0.7 {
|
(x, y),
|
||||||
self.tiles[x][y][5] = tiles::Tiletypes::Rock;
|
));
|
||||||
ret.push(Vector3::new(x as f32, y as f32, 5.0));
|
} else if noisemap.get_value(x, y) > 0.2 {
|
||||||
}
|
ret.append(&self.stack_tiles(
|
||||||
|
2,
|
||||||
|
tiles::Tiletypes::Grass,
|
||||||
}
|
tiles::Tiletypes::Dirt,
|
||||||
else if noisemap.get_value(x, y) > 0.2 {
|
(x, y),
|
||||||
self.tiles[x][y][0] = tiles::Tiletypes::Dirt;
|
));
|
||||||
if noisemap.get_value(x, y) > 0.3 {
|
} else if noisemap.get_value(x, y) > -0.3 {
|
||||||
self.tiles[x][y][1] = tiles::Tiletypes::Dirt;
|
|
||||||
ret.push(Vector3::new(x as f32, y as f32, 1.0));
|
|
||||||
self.tiles[x][y][2] = tiles::Tiletypes::Grass;
|
|
||||||
ret.push(Vector3::new(x as f32, y as f32, 2.0));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
self.tiles[x][y][1] = tiles::Tiletypes::Grass;
|
|
||||||
ret.push(Vector3::new(x as f32, y as f32, 1.0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if noisemap.get_value(x, y) > 0.0 {
|
|
||||||
self.tiles[x][y][0] = tiles::Tiletypes::Grass;
|
self.tiles[x][y][0] = tiles::Tiletypes::Grass;
|
||||||
}
|
} else if noisemap.get_value(x, y) > -0.4 {
|
||||||
else if noisemap.get_value(x, y) > -0.1 {
|
|
||||||
self.tiles[x][y][0] = tiles::Tiletypes::Sand;
|
self.tiles[x][y][0] = tiles::Tiletypes::Sand;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
self.tiles[x][y][0] = tiles::Tiletypes::WaterSlab;
|
self.tiles[x][y][0] = tiles::Tiletypes::WaterSlab;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,6 +70,25 @@ impl World {
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn stack_tiles(
|
||||||
|
&mut self,
|
||||||
|
height: usize,
|
||||||
|
top: tiles::Tiletypes,
|
||||||
|
filler: tiles::Tiletypes,
|
||||||
|
pos: (usize, usize),
|
||||||
|
) -> Vector3Array {
|
||||||
|
let mut positions = Vector3Array::new();
|
||||||
|
for z in 0..height {
|
||||||
|
positions.push(Vector3::new(pos.0 as f32, pos.1 as f32, z as f32));
|
||||||
|
if z == height - 1 {
|
||||||
|
self.tiles[pos.0][pos.1][z] = top;
|
||||||
|
} else {
|
||||||
|
self.tiles[pos.0][pos.1][z] = filler;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
positions
|
||||||
|
}
|
||||||
|
|
||||||
pub fn new(xsize: usize, ysize: usize, zsize: usize, seed: String) -> World {
|
pub fn new(xsize: usize, ysize: usize, zsize: usize, seed: String) -> World {
|
||||||
World {
|
World {
|
||||||
xsize,
|
xsize,
|
||||||
|
@ -92,7 +96,6 @@ impl World {
|
||||||
zsize,
|
zsize,
|
||||||
tiles: get_vec3(xsize, ysize, zsize),
|
tiles: get_vec3(xsize, ysize, zsize),
|
||||||
seed,
|
seed,
|
||||||
tileattributes: tiles::Attributelists::new(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue