diff options
Diffstat (limited to 'World.gd')
-rw-r--r-- | World.gd | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/World.gd b/World.gd deleted file mode 100644 index 15e283f..0000000 --- a/World.gd +++ /dev/null @@ -1,68 +0,0 @@ -extends RigidBody - -export var acceleration = 10.0 -export var generation_distance = 300.0 -export var generation_subdivision = 5.0 - -var gen_coords = Vector2.ZERO -const init_distance = 10 - -onready var Rock = preload("res://Rock.tscn") -onready var noise = OpenSimplexNoise.new() - -func _on_WorldGenCull_body_exited(body:Node): - body.queue_free() - -func make_rock(xform:Transform): - var rock = Rock.instance() - rock.transform = xform - self.add_child(rock) - -func generate_location(coords:Vector2): - if coords.x < -init_distance || coords.x > init_distance || coords.y < -init_distance || coords.y > init_distance: - if noise.get_noise_2d(coords.x,coords.y) > 0.6: - coords *= generation_subdivision - make_rock(Transform(Basis(), Vector3(coords.x,0.0,coords.y))) - -func generate_world(): - var new_coords = -(self.transform.origin / generation_subdivision).floor() - new_coords = Vector2(new_coords.x,new_coords.z) - var direction = new_coords - gen_coords - var gen_max = generation_distance / generation_subdivision - var gen_min = -gen_max - if gen_coords.x != new_coords.x: - for i in range(new_coords.y+gen_min,new_coords.y+gen_max): - generate_location(Vector2(new_coords.x+(gen_min if direction.x < 0 else gen_max),i)) - if gen_coords.y != new_coords.y: - for i in range(new_coords.x+gen_min,new_coords.x+gen_max): - generate_location(Vector2(i,new_coords.y+(gen_min if direction.y < 0 else gen_max))) - gen_coords = new_coords - -func _ready(): - randomize() - noise.seed = randi() - noise.octaves = 4 - noise.period = 16 - noise.persistence = 0.001 - noise.lacunarity = 2.0 - - var gen_max = generation_distance / generation_subdivision - var gen_min = -gen_max - for i in range(gen_min,gen_max): - for j in range(gen_min,gen_max): - generate_location(Vector2(i,j)) - -func travel(direction:Vector3): - var boat = $"/root/Main/ShipRigidBody" - var boat_direction = boat.global_transform.basis - boat_direction = Basis(Vector3.UP*boat_direction.get_euler().y) - direction = -direction - direction = boat_direction * direction - direction = direction.normalized() - self.add_central_force(direction*acceleration) - -func _integrate_forces(_state): - generate_world() - var stick = Input.get_axis("ship_down","ship_up") - if stick != 0.0: - travel(Vector3.FORWARD*stick) |