Nouvelle scène pour la génération du monde

pull/34/head
Valentin Stark 3 years ago
parent adcddbd976
commit 3da2c271f5
  1. 2
      menu/LoadWorld.gd
  2. 2
      menu/NewWorld.gd
  3. 4
      ui/map/map.gd
  4. 6
      utils/world_generation/WorldGeneration.gd
  5. 18
      utils/world_generation/WorldGeneration.tscn
  6. 6
      world/World3d.gd
  7. 6
      world/game.tscn

@ -15,4 +15,4 @@ func _on_CancelButton_pressed():
func _button_pressed(name): func _button_pressed(name):
Global.terrain_name = name Global.terrain_name = name
get_tree().change_scene("res://world/game.tscn") get_tree().change_scene("res://utils/world_generation/WorldGeneration.tscn")

@ -11,4 +11,4 @@ func _on_CancelButton_pressed():
func _on_CreateButton_pressed(): func _on_CreateButton_pressed():
Global.terrain_name = $VBoxContainer/LineEdit.text Global.terrain_name = $VBoxContainer/LineEdit.text
get_tree().change_scene("res://world/game.tscn") get_tree().change_scene("res://utils/world_generation/WorldGeneration.tscn")

@ -3,6 +3,7 @@ extends Node2D
signal map_clicked signal map_clicked
func heightmap(): func heightmap():
print (Global.terrain)
for triangle in Global.terrain.get_triangles(): for triangle in Global.terrain.get_triangles():
var colors = Gradient.new() var colors = Gradient.new()
colors.add_point(0.999, Color("#9e0142")) # red colors.add_point(0.999, Color("#9e0142")) # red
@ -97,6 +98,3 @@ func _process(_delta):
var new_position = get_viewport().get_mouse_position() / scale var new_position = get_viewport().get_mouse_position() / scale
if new_position.x <= 2000 and new_position.y <= 2000: if new_position.x <= 2000 and new_position.y <= 2000:
emit_signal("map_clicked", new_position) emit_signal("map_clicked", new_position)
func _on_Game_world_loaded():
update()

@ -1,6 +1,4 @@
extends Node extends Control
signal world_loaded
export(int) var width = 2000 export(int) var width = 2000
export(int) var height = 2000 export(int) var height = 2000
@ -33,7 +31,7 @@ func _ready():
if Global.terrain.is_created() or Global.terrain.is_loaded(): if Global.terrain.is_created() or Global.terrain.is_loaded():
add_trees() add_trees()
emit_signal("world_loaded") get_tree().change_scene("res://world/game.tscn")
else: else:
Global.print_debug("Pas de Global.terrain, pas de construction ...") Global.print_debug("Pas de Global.terrain, pas de construction ...")
Global.print_debug("Pas de construction ..., pas de palais ...") Global.print_debug("Pas de construction ..., pas de palais ...")

@ -0,0 +1,18 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://utils/world_generation/WorldGeneration.gd" type="Script" id=1]
[node name="WorldGeneration" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
[node name="ProgressBar" type="ProgressBar" parent="."]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -82.5
margin_top = -7.0
margin_right = 82.5
margin_bottom = 7.0

@ -1,8 +1,7 @@
extends Spatial extends Spatial
func _ready(): func _ready():
pass draw_world()
func draw_world(): func draw_world():
# for i in range(0, 1, 1): # for i in range(0, 1, 1):
@ -43,6 +42,3 @@ func draw_world():
mi.cast_shadow = GeometryInstance.SHADOW_CASTING_SETTING_ON mi.cast_shadow = GeometryInstance.SHADOW_CASTING_SETTING_ON
print(mi) print(mi)
add_child(mi) add_child(mi)
func _on_Game_world_loaded():
draw_world()

@ -1,7 +1,6 @@
[gd_scene load_steps=8 format=2] [gd_scene load_steps=7 format=2]
[ext_resource path="res://ui/ui.tscn" type="PackedScene" id=1] [ext_resource path="res://ui/ui.tscn" type="PackedScene" id=1]
[ext_resource path="res://world/game.gd" type="Script" id=2]
[ext_resource path="res://world/default_env.tres" type="Environment" id=3] [ext_resource path="res://world/default_env.tres" type="Environment" id=3]
[ext_resource path="res://world/World3d.gd" type="Script" id=4] [ext_resource path="res://world/World3d.gd" type="Script" id=4]
[ext_resource path="res://utils/camera/CamBase.tscn" type="PackedScene" id=5] [ext_resource path="res://utils/camera/CamBase.tscn" type="PackedScene" id=5]
@ -13,7 +12,6 @@ size = Vector2( 2000, 2000 )
albedo_color = Color( 0.054902, 0.533333, 0.741176, 1 ) albedo_color = Color( 0.054902, 0.533333, 0.741176, 1 )
[node name="Game" type="Node"] [node name="Game" type="Node"]
script = ExtResource( 2 )
[node name="UI" parent="." instance=ExtResource( 1 )] [node name="UI" parent="." instance=ExtResource( 1 )]
@ -47,8 +45,6 @@ transform = Transform( 0.971628, 0.168947, -0.16552, 0, 0.699825, 0.714314, 0.23
light_energy = 0.1 light_energy = 0.1
shadow_enabled = true shadow_enabled = true
[connection signal="world_loaded" from="." to="UI/Map" method="_on_Game_world_loaded"]
[connection signal="world_loaded" from="." to="World3d" method="_on_Game_world_loaded"]
[connection signal="map_clicked" from="UI/Map" to="World3d/CamBase/Camera" method="_on_Map_map_clicked"] [connection signal="map_clicked" from="UI/Map" to="World3d/CamBase/Camera" method="_on_Map_map_clicked"]
[connection signal="camera_moved" from="World3d/CamBase/Camera" to="UI/Map/Cursor" method="_on_Camera_camera_moved"] [connection signal="camera_moved" from="World3d/CamBase/Camera" to="UI/Map/Cursor" method="_on_Camera_camera_moved"]

Loading…
Cancel
Save