mirror of
https://git.kittycat.homes/zoe/codename-routes.git
synced 2024-08-15 03:18:26 +00:00
aweiedsjfjdshf
This commit is contained in:
parent
797aab3443
commit
e0c020bbd3
8 changed files with 33 additions and 32 deletions
|
@ -1,3 +1,3 @@
|
||||||
source_md5="30885b768ea8e61f6f1072099ba8c3af"
|
source_md5="eaa193d5026134717cb7a679b662d485"
|
||||||
dest_md5="3858a5d8c4a4ecf0f3bd148fa4d0440a"
|
dest_md5="2cdafd45bc53a3c67ee607a5f4ff9fd0"
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 7 KiB After Width: | Height: | Size: 8.7 KiB |
|
@ -1,8 +1,8 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
export var xsize = 512
|
export var xsize = 16
|
||||||
export var ysize = 512
|
export var ysize = 16
|
||||||
export var zsize = 16
|
export var zsize = 3
|
||||||
export var cityname = "night city"
|
export var cityname = "night city"
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
|
Binary file not shown.
|
@ -2,7 +2,6 @@ use gdnative::prelude::*;
|
||||||
use rand::prelude::StdRng;
|
use rand::prelude::StdRng;
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use rand_seeder::Seeder;
|
use rand_seeder::Seeder;
|
||||||
use strum::EnumCount;
|
|
||||||
|
|
||||||
mod tiles;
|
mod tiles;
|
||||||
|
|
||||||
|
@ -35,43 +34,28 @@ impl World {
|
||||||
pub fn generate(&mut self) -> Vector3Array {
|
pub fn generate(&mut self) -> Vector3Array {
|
||||||
let mut rng: StdRng = Seeder::from(self.seed.to_owned()).make_rng();
|
let mut rng: StdRng = Seeder::from(self.seed.to_owned()).make_rng();
|
||||||
self.tiles = get_vec3(self.xsize, self.ysize, self.zsize);
|
self.tiles = get_vec3(self.xsize, self.ysize, self.zsize);
|
||||||
|
|
||||||
|
// fill edges with water
|
||||||
|
for x in 0..self.ysize {
|
||||||
|
self.tiles[x][0][0] = tiles::Tiletypes::WaterSlab;
|
||||||
|
self.tiles[x][self.ysize - 1][0] = tiles::Tiletypes::WaterSlab;
|
||||||
|
}
|
||||||
|
for y in 0..self.xsize {
|
||||||
|
self.tiles[0][y][0] = tiles::Tiletypes::WaterSlab;
|
||||||
|
self.tiles[self.xsize - 1][y][0] = tiles::Tiletypes::WaterSlab;
|
||||||
|
}
|
||||||
|
|
||||||
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 {
|
||||||
for z in 0..self.zsize {
|
for z in 0..self.zsize {
|
||||||
ret.push(Vector3::new(x as f32, y as f32, z as f32));
|
ret.push(Vector3::new(x as f32, y as f32, z as f32));
|
||||||
self.tiles[x][y][z] = self.new_tile_init_step(x, y, z, &mut rng)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_tile_init_step(&self, x: usize, y: usize, z: usize, rng: &mut StdRng) -> tiles::Tiletypes {
|
|
||||||
// first generate bedrock
|
|
||||||
if z == 0 {
|
|
||||||
if y == 0 || x == 0 || y == self.ysize - 1 || x == self.xsize - 1{
|
|
||||||
return tiles::Tiletypes::Water;
|
|
||||||
}
|
|
||||||
let random = rng.gen_range(0..3) as u8;
|
|
||||||
match random {
|
|
||||||
0 => return tiles::Tiletypes::Grass,
|
|
||||||
_ => return self.tileattributes.bedrock.choose(rng).unwrap().to_owned(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// then make sure the top row of tiles is air
|
|
||||||
if z == self.zsize - 1
|
|
||||||
|| !tiles::Tile::new(self.tiles[x][y][z - 1]).is_support
|
|
||||||
|| tiles::Tile::new(self.tiles[x][y][z - 1]).must_be_on_top
|
|
||||||
{
|
|
||||||
return tiles::Tiletypes::Air;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if no tile fits, then return air
|
|
||||||
tiles::Tiletypes::Sand
|
|
||||||
}
|
|
||||||
|
|
||||||
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,
|
||||||
|
|
|
@ -10,6 +10,8 @@ pub enum Tiletypes {
|
||||||
Dirt,
|
Dirt,
|
||||||
Sand,
|
Sand,
|
||||||
Rock,
|
Rock,
|
||||||
|
WaterSlab,
|
||||||
|
GrassSlab,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
@ -59,6 +61,21 @@ impl Tile {
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
Tiletypes::GrassSlab => {
|
||||||
|
tile = TileBuilder::default()
|
||||||
|
.kind(kind)
|
||||||
|
.must_be_on_top(true)
|
||||||
|
.is_support(false)
|
||||||
|
.build()
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
Tiletypes::WaterSlab => {
|
||||||
|
tile = TileBuilder::default()
|
||||||
|
.kind(kind)
|
||||||
|
.is_support(false)
|
||||||
|
.build()
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
_ => tile = TileBuilder::default().kind(kind).build().unwrap(),
|
_ => tile = TileBuilder::default().kind(kind).build().unwrap(),
|
||||||
};
|
};
|
||||||
tile
|
tile
|
||||||
|
|
Loading…
Reference in a new issue