enhance navigation

pull/7/head
Valentin Stark 3 years ago
parent 85a5520013
commit d6842dd411
  1. 8
      ui/map/cursor/Cursor.gd
  2. BIN
      ui/map/cursor/cursor.png
  3. 35
      ui/map/cursor/cursor.png.import
  4. 8
      ui/map/map.gd
  5. 8
      ui/map/map.tscn
  6. 3
      utils/camera/CamBase.tscn
  7. 3
      world/World.gd
  8. 21
      world/game.tscn

@ -0,0 +1,8 @@
extends Sprite
func _on_Camera_camera_moved(new_location):
var map_x = new_location.x
var map_y = new_location.z
position.x = map_x
position.y = map_y
pass # Replace with function body.

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/cursor.png-c6b2f949aa939fd4f4289acd7e6ebaee.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://ui/map/cursor/cursor.png"
dest_files=[ "res://.import/cursor.png-c6b2f949aa939fd4f4289acd7e6ebaee.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

@ -1,5 +1,7 @@
extends Node2D extends Node2D
signal map_clicked
var terrain var terrain
func heightmap(): func heightmap():
@ -102,6 +104,12 @@ func _draw():
# draw_voronoi_cells_convex_hull() # draw_voronoi_cells_convex_hull()
# draw_voronoi_edges(Color("#ff0000")) # draw_voronoi_edges(Color("#ff0000"))
func _process(delta):
if Input.is_action_pressed("alt_command"):
var new_position = get_viewport().get_mouse_position() / scale
if new_position.x <= 2000 and new_position.y <= 2000:
emit_signal("map_clicked", new_position)
func _on_Game_world_loaded(game_terrain): func _on_Game_world_loaded(game_terrain):
terrain = game_terrain terrain = game_terrain
update() update()

@ -1,6 +1,12 @@
[gd_scene load_steps=2 format=2] [gd_scene load_steps=4 format=2]
[ext_resource path="res://ui/map/map.gd" type="Script" id=1] [ext_resource path="res://ui/map/map.gd" type="Script" id=1]
[ext_resource path="res://ui/map/cursor/cursor.png" type="Texture" id=2]
[ext_resource path="res://ui/map/cursor/Cursor.gd" type="Script" id=3]
[node name="Map" type="Node2D"] [node name="Map" type="Node2D"]
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="Cursor" type="Sprite" parent="."]
texture = ExtResource( 2 )
script = ExtResource( 3 )

@ -6,10 +6,11 @@
[ext_resource path="res://utils/camera/CameraInput.gd" type="Script" id=4] [ext_resource path="res://utils/camera/CameraInput.gd" type="Script" id=4]
[node name="CamBase" type="Spatial"] [node name="CamBase" type="Spatial"]
transform = Transform( 1, 0, 0, 0, 0.34202, 0.939693, 0, -0.939693, 0.34202, 0, 0, 0 ) transform = Transform( 1, 0, 0, 0, 0.0238738, 0.999715, 0, -0.999715, 0.0238738, 0, 0, 16.935 )
script = ExtResource( 2 ) script = ExtResource( 2 )
[node name="Camera" type="Camera" parent="."] [node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 0.910272, -0.41401, 0, 0.41401, 0.910272, 0, 0, 6.618 )
size = 20.0 size = 20.0
near = 0.01 near = 0.01
far = 8192.0 far = 8192.0

@ -16,7 +16,7 @@ func draw_world():
st.add_vertex(point.point3d() * Vector3(1, 24*5, 1)) st.add_vertex(point.point3d() * Vector3(1, 24*5, 1))
st.generate_normals() st.generate_normals()
st.generate_tangents() # st.generate_tangents()
st.index() st.index()
# Commit to a mesh. # Commit to a mesh.
var mesh = st.commit() var mesh = st.commit()
@ -33,3 +33,4 @@ func draw_world():
func _on_Game_world_loaded(game_terrain): func _on_Game_world_loaded(game_terrain):
terrain = game_terrain terrain = game_terrain
draw_world() draw_world()

@ -1,4 +1,4 @@
[gd_scene load_steps=7 format=2] [gd_scene load_steps=8 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/game.gd" type="Script" id=2]
@ -9,6 +9,9 @@
[sub_resource type="PlaneMesh" id=1] [sub_resource type="PlaneMesh" id=1]
size = Vector2( 2000, 2000 ) size = Vector2( 2000, 2000 )
[sub_resource type="SpatialMaterial" id=2]
albedo_color = Color( 0.054902, 0.533333, 0.741176, 1 )
[node name="Game" type="Node"] [node name="Game" type="Node"]
script = ExtResource( 2 ) script = ExtResource( 2 )
@ -17,24 +20,38 @@ script = ExtResource( 2 )
[node name="Map" parent="UI" index="0"] [node name="Map" parent="UI" index="0"]
scale = Vector2( 0.25, 0.25 ) scale = Vector2( 0.25, 0.25 )
[node name="Cursor" parent="UI/Map" index="0"]
scale = Vector2( 4, 4 )
z_index = 3
[node name="World" type="Spatial" parent="."] [node name="World" type="Spatial" parent="."]
script = ExtResource( 4 ) script = ExtResource( 4 )
[node name="Water" type="MeshInstance" parent="World"] [node name="Water" type="MeshInstance" parent="World"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1000, 0, 1000 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1000, -0.1, 1000 )
mesh = SubResource( 1 ) mesh = SubResource( 1 )
material/0 = SubResource( 2 )
[node name="WorldEnvironment" type="WorldEnvironment" parent="World"] [node name="WorldEnvironment" type="WorldEnvironment" parent="World"]
environment = ExtResource( 3 ) environment = ExtResource( 3 )
[node name="CamBase" parent="World" instance=ExtResource( 5 )] [node name="CamBase" parent="World" instance=ExtResource( 5 )]
[node name="Camera" parent="World/CamBase" index="0"]
movement_speed = 48.076
min_zoom = 10.0
zoom_sensibility = 1.436
rotation_sensibility = 3.0
[node name="DirectionalLight" type="DirectionalLight" parent="World"] [node name="DirectionalLight" type="DirectionalLight" parent="World"]
transform = Transform( 1, 0, 0, 0, 0.41636, 0.9092, 0, -0.9092, 0.41636, 0, 1.41623, 0 ) transform = Transform( 1, 0, 0, 0, 0.41636, 0.9092, 0, -0.9092, 0.41636, 0, 1.41623, 0 )
light_energy = 0.1 light_energy = 0.1
[connection signal="world_loaded" from="." to="UI/Map" method="_on_Game_world_loaded"] [connection signal="world_loaded" from="." to="UI/Map" method="_on_Game_world_loaded"]
[connection signal="world_loaded" from="." to="World" method="_on_Game_world_loaded"] [connection signal="world_loaded" from="." to="World" method="_on_Game_world_loaded"]
[connection signal="map_clicked" from="UI/Map" to="World/CamBase/Camera" method="_on_Map_map_clicked"]
[connection signal="camera_moved" from="World/CamBase/Camera" to="UI/Map/Cursor" method="_on_Camera_camera_moved"]
[editable path="UI"] [editable path="UI"]
[editable path="UI/Map"]
[editable path="World/CamBase"] [editable path="World/CamBase"]

Loading…
Cancel
Save