497009 před 2 roky
rodič
revize
cb569154a6

+ 3 - 6
godot_project/Player.tscn

@@ -1,7 +1,8 @@
-[gd_scene load_steps=4 format=2]
+[gd_scene load_steps=5 format=2]
 
 [ext_resource path="res://icon.png" type="Texture" id=1]
 [ext_resource path="res://Player.gd" type="Script" id=2]
+[ext_resource path="res://Player_camera.tscn" type="PackedScene" id=3]
 
 [sub_resource type="RectangleShape2D" id=1]
 extents = Vector2( 32, 32 )
@@ -53,9 +54,5 @@ autostart = true
 wait_time = 0.3
 one_shot = true
 
-[node name="Camera2D" type="Camera2D" parent="."]
-current = true
-zoom = Vector2( 1.5, 1.5 )
-smoothing_enabled = true
-smoothing_speed = 3.0
+[node name="Camera2D" parent="." instance=ExtResource( 3 )]
 [connection signal="timeout" from="update_can_dash" to="." method="_on_update_can_dash_timeout"]

+ 7 - 0
godot_project/Player_camera.tscn

@@ -0,0 +1,7 @@
+[gd_scene format=2]
+
+[node name="Camera2D" type="Camera2D"]
+current = true
+zoom = Vector2( 1.5, 1.5 )
+smoothing_enabled = true
+smoothing_speed = 3.0

+ 15 - 0
godot_project/laser.gd

@@ -0,0 +1,15 @@
+extends Node2D
+
+
+func _ready():
+	if $Line2D.get_point_count() == 2:
+		$RayCast2D.position = $Line2D.get_point_position(0)
+		$RayCast2D.set_cast_to($Line2D.get_point_position(1))
+	
+	else:
+		print("Line2D has more than 2 points. Will not work")
+		
+
+func _physics_process(delta):
+	if $RayCast2D.get_collider():
+		$RayCast2D.get_collider().queue_free()

+ 15 - 33
godot_project/test_scene.tscn

@@ -1,24 +1,18 @@
-[gd_scene load_steps=11 format=2]
+[gd_scene load_steps=9 format=2]
 
 [ext_resource path="res://moving_platform.tscn" type="PackedScene" id=1]
 [ext_resource path="res://Player.tscn" type="PackedScene" id=2]
 [ext_resource path="res://self_destroying_tiles.tscn" type="PackedScene" id=3]
 [ext_resource path="res://jumpable_tiles.tscn" type="PackedScene" id=4]
-[ext_resource path="res://icon.png" type="Texture" id=5]
+[ext_resource path="res://vent.tscn" type="PackedScene" id=5]
 [ext_resource path="res://light_platform.tscn" type="PackedScene" id=6]
-[ext_resource path="res://vent.gd" type="Script" id=7]
+[ext_resource path="res://laser.gd" type="Script" id=7]
 
 [sub_resource type="Curve2D" id=1]
 _data = {
 "points": PoolVector2Array( 0, 0, 0, 0, 864, 416, 0, 0, 0, 0, 1360, 416, 0, 0, 0, 0, 1360, 528, 0, 0, 0, 0, 864, 528, 0, 0, 0, 0, 864, 416 )
 }
 
-[sub_resource type="RectangleShape2D" id=2]
-extents = Vector2( 24.1317, 32 )
-
-[sub_resource type="RectangleShape2D" id=3]
-extents = Vector2( 15.8477, 16.8909 )
-
 [node name="Node2D" type="Node2D"]
 
 [node name="Player" parent="." instance=ExtResource( 2 )]
@@ -41,33 +35,21 @@ time_for_loop = 10
 
 [node name="light_platform" parent="." instance=ExtResource( 6 )]
 
-[node name="vent" type="Area2D" parent="."]
-position = Vector2( 93.2285, 75.2341 )
-script = ExtResource( 7 )
-
-[node name="CollisionShape2D" type="CollisionShape2D" parent="vent"]
-position = Vector2( -8, 0 )
-shape = SubResource( 2 )
-
-[node name="Sprite" type="Sprite" parent="vent"]
-modulate = Color( 0.976471, 0.937255, 0.0156863, 1 )
-position = Vector2( -8, 0 )
-scale = Vector2( 0.75, 1 )
-texture = ExtResource( 5 )
+[node name="vent" parent="." instance=ExtResource( 5 )]
 
-[node name="button" type="Area2D" parent="vent" groups=[
-"buttons",
-]]
-position = Vector2( -29.2285, 404.766 )
+[node name="laser" type="Node2D" parent="."]
+position = Vector2( 816, 480 )
+script = ExtResource( 7 )
 __meta__ = {
 "_edit_group_": true
 }
 
-[node name="CollisionShape2D" type="CollisionShape2D" parent="vent/button"]
-shape = SubResource( 3 )
+[node name="Line2D" type="Line2D" parent="laser"]
+points = PoolVector2Array( 0, 0, 240, 0 )
+width = 3.0
+default_color = Color( 0.992157, 0.00784314, 0.00784314, 1 )
+round_precision = 16
 
-[node name="Sprite" type="Sprite" parent="vent/button"]
-modulate = Color( 0.992157, 0.0313726, 0.952941, 1 )
-position = Vector2( 1.90735e-06, 1.90735e-06 )
-scale = Vector2( 0.5, 0.5 )
-texture = ExtResource( 5 )
+[node name="RayCast2D" type="RayCast2D" parent="laser"]
+enabled = true
+cast_to = Vector2( 0, 0 )

+ 41 - 0
godot_project/vent.tscn

@@ -0,0 +1,41 @@
+[gd_scene load_steps=5 format=2]
+
+[ext_resource path="res://vent.gd" type="Script" id=1]
+[ext_resource path="res://icon.png" type="Texture" id=2]
+
+[sub_resource type="RectangleShape2D" id=2]
+extents = Vector2( 24.1317, 32 )
+
+[sub_resource type="RectangleShape2D" id=3]
+extents = Vector2( 15.8477, 16.8909 )
+
+[node name="vent" type="Area2D"]
+position = Vector2( 93.2285, 75.2341 )
+script = ExtResource( 1 )
+
+[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
+position = Vector2( -8, 0 )
+shape = SubResource( 2 )
+
+[node name="Sprite" type="Sprite" parent="."]
+modulate = Color( 0.976471, 0.937255, 0.0156863, 1 )
+position = Vector2( -8, 0 )
+scale = Vector2( 0.75, 1 )
+texture = ExtResource( 2 )
+
+[node name="button" type="Area2D" parent="." groups=[
+"buttons",
+]]
+position = Vector2( 50.7715, 4.76595 )
+__meta__ = {
+"_edit_group_": true
+}
+
+[node name="CollisionShape2D" type="CollisionShape2D" parent="button"]
+shape = SubResource( 3 )
+
+[node name="Sprite" type="Sprite" parent="button"]
+modulate = Color( 0.992157, 0.0313726, 0.952941, 1 )
+position = Vector2( 1.90735e-06, 1.90735e-06 )
+scale = Vector2( 0.5, 0.5 )
+texture = ExtResource( 2 )