This commit is contained in:
Zoe 2022-05-13 20:44:22 +02:00
parent b6fbb204f1
commit 4daf1fe0ff
5 changed files with 41 additions and 18 deletions

Binary file not shown.

6
godot/world/Control.gd Normal file
View file

@ -0,0 +1,6 @@
extends Control
signal reload_requested
func _on_Reload_pressed():
emit_signal("reload_requested", $TextEdit.text)

View file

@ -1,9 +1,9 @@
extends Node
export var xsize = 256
export var ysize = 256
export var zsize = 3
export var cityname = "cute little kitties"
export var xsize = 1048
export var ysize = 1048
var zsize = 10
export var cityname = "dsfdsfdsfdsfsfkdsjfksdjf"
func _ready():
StateServer.generate_world(xsize, ysize, zsize, cityname)

View file

@ -21,9 +21,8 @@ func get_tile_at(pos: Vector3) -> String:
func update_tiles(tile_positions: PoolVector3Array):
for tile in tile_positions:
if !StateServer.is_tile_hidden(int(tile.x), int(tile.y), int(tile.z)):
tilemaps[tile.z].set_tile_graphics(Vector2(tile.x, tile.y),
get_tile_at(tile))
tilemaps[tile.z].set_tile_graphics(Vector2(tile.x, tile.y),
get_tile_at(tile))
for map in tilemaps:
map.update_dirty_quadrants()

View file

@ -41,6 +41,35 @@ impl World {
ret.push(Vector3::new(x as f32, y as f32, 0.0));
if noisemap.get_value(x, y) > 0.5 {
self.tiles[x][y][0] = tiles::Tiletypes::Rock;
self.tiles[x][y][1] = tiles::Tiletypes::Rock;
ret.push(Vector3::new(x as f32, y as f32, 1.0));
self.tiles[x][y][2] = tiles::Tiletypes::Rock;
ret.push(Vector3::new(x as f32, y as f32, 2.0));
self.tiles[x][y][3] = tiles::Tiletypes::Rock;
ret.push(Vector3::new(x as f32, y as f32, 3.0));
if noisemap.get_value(x, y) > 0.6 {
self.tiles[x][y][4] = tiles::Tiletypes::Rock;
ret.push(Vector3::new(x as f32, y as f32, 4.0));
}
if noisemap.get_value(x, y) > 0.7 {
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 {
self.tiles[x][y][0] = tiles::Tiletypes::Dirt;
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;
@ -56,17 +85,6 @@ impl World {
ret
}
fn tile_is_next_to(&self, x: usize, y: usize, z: usize, neighbor: tiles::Tiletypes) -> bool {
if self.tiles[x - 1][y - 1][z] == neighbor
|| self.tiles[x - 1][y][z] == neighbor
|| self.tiles[x][y + 1][z] == neighbor
|| self.tiles[x + 1][y + 1][z] == neighbor
{
return true;
}
false
}
pub fn new(xsize: usize, ysize: usize, zsize: usize, seed: String) -> World {
World {
xsize,