Implémentation des entités

pull/19/head
Valentin Stark 3 years ago
parent f7d049622b
commit f6e29da030
  1. 3
      .godot/editor/Bloc.gd-folding-777908489b1a8005763f3e64e2d617fa.cfg
  2. 3
      .godot/editor/Character.gd-folding-bf899ffaaf35dcc8291eb6a2a32ad186.cfg
  3. 170
      .godot/editor/Character.tscn-editstate-93f18c909dc2d6f15b41da300e4d1e0b.cfg
  4. 5
      .godot/editor/Character.tscn-folding-93f18c909dc2d6f15b41da300e4d1e0b.cfg
  5. 3
      .godot/editor/Chunks.gd-folding-5949b78e31fd40a7520f4ee5be998ee8.cfg
  6. 3
      .godot/editor/Entity.gd-folding-62048656195efaca6cbfe20b70ff68c3.cfg
  7. 10
      .godot/editor/WorldGeneration.tscn-editstate-0f1c0c812be0be68b9754190599b56a4.cfg
  8. 3
      .godot/editor/bloc_complet.glb-994aa1e23eb71978e33bad80f3deaabb.scn-folding-58f320eeb26a92b0faf87f84b599f07b.cfg
  9. 170
      .godot/editor/bloc_complet.glb-editstate-994aa1e23eb71978e33bad80f3deaabb.cfg
  10. 5
      .godot/editor/bloc_complet.glb-folding-994aa1e23eb71978e33bad80f3deaabb.cfg
  11. 4
      .godot/editor/create_recent.Node
  12. 3
      .godot/editor/cube.meshlib-folding-80a9dd2f2162760de06730ce36ab0a07.cfg
  13. 12
      .godot/editor/editor_layout.cfg
  14. 82
      .godot/editor/filesystem_cache8
  15. 9
      .godot/editor/filesystem_update4
  16. 8
      .godot/editor/project_metadata.cfg
  17. 4
      .godot/editor/recent_dirs
  18. 48
      .godot/editor/script_editor_cache.cfg
  19. 6
      .godot/global_script_class_cache.cfg
  20. 3
      .godot/imported/bloc_complet.glb-994aa1e23eb71978e33bad80f3deaabb.md5
  21. BIN
      .godot/imported/bloc_complet.glb-994aa1e23eb71978e33bad80f3deaabb.scn
  22. BIN
      .godot/imported/bloc_complet_albedo.png-d517f1262761d1fe31bd54f51927d7e2.bptc.ctex
  23. BIN
      .godot/imported/bloc_complet_albedo.png-d517f1262761d1fe31bd54f51927d7e2.ctex
  24. 3
      .godot/imported/bloc_complet_albedo.png-d517f1262761d1fe31bd54f51927d7e2.md5
  25. BIN
      .godot/imported/bloc_complet_albedo.png-d517f1262761d1fe31bd54f51927d7e2.s3tc.ctex
  26. BIN
      .godot/imported/bloc_complet_normal.png-cbf8a7e820fdc110c6faf4c702e03006.bptc.ctex
  27. BIN
      .godot/imported/bloc_complet_normal.png-cbf8a7e820fdc110c6faf4c702e03006.ctex
  28. 3
      .godot/imported/bloc_complet_normal.png-cbf8a7e820fdc110c6faf4c702e03006.md5
  29. BIN
      .godot/imported/bloc_complet_normal.png-cbf8a7e820fdc110c6faf4c702e03006.s3tc.ctex
  30. BIN
      .godot/shader_cache/SceneForwardClusteredShaderRD/01a9808236399f8ebd21e87d1a37f24fc50c8317697ad5d2c97d16b7efa43242/958fe242f7620728a7a7b9522267b92135768b58.cache
  31. BIN
      .godot/shader_cache/SceneForwardClusteredShaderRD/01a9808236399f8ebd21e87d1a37f24fc50c8317697ad5d2c97d16b7efa43242/adcca0c58d18f052ff75ecdaa3dbb219f5d6cbc4.cache
  32. BIN
      .godot/uid_cache.bin
  33. BIN
      assets/test/bloc_complet.glb
  34. 32
      assets/test/bloc_complet.glb.import
  35. BIN
      assets/test/bloc_complet_albedo.png
  36. 36
      assets/test/bloc_complet_albedo.png.import
  37. BIN
      assets/test/bloc_complet_normal.png
  38. 36
      assets/test/bloc_complet_normal.png.import
  39. BIN
      assets/test/cube.meshlib
  40. 41
      export_presets.cfg
  41. 159
      scripts/Chunks.gd
  42. 8
      scripts/Entity.gd
  43. 6
      scripts/Map.gd
  44. 54
      scripts/World.gd
  45. 23
      scripts/WorldGeneration.gd

@ -0,0 +1,3 @@
[folding]
sections_unfolded=PackedStringArray()

@ -0,0 +1,3 @@
[folding]
sections_unfolded=PackedStringArray()

@ -0,0 +1,170 @@
[editor_states]
Anim={
"visible": false
}
2D={
"grid_offset": Vector2(0, 0),
"grid_snap_active": false,
"grid_step": Vector2(8, 8),
"grid_visibility": 1,
"ofs": Vector2(-114.654, -46.1878),
"primary_grid_steps": 8,
"show_edit_locks": true,
"show_guides": true,
"show_helpers": false,
"show_origin": true,
"show_rulers": true,
"show_transformation_gizmos": true,
"show_viewport": true,
"show_zoom_control": true,
"smart_snap_active": false,
"snap_guides": true,
"snap_node_anchors": true,
"snap_node_center": true,
"snap_node_parent": true,
"snap_node_sides": true,
"snap_other_nodes": true,
"snap_pixel": true,
"snap_relative": false,
"snap_rotation": false,
"snap_rotation_offset": 0.0,
"snap_rotation_step": 0.261799,
"snap_scale": false,
"snap_scale_step": 0.1,
"zoom": 5.65685
}
3D={
"fov": 70.01,
"gizmos_status": {
"AudioListener3D": 0,
"AudioStreamPlayer3D": 0,
"CPUParticles3D": 0,
"CSGShape3D": 0,
"Camera3D": 0,
"CollisionObject3D": 0,
"CollisionPolygon3D": 0,
"CollisionShape3D": 0,
"Decal": 0,
"FogVolume": 0,
"GPUParticles3D": 0,
"GPUParticlesCollision3D": 0,
"Joint3D": 0,
"Light3D": 0,
"LightmapGI": 0,
"LightmapProbe": 0,
"Marker3D": 0,
"NavigationLink3D": 0,
"NavigationRegion3D": 0,
"OccluderInstance3D": 0,
"Path3D": 0,
"PhysicalBone3D": 0,
"RayCast3D": 0,
"ReflectionProbe": 0,
"ShapeCast3D": 0,
"Skeleton3D": 0,
"SoftBody3D": 0,
"SpringArm3D": 0,
"VehicleWheel3D": 0,
"VisibleOnScreenNotifier3D": 0,
"VoxelGI": 0
},
"local_coords": false,
"preview_sun_env": {
"environ_ao_enabled": false,
"environ_enabled": true,
"environ_energy": 1.0,
"environ_gi_enabled": false,
"environ_glow_enabled": true,
"environ_ground_color": Color(0.2, 0.169, 0.133, 1),
"environ_sky_color": Color(0.385, 0.454, 0.55, 1),
"environ_tonemap_enabled": true,
"sun_color": Color(1, 1, 1, 1),
"sun_enabled": true,
"sun_energy": 1.0,
"sun_max_distance": 100.0,
"sun_rotation": Vector2(-1.0472, 2.61799)
},
"rotate_snap": 15.0,
"scale_snap": 10.0,
"show_grid": true,
"show_origin": true,
"snap_enabled": false,
"translate_snap": 1.0,
"viewport_mode": 1,
"viewports": [{
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 5.44196,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": true,
"position": Vector3(0, 0, 0),
"use_environment": false,
"use_orthogonal": false,
"view_type": 0,
"x_rotation": 0.32983,
"y_rotation": -3.64159
}, {
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 4.0,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": false,
"position": Vector3(0, 0, 0),
"use_environment": false,
"use_orthogonal": false,
"view_type": 0,
"x_rotation": 0.5,
"y_rotation": -0.5
}, {
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 4.0,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": false,
"position": Vector3(0, 0, 0),
"use_environment": false,
"use_orthogonal": false,
"view_type": 0,
"x_rotation": 0.5,
"y_rotation": -0.5
}, {
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 4.0,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": false,
"position": Vector3(0, 0, 0),
"use_environment": false,
"use_orthogonal": false,
"view_type": 0,
"x_rotation": 0.5,
"y_rotation": -0.5
}],
"zfar": 4000.01,
"znear": 0.05
}

@ -0,0 +1,5 @@
[folding]
node_unfolds=[]
resource_unfolds=["res://scenes/Character.tscn::CapsuleMesh_4bik6", PackedStringArray()]
nodes_folded=[]

@ -0,0 +1,3 @@
[folding]
sections_unfolded=PackedStringArray()

@ -0,0 +1,3 @@
[folding]
sections_unfolded=PackedStringArray()

@ -8,7 +8,7 @@ Anim={
"grid_snap_active": false, "grid_snap_active": false,
"grid_step": Vector2(8, 8), "grid_step": Vector2(8, 8),
"grid_visibility": 1, "grid_visibility": 1,
"ofs": Vector2(-35.886, -12.5758), "ofs": Vector2(-114.654, -46.1878),
"primary_grid_steps": 8, "primary_grid_steps": 8,
"show_edit_locks": true, "show_edit_locks": true,
"show_guides": true, "show_guides": true,
@ -32,7 +32,7 @@ Anim={
"snap_rotation_step": 0.261799, "snap_rotation_step": 0.261799,
"snap_scale": false, "snap_scale": false,
"snap_scale_step": 0.1, "snap_scale_step": 0.1,
"zoom": 11.9865 "zoom": 5.65685
} }
3D={ 3D={
"fov": 70.01, "fov": 70.01,
@ -85,12 +85,12 @@ Anim={
"sun_max_distance": 100.0, "sun_max_distance": 100.0,
"sun_rotation": Vector2(-1.0472, 2.61799) "sun_rotation": Vector2(-1.0472, 2.61799)
}, },
"rotate_snap": 15.0, "rotate_snap": 0.555556,
"scale_snap": 10.0, "scale_snap": 1.25,
"show_grid": true, "show_grid": true,
"show_origin": true, "show_origin": true,
"snap_enabled": false, "snap_enabled": false,
"translate_snap": 1.0, "translate_snap": 0.001,
"viewport_mode": 1, "viewport_mode": 1,
"viewports": [{ "viewports": [{
"auto_orthogonal": false, "auto_orthogonal": false,

@ -0,0 +1,170 @@
[editor_states]
Anim={
"visible": false
}
2D={
"grid_offset": Vector2(0, 0),
"grid_snap_active": false,
"grid_step": Vector2(8, 8),
"grid_visibility": 1,
"ofs": Vector2(-114.654, -46.1878),
"primary_grid_steps": 8,
"show_edit_locks": true,
"show_guides": true,
"show_helpers": false,
"show_origin": true,
"show_rulers": true,
"show_transformation_gizmos": true,
"show_viewport": true,
"show_zoom_control": true,
"smart_snap_active": false,
"snap_guides": true,
"snap_node_anchors": true,
"snap_node_center": true,
"snap_node_parent": true,
"snap_node_sides": true,
"snap_other_nodes": true,
"snap_pixel": true,
"snap_relative": false,
"snap_rotation": false,
"snap_rotation_offset": 0.0,
"snap_rotation_step": 0.261799,
"snap_scale": false,
"snap_scale_step": 0.1,
"zoom": 5.65685
}
3D={
"fov": 70.01,
"gizmos_status": {
"AudioListener3D": 0,
"AudioStreamPlayer3D": 0,
"CPUParticles3D": 0,
"CSGShape3D": 0,
"Camera3D": 0,
"CollisionObject3D": 0,
"CollisionPolygon3D": 0,
"CollisionShape3D": 0,
"Decal": 0,
"FogVolume": 0,
"GPUParticles3D": 0,
"GPUParticlesCollision3D": 0,
"Joint3D": 0,
"Light3D": 0,
"LightmapGI": 0,
"LightmapProbe": 0,
"Marker3D": 0,
"NavigationLink3D": 0,
"NavigationRegion3D": 0,
"OccluderInstance3D": 0,
"Path3D": 0,
"PhysicalBone3D": 0,
"RayCast3D": 0,
"ReflectionProbe": 0,
"ShapeCast3D": 0,
"Skeleton3D": 0,
"SoftBody3D": 0,
"SpringArm3D": 0,
"VehicleWheel3D": 0,
"VisibleOnScreenNotifier3D": 0,
"VoxelGI": 0
},
"local_coords": false,
"preview_sun_env": {
"environ_ao_enabled": false,
"environ_enabled": true,
"environ_energy": 1.0,
"environ_gi_enabled": false,
"environ_glow_enabled": true,
"environ_ground_color": Color(0.2, 0.169, 0.133, 1),
"environ_sky_color": Color(0.385, 0.454, 0.55, 1),
"environ_tonemap_enabled": true,
"sun_color": Color(1, 1, 1, 1),
"sun_enabled": true,
"sun_energy": 1.0,
"sun_max_distance": 100.0,
"sun_rotation": Vector2(-1.0472, 2.61799)
},
"rotate_snap": 5.0,
"scale_snap": 5.0,
"show_grid": true,
"show_origin": true,
"snap_enabled": false,
"translate_snap": 0.1,
"viewport_mode": 1,
"viewports": [{
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 1.36184,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": true,
"position": Vector3(0, 0, 0),
"use_environment": false,
"use_orthogonal": false,
"view_type": 0,
"x_rotation": 0.649339,
"y_rotation": -18.5162
}, {
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 4.0,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": false,
"position": Vector3(0, 0, 0),
"use_environment": false,
"use_orthogonal": false,
"view_type": 0,
"x_rotation": 0.5,
"y_rotation": -0.5
}, {
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 4.0,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": false,
"position": Vector3(0, 0, 0),
"use_environment": false,
"use_orthogonal": false,
"view_type": 0,
"x_rotation": 0.5,
"y_rotation": -0.5
}, {
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 4.0,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": false,
"position": Vector3(0, 0, 0),
"use_environment": false,
"use_orthogonal": false,
"view_type": 0,
"x_rotation": 0.5,
"y_rotation": -0.5
}],
"zfar": 4000.01,
"znear": 0.05
}

@ -0,0 +1,5 @@
[folding]
node_unfolds=[NodePath("bloc_complet2"), PackedStringArray("Skeleton")]
resource_unfolds=["res://assets/test/bloc_complet.glb::ArrayMesh_bygxf", PackedStringArray("Resource")]
nodes_folded=[]

@ -1,8 +1,10 @@
MeshInstance3D
CollisionShape3D
CharacterBody3D
TextureRect TextureRect
TileMap TileMap
Node Node
GridMap GridMap
MeshInstance3D
Camera3D Camera3D
SpotLight3D SpotLight3D
DirectionalLight3D DirectionalLight3D

@ -0,0 +1,3 @@
[folding]
sections_unfolded=PackedStringArray()

@ -7,8 +7,8 @@ dock_filesystem_file_list_display_mode=1
dock_split_2=0 dock_split_2=0
dock_split_3=0 dock_split_3=0
dock_hsplit_1=0 dock_hsplit_1=0
dock_hsplit_2=703 dock_hsplit_2=270
dock_hsplit_3=-432 dock_hsplit_3=-270
dock_hsplit_4=0 dock_hsplit_4=0
dock_3="Scene,Import" dock_3="Scene,Import"
dock_4="FileSystem" dock_4="FileSystem"
@ -16,11 +16,11 @@ dock_5="Inspector,Node,History"
[EditorNode] [EditorNode]
open_scenes=["res://scenes/3DWorld.tscn", "res://scenes/Game.tscn", "res://scenes/HUD.tscn", "res://scenes/WorldGeneration.tscn"] open_scenes=["res://scenes/WorldGeneration.tscn", "res://scenes/3DWorld.tscn"]
[ScriptEditor] [ScriptEditor]
open_scripts=["res://scripts/Camera3D.gd", "res://scripts/Chunks.gd", "res://scripts/Global.gd", "res://scripts/Map.gd", "res://scripts/World.gd", "res://scripts/WorldGeneration.gd"] open_scripts=["res://scripts/Camera3D.gd", "res://scripts/Chunks.gd", "res://scripts/Entity.gd", "res://scripts/Map.gd", "res://scripts/World.gd", "res://scripts/WorldGeneration.gd"]
open_help=["Image", "ImageTexture", "Object", "Texture2D", "TextureRect"] open_help=[]
script_split_offset=518 script_split_offset=70
list_split_offset=0 list_split_offset=0

@ -1,41 +1,43 @@
2a60927148abd1d33b818b535e306557 2a60927148abd1d33b818b535e306557
::res://::1677100541 ::res://::1677194650
icon.png::CompressedTexture2D::4672001524465425285::1676574357::1676664790::1::::<><>:: export_presets.cfg::TextFile::-1::1677194603::0::1::::<><>::
README.md::TextFile::-1::1676578345::0::1::::<><>:: icon.png::CompressedTexture2D::4672001524465425285::1676578483::1676582905::1::::<><>::
::res://assets/::1677084140 README.md::TextFile::-1::1676578483::0::1::::<><>::
environment.tres::Environment::8600195688495287911::1677084140::0::1::::<><>:: ::res://assets/::1677177540
water.gdshader::Shader::-1::1677015851::0::1::::<><>:: environment.tres::Environment::8600195688495287911::1677177540::0::1::::<><>::
::res://assets/blocs/::1677015905 water.gdshader::Shader::-1::1677174532::0::1::::<><>::
0_sides.glb::PackedScene::7036506600244808940::1677003366::1677015904::1::::<><>::uid://b53thhe2sa6x0 ::res://assets/blocs/::1677174532
0_sides_grass.png::CompressedTexture2D::4551055068461159203::1677003427::1677015904::1::::<><>:: 0_sides.glb::PackedScene::7036506600244808940::1677174532::1677174532::1::::<><>::
1_side.glb::PackedScene::5601417408597394875::1677003385::1677015904::1::::<><>::uid://cfr1s2lqng8eo 0_sides_grass.png::CompressedTexture2D::4551055068461159203::1677174532::1677174532::1::::<><>::
1_side_grass.png::CompressedTexture2D::5160492229365512154::1677003427::1677015904::1::::<><>:: 1_side.glb::PackedScene::5601417408597394875::1677174532::1677174532::1::::<><>::
2_side_angle.glb::PackedScene::8081534368546731168::1677003412::1677015905::1::::<><>::uid://c0xxcgdm7s2ak 1_side_grass.png::CompressedTexture2D::5160492229365512154::1677174532::1677174532::1::::<><>::
2_side_angle_grass.png::CompressedTexture2D::6576443529465065670::1677003428::1677015904::1::::<><>:: 2_side_angle.glb::PackedScene::8081534368546731168::1677174532::1677174532::1::::<><>::
2_side_opposite.glb::PackedScene::3205848216587541745::1677003400::1677015905::1::::<><>::uid://bffdt5if5pnda 2_side_angle_grass.png::CompressedTexture2D::6576443529465065670::1677174532::1677174532::1::::<><>::
2_side_opposite_grass.png::CompressedTexture2D::2747904460042865810::1677003428::1677015904::1::::<><>:: 2_side_opposite.glb::PackedScene::3205848216587541745::1677174532::1677174532::1::::<><>::
3_side_angle.glb::PackedScene::4729157567058414100::1677003421::1677015905::1::::<><>::uid://kc4nqve8lx14 2_side_opposite_grass.png::CompressedTexture2D::2747904460042865810::1677174532::1677174532::1::::<><>::
3_side_angle_grass.png::CompressedTexture2D::707802073040230165::1677003428::1677015904::1::::<><>:: 3_side_angle.glb::PackedScene::4729157567058414100::1677174532::1677174532::1::::<><>::
4_sides.glb::PackedScene::139420628202576697::1677003373::1677015905::1::::<><>::uid://dlo0nmochxy4u 3_side_angle_grass.png::CompressedTexture2D::707802073040230165::1677174532::1677174532::1::::<><>::
4_sides_grass.png::CompressedTexture2D::7961782411803042998::1677003428::1677015904::1::::<><>:: 4_sides.glb::PackedScene::139420628202576697::1677174532::1677174532::1::::<><>::
blocs.meshlib::MeshLibrary::2672089234605318559::1677003618::0::1::::<><>::uid://b53thhe2sa6x0<>uid://cfr1s2lqng8eo<>uid://c0xxcgdm7s2ak<>uid://bffdt5if5pnda<>uid://kc4nqve8lx14<>uid://dlo0nmochxy4u 4_sides_grass.png::CompressedTexture2D::7961782411803042998::1677174532::1677174532::1::::<><>::
::res://assets/images/::1677081411 blocs.meshlib::MeshLibrary::2672089234605318559::1677174532::0::1::::<><>::uid://b53thhe2sa6x0<>uid://cfr1s2lqng8eo<>uid://c0xxcgdm7s2ak<>uid://bffdt5if5pnda<>uid://kc4nqve8lx14<>uid://dlo0nmochxy4u
colors.png::CompressedTexture2D::2558953172502239658::1671825732::1677081411::1::::<><>:: ::res://assets/images/::1677174532
grass_top.png::CompressedTexture2D::3263707750932711970::1676919772::1677078622::1::::<><>:: colors.png::CompressedTexture2D::2558953172502239658::1677174532::1677174532::1::::<><>::
::res://assets/tests/::1677018084 grass_top.png::CompressedTexture2D::3263707750932711970::1677174532::1677174532::1::::<><>::
blocs.meshlib::MeshLibrary::7399659330532602926::1677018084::0::1::::<><>::uid://ced8eb4jbj1v5 ::res://assets/test/::1677177509
bloc_complet.glb::PackedScene::4200726942972538951::1677017973::1677018069::1::::<><>::uid://ced8eb4jbj1v5 bloc_complet.glb::PackedScene::1436864023732800907::1677175567::1677177205::1::::<><>::uid://chgapiyga3x6o<>uid://cmoaaucso40hs
bloc_complet_grass.png::CompressedTexture2D::5061800776870741768::1677018069::1677018069::1::::<><>:: bloc_complet_albedo.png::CompressedTexture2D::5276576783821208744::1677177183::1677177210::1::::<><>::
::res://scenes/::1677100278 bloc_complet_normal.png::CompressedTexture2D::5644009833993754604::1677177183::1677177214::1::::<><>::
3DWorld.tscn::PackedScene::3599411568061770725::1677100278::0::1::::<><>::uid://becm6iybpdly2<>res://scripts/Chunks.gd<>res://scripts/Camera3D.gd<>res://assets/water.gdshader<>uid://dur874iy77jjr cube.meshlib::MeshLibrary::1045877065266806205::1677177509::0::1::::<><>::uid://chgapiyga3x6o<>uid://cmoaaucso40hs
Game.tscn::PackedScene::9075056520838281688::1677100278::0::1::::<><>::uid://brjt1u0dgbmi4<>uid://d1sd7pxywgunu ::res://scenes/::1677194529
HUD.tscn::PackedScene::9021570906125339886::1677100278::0::1::::<><>::res://scripts/Map.gd 3DWorld.tscn::PackedScene::3599411568061770725::1677194529::0::1::::<><>::uid://becm6iybpdly2<>res://scripts/Chunks.gd<>res://scripts/Camera3D.gd<>res://assets/water.gdshader<>uid://dur874iy77jjr
Map.tscn::PackedScene::4214730063588096553::1677100278::0::1::::<><>::uid://bcptt5eiydwq1<>res://scripts/Map.gd Game.tscn::PackedScene::9075056520838281688::1677174532::0::1::::<><>::uid://brjt1u0dgbmi4<>uid://d1sd7pxywgunu
WorldGeneration.tscn::PackedScene::1108513713840477990::1677100278::0::1::::<><>::res://scripts/WorldGeneration.gd HUD.tscn::PackedScene::9021570906125339886::1677174532::0::1::::<><>::res://scripts/Map.gd
::res://scripts/::1677100526 WorldGeneration.tscn::PackedScene::1108513713840477990::1677194529::0::1::::<><>::res://scripts/WorldGeneration.gd
Camera3D.gd::GDScript::-1::1676664790::0::1::::<>Camera3D<>:: ::res://scripts/::1677194529
Chunks.gd::GDScript::-1::1677092524::0::1::::<>GridMap<>:: Camera3D.gd::GDScript::-1::1677174532::0::1::::<>Camera3D<>::
Global.gd::GDScript::-1::1677079629::0::1::::<>Node<>:: Chunks.gd::GDScript::-1::1677194529::0::1::::<>GridMap<>::
Map.gd::GDScript::-1::1677100526::0::1::::<>TextureRect<>:: Entity.gd::GDScript::-1::1677190734::0::1::::Entity<>Node<>::
World.gd::GDScript::-1::1677092596::0::1::::World<>Node<>:: Global.gd::GDScript::-1::1677174532::0::1::::<>Node<>::
WorldGeneration.gd::GDScript::-1::1677093440::0::1::::<>Control<>:: Map.gd::GDScript::-1::1677190875::0::1::::<>TextureRect<>::
World.gd::GDScript::-1::1677190705::0::1::::World<>Node<>::
WorldGeneration.gd::GDScript::-1::1677193585::0::1::::<>Control<>::

@ -1,8 +1,3 @@
res://scenes/3DWorld.tscn
res://assets/environment.tres
res://scenes/Game.tscn
res://scenes/HUD.tscn
res://scenes/Map.tscn
res://scenes/WorldGeneration.tscn res://scenes/WorldGeneration.tscn
res://scripts/Map.gd res://assets/environment.tres
res://scripts/WorldGeneration.gd res://scenes/3DWorld.tscn

@ -1,6 +1,6 @@
[editor_metadata] [editor_metadata]
executable_path="/home/valentin/Téléchargements/Godot_v4.0-rc3_linux.x86_64" executable_path="/home/valentin/Téléchargements/Godot_v4.0-rc2_linux.x86_64"
tile_source_sort=0 tile_source_sort=0
use_advanced_connections=false use_advanced_connections=false
@ -11,8 +11,8 @@ run_reload_scripts=true
[recent_files] [recent_files]
scenes=["res://scenes/WorldGeneration.tscn", "res://scenes/Map.tscn", "res://scenes/HUD.tscn", "res://scenes/Game.tscn", "res://scenes/3DWorld.tscn", "res://scenes/world_generation.tscn", "res://MeshLib.tscn", "res://scenes/GridMap.tscn", "res://GridMap.tscn", "res://blocs/my_first_bloc.glb"] scenes=["res://scenes/3DWorld.tscn", "res://scenes/WorldGeneration.tscn", "res://assets/test/bloc_complet.glb", "res://scenes/Character.tscn", "res://scenes/Map.tscn", "res://scenes/HUD.tscn", "res://scenes/Game.tscn", "res://scenes/world_generation.tscn", "res://MeshLib.tscn", "res://scenes/GridMap.tscn"]
scripts=["ImageTexture", "Texture2D", "TextureRect", "Image", "Object", "res://scripts/Map.gd", "res://scripts/Chunks.gd", "res://scripts/WorldGeneration.gd", "res://WorldGeneration.gd", "res://scripts/World.gd"] scripts=["res://scripts/Camera3D.gd", "res://scripts/Map.gd", "res://scripts/Entity.gd", "res://scripts/Bloc.gd", "res://scripts/Chunks.gd", "res://scripts/World.gd", "res://scripts/Character.gd", "res://scripts/WorldGeneration.gd", "ImageTexture", "Texture2D"]
[color_picker] [color_picker]
@ -22,7 +22,7 @@ recent_presets=PackedColorArray(1, 1, 1, 1, 0.72549, 0.74902, 0.0156863, 1, 0.74
project_settings=Rect2(830, 1124, 1531, 700) project_settings=Rect2(830, 1124, 1531, 700)
search_help=Rect2(684, 826, 1368, 912) search_help=Rect2(684, 826, 1368, 912)
export=Rect2(468, 286, 1800, 1400) export=Rect2(468, 69, 1800, 1011)
[project_settings] [project_settings]

@ -1,7 +1,7 @@
/home/valentin/Documents/Gridmap/scripts
res://scripts res://scripts
res://assets/test
res://scenes res://scenes
res://assets/tests
/home/valentin/Documents/Gridmap/scripts
res:// res://
res://assets res://assets
/home/valentin/Documents/Gridmap /home/valentin/Documents/Gridmap

@ -1,74 +1,78 @@
[res://scripts/Global.gd] [res://scripts/WorldGeneration.gd]
state={ state={
"bookmarks": PackedInt32Array(), "bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(), "breakpoints": PackedInt32Array(),
"column": 22, "column": 0,
"folded_lines": Array[int]([]), "folded_lines": Array[int]([]),
"h_scroll_position": 0, "h_scroll_position": 0,
"row": 31, "row": 14,
"scroll_position": 11.0, "scroll_position": 0.0,
"selection": false, "selection": false,
"syntax_highlighter": "GDScript" "syntax_highlighter": "GDScript"
} }
[res://scripts/Camera3D.gd] [res://scripts/World.gd]
state={ state={
"bookmarks": PackedInt32Array(), "bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(), "breakpoints": PackedInt32Array(),
"column": 0, "column": 12,
"folded_lines": Array[int]([]), "folded_lines": Array[int]([]),
"h_scroll_position": 0, "h_scroll_position": 0,
"row": 0, "row": 63,
"scroll_position": 0.0, "scroll_position": 6.0,
"selection": false, "selection": false,
"syntax_highlighter": "GDScript" "syntax_highlighter": "GDScript"
} }
[res://scripts/World.gd] [res://scripts/Chunks.gd]
state={ state={
"bookmarks": PackedInt32Array(), "bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(), "breakpoints": PackedInt32Array(),
"column": 0, "column": 20,
"folded_lines": Array[int]([]), "folded_lines": Array[int]([]),
"h_scroll_position": 0, "h_scroll_position": 0,
"row": 46, "row": 110,
"scroll_position": 28.0, "scroll_position": 0.0,
"selection": false, "selection": true,
"selection_from_column": 20,
"selection_from_line": 110,
"selection_to_column": 67,
"selection_to_line": 114,
"syntax_highlighter": "GDScript" "syntax_highlighter": "GDScript"
} }
[res://scripts/Map.gd] [res://scripts/Entity.gd]
state={ state={
"bookmarks": PackedInt32Array(), "bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(), "breakpoints": PackedInt32Array(),
"column": 5, "column": 25,
"folded_lines": Array[int]([]), "folded_lines": Array[int]([]),
"h_scroll_position": 0, "h_scroll_position": 0,
"row": 8, "row": 7,
"scroll_position": 0.0, "scroll_position": 0.0,
"selection": false, "selection": false,
"syntax_highlighter": "GDScript" "syntax_highlighter": "GDScript"
} }
[res://scripts/WorldGeneration.gd] [res://scripts/Map.gd]
state={ state={
"bookmarks": PackedInt32Array(), "bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(), "breakpoints": PackedInt32Array(),
"column": 23, "column": 26,
"folded_lines": Array[int]([]), "folded_lines": Array[int]([]),
"h_scroll_position": 0, "h_scroll_position": 0,
"row": 18, "row": 12,
"scroll_position": 10.0, "scroll_position": 0.0,
"selection": false, "selection": false,
"syntax_highlighter": "GDScript" "syntax_highlighter": "GDScript"
} }
[res://scripts/Chunks.gd] [res://scripts/Camera3D.gd]
state={ state={
"bookmarks": PackedInt32Array(), "bookmarks": PackedInt32Array(),
@ -77,7 +81,7 @@ state={
"folded_lines": Array[int]([]), "folded_lines": Array[int]([]),
"h_scroll_position": 0, "h_scroll_position": 0,
"row": 0, "row": 0,
"scroll_position": 0.0, "scroll_position": 12.0,
"selection": false, "selection": false,
"syntax_highlighter": "GDScript" "syntax_highlighter": "GDScript"
} }

@ -6,6 +6,12 @@ list=Array[Dictionary]([{
"path": "res://utils/camera/CameraController.gd" "path": "res://utils/camera/CameraController.gd"
}, { }, {
"base": &"Node", "base": &"Node",
"class": &"Entity",
"icon": "",
"language": &"GDScript",
"path": "res://scripts/Entity.gd"
}, {
"base": &"Node",
"class": &"World", "class": &"World",
"icon": "", "icon": "",
"language": &"GDScript", "language": &"GDScript",

@ -0,0 +1,3 @@
source_md5="dd6d69728f1e6cf0737febc43f78b625"
dest_md5="3eb390bfa3cdfe1b0a37de377fedf38d"

@ -0,0 +1,3 @@
source_md5="663ed34c11220700fbd6e8a73c9b7b6a"
dest_md5="80f60927ff60435698b02edcd4085ac7"

@ -0,0 +1,3 @@
source_md5="d74e8f37219f33f95741c798386e625b"
dest_md5="489ed7520194a75f639053b1d11fc5be"

Binary file not shown.

Binary file not shown.

@ -0,0 +1,32 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://uqa68jcxs6tj"
path="res://.godot/imported/bloc_complet.glb-994aa1e23eb71978e33bad80f3deaabb.scn"
[deps]
source_file="res://assets/test/bloc_complet.glb"
dest_files=["res://.godot/imported/bloc_complet.glb-994aa1e23eb71978e33bad80f3deaabb.scn"]
[params]
nodes/root_type="Node3D"
nodes/root_name="Scene Root"
nodes/apply_root_scale=true
nodes/root_scale=1.0
meshes/ensure_tangents=true
meshes/generate_lods=false
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
gltf/embedded_image_handling=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

@ -0,0 +1,36 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://chgapiyga3x6o"
path.bptc="res://.godot/imported/bloc_complet_albedo.png-d517f1262761d1fe31bd54f51927d7e2.bptc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
generator_parameters={}
[deps]
source_file="res://assets/test/bloc_complet_albedo.png"
dest_files=["res://.godot/imported/bloc_complet_albedo.png-d517f1262761d1fe31bd54f51927d7e2.bptc.ctex"]
[params]
compress/mode=2
compress/high_quality=true
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

@ -0,0 +1,36 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cmoaaucso40hs"
path.bptc="res://.godot/imported/bloc_complet_normal.png-cbf8a7e820fdc110c6faf4c702e03006.bptc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
generator_parameters={}
[deps]
source_file="res://assets/test/bloc_complet_normal.png"
dest_files=["res://.godot/imported/bloc_complet_normal.png-cbf8a7e820fdc110c6faf4c702e03006.bptc.ctex"]
[params]
compress/mode=2
compress/high_quality=true
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=1
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=1
roughness/src_normal="res://assets/test/bloc_complet_normal.png"
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

@ -0,0 +1,41 @@
[preset.0]
name="Linux/X11"
platform="Linux/X11"
runnable=true
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path=""
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
script_encryption_key=""
[preset.0.options]
custom_template/debug=""
custom_template/release=""
debug/export_console_script=1
binary_format/embed_pck=false
texture_format/bptc=false
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
texture_format/no_bptc_fallbacks=true
binary_format/architecture="x86_64"
ssh_remote_deploy/enabled=false
ssh_remote_deploy/host="user@host_ip"
ssh_remote_deploy/port="22"
ssh_remote_deploy/extra_args_ssh=""
ssh_remote_deploy/extra_args_scp=""
ssh_remote_deploy/run_script="#!/usr/bin/env bash
export DISPLAY=:0
unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
\"{temp_dir}/{exe_name}\" {cmd_args}"
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")
rm -rf \"{temp_dir}\""

@ -7,17 +7,24 @@ extends GridMap
@onready var camera = $Camera3D @onready var camera = $Camera3D
@onready var multimeshInstances = []
func _ready(): func _ready():
setGridChunk(0, ChunkWidth, 0, ChunkHeight) setGridChunk(0, ChunkWidth, 0, ChunkHeight)
func generateGridChunk(cameraPos: Vector3) -> void: func generateGridChunk(cameraPos: Vector3) -> void:
clear() clear()
for instance in multimeshInstances:
remove_child(instance)
multimeshInstances = []
var chunkCenter = local_to_map(cameraPos) var chunkCenter = local_to_map(cameraPos)
var rowStart: float = chunkCenter.z - (ChunkHeight / 2) var rowStart: float = chunkCenter.z - (ChunkHeight / 2)
var rowEnd: float = chunkCenter.z + (ChunkHeight / 2) var rowEnd: float = chunkCenter.z + (ChunkHeight / 2)
var columnStart: float = chunkCenter.x - (ChunkWidth / 2) var columnStart: float = chunkCenter.x - (ChunkWidth / 2)
var columnEnd: float = chunkCenter.x + (ChunkWidth / 2) var columnEnd: float = chunkCenter.x + (ChunkWidth / 2)
setGridChunk(columnStart, columnEnd, rowStart, rowEnd) setGridChunk(columnStart, columnEnd, rowStart, rowEnd)
setEntities(columnStart, columnEnd, rowStart, rowEnd)
func setGridChunk(columnStart: float, columnEnd: float, rowStart: float, rowEnd: float) -> void: func setGridChunk(columnStart: float, columnEnd: float, rowStart: float, rowEnd: float) -> void:
if columnStart < 0 : if columnStart < 0 :
@ -25,83 +32,101 @@ func setGridChunk(columnStart: float, columnEnd: float, rowStart: float, rowEnd:
if rowStart < 0 : if rowStart < 0 :
rowStart = 0 rowStart = 0
if columnEnd > Global.world.width - 1 : if columnEnd > Global.world.width - 1 :
columnEnd =Global. world.width - 2 columnEnd =Global.world.width - 2
if rowEnd > Global.world.height - 1 : if rowEnd > Global.world.height - 1 :
rowEnd = Global.world.height - 2 rowEnd = Global.world.height - 2
for mz in range(rowStart, rowEnd): for mz in range(rowStart, rowEnd):
for mx in range(columnStart, columnEnd): for mx in range(columnStart, columnEnd):
var my: float = Global.world.find_elevation(Vector2(mx, mz)) var bloc = Global.world.get_bloc(Vector2(mx, mz))
var my: float = bloc.y
var meshID var meshID
var mesh_rotation var mesh_rotation
if my > 0: if bloc.type != 0:
var neighbours = Global.world.get_neighbours_4_at_same_height(Vector2(mx, mz)) var neighbours = Global.world.get_neighbours_4_at_same_height(Vector2(mx, mz))
match neighbours: if neighbours == Global.directions_4.RIGHT:
Global.directions_4.RIGHT: meshID = Global.bloc_sides_id.SIDE_3
meshID = Global.bloc_sides_id.SIDE_3 mesh_rotation = Global.GRID_ROTATION[3]
mesh_rotation = Global.GRID_ROTATION[3] elif neighbours == Global.directions_4.LEFT:
meshID = Global.bloc_sides_id.SIDE_3
Global.directions_4.LEFT: mesh_rotation = Global.GRID_ROTATION[1]
meshID = Global.bloc_sides_id.SIDE_3 elif neighbours == Global.directions_4.LEFT + Global.directions_4.RIGHT:
mesh_rotation = Global.GRID_ROTATION[1] meshID = Global.bloc_sides_id.SIDE_2_OPPOSITE
mesh_rotation = Global.GRID_ROTATION[0]
Global.directions_4.LEFT + Global.directions_4.RIGHT: elif neighbours == Global.directions_4.BOTTOM:
meshID = Global.bloc_sides_id.SIDE_2_OPPOSITE meshID = Global.bloc_sides_id.SIDE_3
mesh_rotation = Global.GRID_ROTATION[0] mesh_rotation = Global.GRID_ROTATION[0]
elif neighbours == Global.directions_4.BOTTOM + Global.directions_4.RIGHT:
Global.directions_4.BOTTOM: meshID = Global.bloc_sides_id.SIDE_2_ANGLE
meshID = Global.bloc_sides_id.SIDE_3 mesh_rotation = Global.GRID_ROTATION[3]
mesh_rotation = Global.GRID_ROTATION[0] elif neighbours == Global.directions_4.BOTTOM + Global.directions_4.LEFT:
meshID = Global.bloc_sides_id.SIDE_2_ANGLE
Global.directions_4.BOTTOM + Global.directions_4.RIGHT: mesh_rotation = Global.GRID_ROTATION[0]
meshID = Global.bloc_sides_id.SIDE_2_ANGLE elif neighbours == Global.directions_4.BOTTOM + Global.directions_4.LEFT + Global.directions_4.RIGHT:
mesh_rotation = Global.GRID_ROTATION[3] meshID = Global.bloc_sides_id.SIDE_1
mesh_rotation = Global.GRID_ROTATION[0]
Global.directions_4.BOTTOM + Global.directions_4.LEFT: elif neighbours == Global.directions_4.TOP:
meshID = Global.bloc_sides_id.SIDE_2_ANGLE meshID = Global.bloc_sides_id.SIDE_3
mesh_rotation = Global.GRID_ROTATION[0] mesh_rotation = Global.GRID_ROTATION[2]
elif neighbours == Global.directions_4.TOP + Global.directions_4.RIGHT:
Global.directions_4.BOTTOM + Global.directions_4.LEFT + Global.directions_4.RIGHT: meshID = Global.bloc_sides_id.SIDE_2_ANGLE
meshID = Global.bloc_sides_id.SIDE_1 mesh_rotation = Global.GRID_ROTATION[2]
mesh_rotation = Global.GRID_ROTATION[0] elif neighbours == Global.directions_4.TOP + Global.directions_4.LEFT:
meshID = Global.bloc_sides_id.SIDE_2_ANGLE
Global.directions_4.TOP: mesh_rotation = Global.GRID_ROTATION[1]
meshID = Global.bloc_sides_id.SIDE_3 elif neighbours == Global.directions_4.TOP + Global.directions_4.LEFT + Global.directions_4.RIGHT:
mesh_rotation = Global.GRID_ROTATION[2] meshID = Global.bloc_sides_id.SIDE_1
mesh_rotation = Global.GRID_ROTATION[2]
Global.directions_4.TOP + Global.directions_4.RIGHT: elif neighbours == Global.directions_4.TOP + Global.directions_4.BOTTOM:
meshID = Global.bloc_sides_id.SIDE_2_ANGLE meshID = Global.bloc_sides_id.SIDE_2_OPPOSITE
mesh_rotation = Global.GRID_ROTATION[2] mesh_rotation = Global.GRID_ROTATION[1]
elif neighbours == Global.directions_4.TOP + Global.directions_4.BOTTOM + Global.directions_4.RIGHT:
Global.directions_4.TOP + Global.directions_4.LEFT: meshID = Global.bloc_sides_id.SIDE_1
meshID = Global.bloc_sides_id.SIDE_2_ANGLE mesh_rotation = Global.GRID_ROTATION[3]
mesh_rotation = Global.GRID_ROTATION[1] elif neighbours == Global.directions_4.TOP + Global.directions_4.BOTTOM + Global.directions_4.LEFT:
meshID = Global.bloc_sides_id.SIDE_1
Global.directions_4.TOP + Global.directions_4.LEFT + Global.directions_4.RIGHT: mesh_rotation = Global.GRID_ROTATION[1]
meshID = Global.bloc_sides_id.SIDE_1 elif neighbours == Global.directions_4.TOP + Global.directions_4.BOTTOM + Global.directions_4.LEFT + Global.directions_4.RIGHT:
mesh_rotation = Global.GRID_ROTATION[2] meshID = Global.bloc_sides_id.SIDE_0
mesh_rotation = Global.GRID_ROTATION[0]
Global.directions_4.TOP + Global.directions_4.BOTTOM: elif neighbours == 0:
meshID = Global.bloc_sides_id.SIDE_2_OPPOSITE meshID = Global.bloc_sides_id.SIDE_4
mesh_rotation = Global.GRID_ROTATION[1] mesh_rotation = Global.GRID_ROTATION[0]
Global.directions_4.TOP + Global.directions_4.BOTTOM + Global.directions_4.RIGHT:
meshID = Global.bloc_sides_id.SIDE_1
mesh_rotation = Global.GRID_ROTATION[3]
Global.directions_4.TOP + Global.directions_4.BOTTOM + Global.directions_4.LEFT:
meshID = Global.bloc_sides_id.SIDE_1
mesh_rotation = Global.GRID_ROTATION[1]
Global.directions_4.TOP + Global.directions_4.BOTTOM + Global.directions_4.LEFT + Global.directions_4.RIGHT:
meshID = Global.bloc_sides_id.SIDE_0
mesh_rotation = Global.GRID_ROTATION[0]
0:
meshID = Global.bloc_sides_id.SIDE_4
mesh_rotation = Global.GRID_ROTATION[0]
set_cell_item( Vector3(mx, my, mz) , meshID, mesh_rotation) set_cell_item( Vector3(mx, my, mz) , meshID, mesh_rotation)
func setEntities(columnStart: float, columnEnd: float, rowStart: float, rowEnd: float) -> void:
if columnStart < 0 :
columnStart = 0
if rowStart < 0 :
rowStart = 0
if columnEnd > Global.world.width - 1 :
columnEnd =Global.world.width - 2
if rowEnd > Global.world.height - 1 :
rowEnd = Global.world.height - 2
var multimesh = MultiMesh.new()
multimesh.mesh = CapsuleMesh.new()
multimesh.transform_format = MultiMesh.TRANSFORM_3D
var instances = []
for mz in range(rowStart, rowEnd):
for mx in range(columnStart, columnEnd):
var bloc = Global.world.get_bloc(Vector2(mx, mz))
if bloc.entity != -1:
instances.append(map_to_local(Vector3(bloc.x, bloc.y, bloc.z)))
multimesh.instance_count = instances.size()
for instance_index in multimesh.instance_count:
var transform := Transform3D()
transform.origin = instances[instance_index]
multimesh.set_instance_transform(instance_index, transform)
if instances.size():
var multimesh_instance = MultiMeshInstance3D.new()
multimesh_instance.multimesh = multimesh
multimeshInstances.append(multimesh_instance)
add_child(multimeshInstances[multimeshInstances.size()-1])
func _on_map_update_timer_timeout(): func _on_map_update_timer_timeout():
generateGridChunk(camera.global_transform.origin) generateGridChunk(camera.global_transform.origin)

@ -0,0 +1,8 @@
extends Node
class_name Entity
var position: Vector2
func _init(position: Vector2):
self.position = position

@ -6,9 +6,11 @@ func _ready():
for x in Global.world.width: for x in Global.world.width:
for z in Global.world.height: for z in Global.world.height:
var pixel_color = Color("#00F") var pixel_color = Color("#00F")
var y = Global.world.find_elevation(Vector2(x, z)) var bloc = Global.world.get_bloc(Vector2(x, z))
if y > 0: if bloc.type != 0:
pixel_color = Color("#0F0") pixel_color = Color("#0F0")
if bloc.entity != -1:
pixel_color = Color("F00")
img.set_pixel(x, z, pixel_color) img.set_pixel(x, z, pixel_color)
texture = ImageTexture.create_from_image(img) texture = ImageTexture.create_from_image(img)

@ -2,46 +2,64 @@ extends Node
class_name World class_name World
var heightmap: Array var heightMap: Array
var temperatureMap: Array
var moistureMap: Array
var blocs: Array
var entities: Array
var width: int var width: int
var height: int var height: int
func get_neighbours_8_at_same_height(point: Vector2): func get_neighbours_8_at_same_height(point: Vector2):
var neighbours = 0 var neighbours = 0
var current_bloc = heightmap[point.x][point.y] var current_bloc = heightMap[point.x][point.y]
if heightmap[point.x-1][point.y-1] == current_bloc: if heightMap[point.x-1][point.y-1] == current_bloc:
neighbours += Global.directions_8.TOP_LEFT neighbours += Global.directions_8.TOP_LEFT
if heightmap[point.x][point.y-1] == current_bloc: if heightMap[point.x][point.y-1] == current_bloc:
neighbours += Global.directions_8.TOP neighbours += Global.directions_8.TOP
if heightmap[point.x+1][point.y-1] == current_bloc: if heightMap[point.x+1][point.y-1] == current_bloc:
neighbours += Global.directions_8.TOP_RIGHT neighbours += Global.directions_8.TOP_RIGHT
if heightmap[point.x+1][point.y] == current_bloc: if heightMap[point.x+1][point.y] == current_bloc:
neighbours += Global.directions_8.RIGHT neighbours += Global.directions_8.RIGHT
if heightmap[point.x+1][point.y+1] == current_bloc: if heightMap[point.x+1][point.y+1] == current_bloc:
neighbours += Global.directions_8.BOTTOM_RIGHT neighbours += Global.directions_8.BOTTOM_RIGHT
if heightmap[point.x][point.y+1] == current_bloc: if heightMap[point.x][point.y+1] == current_bloc:
neighbours += Global.directions_8.BOTTOM neighbours += Global.directions_8.BOTTOM
if heightmap[point.x-1][point.y+1] == current_bloc: if heightMap[point.x-1][point.y+1] == current_bloc:
neighbours += Global.directions_8.BOTTOM_LEFT neighbours += Global.directions_8.BOTTOM_LEFT
if heightmap[point.x-1][point.y] == current_bloc: if heightMap[point.x-1][point.y] == current_bloc:
neighbours += Global.directions_8.LEFT neighbours += Global.directions_8.LEFT
return neighbours return neighbours
func get_neighbours_4_at_same_height(point: Vector2): func get_neighbours_4_at_same_height(point: Vector2):
var neighbours = 0 var neighbours = 0
var current_bloc = heightmap[point.x][point.y] var current_bloc = heightMap[point.x][point.y]
if heightmap[point.x][point.y-1] == current_bloc: if heightMap[point.x][point.y-1] == current_bloc:
neighbours += Global.directions_4.TOP neighbours += Global.directions_4.TOP
if heightmap[point.x+1][point.y] == current_bloc: if heightMap[point.x+1][point.y] == current_bloc:
neighbours += Global.directions_4.RIGHT neighbours += Global.directions_4.RIGHT
if heightmap[point.x][point.y+1] == current_bloc: if heightMap[point.x][point.y+1] == current_bloc:
neighbours += Global.directions_4.BOTTOM neighbours += Global.directions_4.BOTTOM
if heightmap[point.x-1][point.y] == current_bloc: if heightMap[point.x-1][point.y] == current_bloc:
neighbours += Global.directions_4.LEFT neighbours += Global.directions_4.LEFT
return neighbours return neighbours
func find_elevation(point: Vector2): func get_bloc(point: Vector2):
return heightmap[point.x][point.y] var bloc = {
"x" = point.x,
"y" = heightMap[point.x][point.y],
"z" = point.y
}
for key in blocs[point.x][point.y].keys():
bloc[key] = blocs[point.x][point.y][key]
return bloc
func add_entity(position: Vector2):
entities.append(Entity.new(position))
blocs[position.x][position.y]["entity"] = entities.size()
pass

@ -3,7 +3,11 @@ extends Control
func _ready(): func _ready():
Global.world.width = 512 Global.world.width = 512
Global.world.height = 512 Global.world.height = 512
Global.world.heightmap = generate_heightmap(Global.world.width, Global.world.height) Global.world.heightMap = generate_heightmap(Global.world.width, Global.world.height)
Global.world.blocs = set_blocs(Global.world.width, Global.world.height, Global.world.heightMap)
Global.world.add_entity(Vector2(10, 10))
get_tree().change_scene_to_file("scenes/Game.tscn") get_tree().change_scene_to_file("scenes/Game.tscn")
func generate_heightmap(width, height): func generate_heightmap(width, height):
@ -39,3 +43,20 @@ func generate_heightmap(width, height):
# print(elevation) # print(elevation)
heightmap[x].append(floor(elevation)) heightmap[x].append(floor(elevation))
return heightmap return heightmap
func set_blocs(width, height, heightmap):
var blocs = []
for x in width:
blocs.append([])
for y in height:
var bloc = {
"type": 0,
"entity": -1
}
if heightmap[x][y] > 0:
bloc.type = 1
blocs[x].append(bloc)
return blocs

Loading…
Cancel
Save