diff --git a/project.godot b/project.godot index 9d83e5b..7a96e00 100644 --- a/project.godot +++ b/project.godot @@ -71,3 +71,8 @@ LMC={ "events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null) ] } +"tile type loop"={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":84,"key_label":0,"unicode":116,"echo":false,"script":null) +] +} diff --git a/scenes/models/god.tscn b/scenes/models/god.tscn index d20b5db..5bc14d0 100644 --- a/scenes/models/god.tscn +++ b/scenes/models/god.tscn @@ -11,6 +11,6 @@ script = ExtResource("1_hfa56") [node name="eye" type="RayCast3D" parent="Camera"] transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0, 0) -target_position = Vector3(50, 0, 0) +target_position = Vector3(100, 0, 0) [node name="UI" parent="." instance=ExtResource("2_06brk")] diff --git a/scenes/models/tile.tscn b/scenes/models/tile.tscn index 898e836..9729753 100644 --- a/scenes/models/tile.tscn +++ b/scenes/models/tile.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=9 format=3 uid="uid://dj0odn77jplje"] +[gd_scene load_steps=11 format=3 uid="uid://dj0odn77jplje"] [ext_resource type="Script" path="res://scripts/Tile.gd" id="1_s01tx"] [ext_resource type="Texture2D" uid="uid://d1k366i5jjtrk" path="res://textures/plus.svg" id="2_cddgt"] @@ -24,6 +24,13 @@ albedo_color = Color(0.203922, 0.458824, 0.113725, 1) material = SubResource("StandardMaterial3D_0knec") size = Vector3(10, 5, 10) +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_1j1g6"] +albedo_color = Color(0.722463, 0, 0.290934, 1) + +[sub_resource type="BoxMesh" id="BoxMesh_341o5"] +material = SubResource("StandardMaterial3D_1j1g6") +size = Vector3(10, 5, 10) + [node name="Tile" type="StaticBody3D"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2.5, 0) script = ExtResource("1_s01tx") @@ -52,7 +59,7 @@ visible = false shape = SubResource("ConcavePolygonShape3D_scykg") [node name="VisibleMesh" type="MeshInstance3D" parent="Forest_tile"] -mesh = SubResource("BoxMesh_doul4") +mesh = SubResource("BoxMesh_341o5") skeleton = NodePath("../..") [node name="ray_north" type="RayCast3D" parent="."] diff --git a/scenes/ui.tscn b/scenes/ui.tscn index d23599f..5f38d0f 100644 --- a/scenes/ui.tscn +++ b/scenes/ui.tscn @@ -33,3 +33,9 @@ offset_bottom = 4.0 grow_horizontal = 2 grow_vertical = 2 mouse_filter = 1 + +[node name="tile_type_label" type="Label" parent="."] +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 23.0 +text = "Tile type: Plain" diff --git a/scripts/God.gd b/scripts/God.gd index ed22429..f4f6f56 100644 --- a/scripts/God.gd +++ b/scripts/God.gd @@ -4,11 +4,22 @@ const SENSETIVITY = 0.009; var walk = 0.25 @onready var head = $"." @onready var camera = $"./Camera" + @onready var ui = $"./UI" @onready var velocity_label: Label = ui.find_child("velocity_label") +@onready var tile_type_label: Label = ui.find_child("tile_type_label") + @onready var eye_raycast: RayCast3D = $"./Camera/eye" @onready var earth = $"../Earth" +enum TileType { + Empty, + Plain, + Forest +} + +var creating_tile_type = TileType.Plain + func _ready(): camera.make_current() Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) @@ -30,16 +41,18 @@ func _physics_process(delta): velocity_label.text = "Velocity: " + str(walk) var input_dir = Input.get_vector("left", "right", "forward", "backward") - #var direction = head.transform.rotation var direction = (head.transform.basis * Vector3(input_dir.x, input_dir.x, input_dir.y)).normalized() - #var direction = (head.transform.basis * Vector2(input_dir.x, input_dir.y)).normalized() var velocity = Vector3.ZERO var speed + if Input.is_action_just_pressed("tile type loop"): + creating_tile_type = wrap(creating_tile_type + 1, 0, 3) + tile_type_label.text = "Tile type: " + str(TileType.keys()[creating_tile_type]) + if Input.is_action_just_pressed("LMC") and eye_raycast.is_colliding(): var target = eye_raycast.get_collider() - if "TileType" in target and target.tile_type == 0: - target.tile_type = 2 + if "TileType" in target: + target.tile_type = creating_tile_type target.update_tile() earth.mark_free_tiles()