diff --git a/camera_zoom.gd b/camera_zoom.gd new file mode 100644 index 0000000..8c49d0b --- /dev/null +++ b/camera_zoom.gd @@ -0,0 +1,14 @@ +extends Node + +var enabled: bool = false +var cost: int = 3 +var upgrade_name: String = "Camera" +var upgrade_description: String = "Afegeix una camera especial" +var icon: Texture2D = preload("res://assets/Images/Xenia Drawing 6.svg") + +func update() -> void: + if enabled: + Global.special_camera = true + else: + Global.special_camera = false + diff --git a/camera_zoom.gd.uid b/camera_zoom.gd.uid new file mode 100644 index 0000000..775b98d --- /dev/null +++ b/camera_zoom.gd.uid @@ -0,0 +1 @@ +uid://dew108n0d84n1 diff --git a/global.gd b/global.gd index 2e1c15d..d86edc9 100644 --- a/global.gd +++ b/global.gd @@ -2,3 +2,4 @@ extends Node var chunk_size: float = 150 var street_width: float = 40 var station_coords: Vector3 = Vector3.ZERO +var special_camera: bool = false diff --git a/level.gd b/level.gd index dece73b..398b4da 100644 --- a/level.gd +++ b/level.gd @@ -151,9 +151,18 @@ func initialize_world() -> void: chunk.exits[3] = true chunk.update() + + func _process(delta: float) -> void: + + if Global.special_camera: + $SubViewportContainer.visible = true + else: + $SubViewportContainer.visible = false + + if not $Player.is_active: return @@ -171,6 +180,7 @@ func _process(delta: float) -> void: new_ped.position = ped_pos func _on_player_station_reached(): + $SubViewportContainer.visible = false for n in $ChunkContainer.get_children(): $ChunkContainer.remove_child(n) n.queue_free() diff --git a/level.tscn b/level.tscn index 12b6666..9327f8e 100644 --- a/level.tscn +++ b/level.tscn @@ -3,6 +3,7 @@ [ext_resource type="Script" uid="uid://dj0cgqed5n3ys" path="res://level.gd" id="1_0b4ue"] [ext_resource type="PackedScene" uid="uid://cmb3b7xrlboy3" path="res://player.tscn" id="1_u52ul"] [ext_resource type="Script" uid="uid://b5ebibi08tjvd" path="res://camera_3d.gd" id="2_vonw3"] +[ext_resource type="Script" uid="uid://oy8s25dl6g4a" path="res://special_camera.gd" id="4_0b4ue"] [sub_resource type="Environment" id="Environment_vonw3"] ambient_light_source = 2 @@ -26,7 +27,7 @@ environment = SubResource("Environment_vonw3") transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.8361101, 0) [node name="Camera3D" type="Camera3D" parent="." unique_id=2083164402] -transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 73.98364, 0) +transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 56.95375, 0) current = true fov = 55.0 script = ExtResource("2_vonw3") @@ -37,4 +38,21 @@ shadow_enabled = true [node name="ChunkContainer" type="Node3D" parent="." unique_id=166513533] +[node name="SubViewportContainer" type="SubViewportContainer" parent="." unique_id=2002031723] +offset_top = 1.0 +offset_right = 207.0 +offset_bottom = 196.0 +stretch = true + +[node name="SubViewport" type="SubViewport" parent="SubViewportContainer" unique_id=1364308452] +handle_input_locally = false +size = Vector2i(207, 195) +render_target_update_mode = 4 + +[node name="SpecialCamera" type="Camera3D" parent="SubViewportContainer/SubViewport" unique_id=684008087] +transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 139.07289, 0) +current = true +fov = 55.0 +script = ExtResource("4_0b4ue") + [connection signal="station_reached" from="Player" to="." method="_on_player_station_reached"] diff --git a/pickup/speed_boost.tscn b/pickup/speed_boost.tscn index 34652b1..038b0b2 100644 --- a/pickup/speed_boost.tscn +++ b/pickup/speed_boost.tscn @@ -20,6 +20,7 @@ func _on_area_entered(area: Area3D) -> void: [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_cumbd"] transparency = 1 +albedo_color = Color(0.98752075, 0.9222888, 0.91135114, 1) albedo_texture = ExtResource("1_y24h4") [sub_resource type="CylinderShape3D" id="CylinderShape3D_rqnpm"] diff --git a/special_camera.gd b/special_camera.gd new file mode 100644 index 0000000..ec75d2a --- /dev/null +++ b/special_camera.gd @@ -0,0 +1,7 @@ +extends Camera3D + +@onready var player: CharacterBody3D = $"../../../Player" + +func _process(delta: float) -> void: + self.position.x = player.position.x + self.position.z = player.position.z diff --git a/special_camera.gd.uid b/special_camera.gd.uid new file mode 100644 index 0000000..ed9f648 --- /dev/null +++ b/special_camera.gd.uid @@ -0,0 +1 @@ +uid://oy8s25dl6g4a diff --git a/special_upgrades.tscn b/special_upgrades.tscn index 4481543..614731a 100644 --- a/special_upgrades.tscn +++ b/special_upgrades.tscn @@ -1,6 +1,7 @@ [gd_scene format=3 uid="uid://byv518wlck1t4"] [ext_resource type="Script" uid="uid://bxvhar7bgeyau" path="res://special_upgrades.gd" id="1_76f4f"] +[ext_resource type="Script" uid="uid://dew108n0d84n1" path="res://camera_zoom.gd" id="2_wn1cs"] [sub_resource type="GDScript" id="GDScript_8j6ry"] script/source = "extends Node @@ -9,12 +10,15 @@ var enabled: bool = false var cost: int = 3 var upgrade_name: String = \"Tamany bloc\" var upgrade_description: String = \"Fa mes xicotet cada bloc\" -var icon: Texture2D = preload(\"res://assets/Images/tren.jpg\") +var icon: Texture2D = preload(\"res://assets/Images/Xenia Drawing 6.svg\") func update() -> void: if enabled: print(\"Updating chunk size\") Global.chunk_size = 120 + else: + Global.chunk_size = 150 + " [node name="SpecialUpgrades" type="Node" unique_id=1238785974] @@ -22,3 +26,6 @@ script = ExtResource("1_76f4f") [node name="ChunkSize" type="Node" parent="." unique_id=1030985851] script = SubResource("GDScript_8j6ry") + +[node name="CameraZoom" type="Node" parent="." unique_id=1211450879] +script = ExtResource("2_wn1cs")