diff --git a/saw.gd b/saw.gd index 01a885c..f6dd50c 100644 --- a/saw.gd +++ b/saw.gd @@ -1,17 +1,21 @@ extends Node2D -@export var max_distance = 260.0 +@export var max_distance_x = 100.0 +@export var max_distance_y = 100.0 @export var moving = true -var alt_position = Vector2(position.x + max_distance,0) +var alt_position = Vector2(position.x + max_distance_x,0) +var alt_position2 = Vector2(position.x - max_distance_x,0) @export var move_speed = 0.0 func _ready() -> void: - alt_position = Vector2(position.x + max_distance,0) + alt_position = Vector2(position.x + max_distance_x,0) + alt_position2 = Vector2(position.x - max_distance_x,0) func _process(delta: float) -> void: if position.x != alt_position.x: position.x = move_toward(position.x, alt_position.x, move_speed) else: + position.x = move_toward(position.x, alt_position2.x, move_speed) moving = false %Player2D.is_on_moving_platform = false #%Player2D.platform_speed = 0.0 diff --git a/saw_moving.tscn b/saw_moving.tscn new file mode 100644 index 0000000..4628288 --- /dev/null +++ b/saw_moving.tscn @@ -0,0 +1,184 @@ +[gd_scene format=3 uid="uid://b0swgdy4faaac"] + +[ext_resource type="Script" uid="uid://by82tj263c628" path="res://saw_swinging.gd" id="1_6frwm"] +[ext_resource type="Texture2D" uid="uid://cpftgnwkpx1rp" path="res://art/saw.png" id="2_4wovf"] +[ext_resource type="Texture2D" uid="uid://dfdjachaibh2u" path="res://art/saw2.png" id="3_v0hit"] +[ext_resource type="Texture2D" uid="uid://cwvvgwo87pct0" path="res://art/saw3.png" id="4_h1a5w"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_ryup7"] +radius = 16.0 + +[sub_resource type="Animation" id="Animation_vwlp5"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:rotation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [0.0] +} + +[sub_resource type="Animation" id="Animation_3wt0e"] +resource_name = "fullswing_ccw" +length = 2.0 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:rotation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 2), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [0.0, -6.2831855] +} + +[sub_resource type="Animation" id="Animation_31jf1"] +resource_name = "fullswing_cw" +length = 2.0 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:rotation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 2), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [0.0, 6.2831855] +} + +[sub_resource type="Animation" id="Animation_x3ve6"] +resource_name = "halfswing_ccw" +length = 4.0 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:rotation") +tracks/0/interp = 5 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 1, 2, 3, 4), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1), +"update": 0, +"values": [0.0, -1.3089969389957472, 0.0, 1.3089969389957472, 0.0] +} + +[sub_resource type="Animation" id="Animation_xp7he"] +resource_name = "halfswing_ccw_2" +length = 4.0 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:rotation") +tracks/0/interp = 5 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 1, 2, 3, 4), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1), +"update": 0, +"values": [3.141592653589793, 1.8325957145940461, 3.141592653589793, 4.4505895925855405, 3.141592653589793] +} + +[sub_resource type="Animation" id="Animation_g2k3i"] +resource_name = "halfswing_cw" +length = 4.0 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:rotation") +tracks/0/interp = 5 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 1, 2, 3, 4), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1), +"update": 0, +"values": [0.0, 1.3089969389957472, 0.0, -1.3089969389957472, 0.0] +} + +[sub_resource type="Animation" id="Animation_axvpk"] +resource_name = "halfswing_cw_2" +length = 4.0 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:rotation") +tracks/0/interp = 5 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 1, 2, 3, 4), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1), +"update": 0, +"values": [3.141592653589793, 4.4505895925855405, 3.141592653589793, 1.8325957145940461, 3.141592653589793] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_3wt0e"] +_data = { +&"RESET": SubResource("Animation_vwlp5"), +&"fullswing_ccw": SubResource("Animation_3wt0e"), +&"fullswing_cw": SubResource("Animation_31jf1"), +&"halfswing_ccw": SubResource("Animation_x3ve6"), +&"halfswing_ccw_2": SubResource("Animation_xp7he"), +&"halfswing_cw": SubResource("Animation_g2k3i"), +&"halfswing_cw_2": SubResource("Animation_axvpk") +} + +[sub_resource type="SpriteFrames" id="SpriteFrames_lmieu"] +animations = [{ +"frames": [{ +"duration": 0.3, +"texture": ExtResource("2_4wovf") +}, { +"duration": 0.3, +"texture": ExtResource("3_v0hit") +}, { +"duration": 0.3, +"texture": ExtResource("4_h1a5w") +}], +"loop": 1, +"name": &"default", +"speed": 5.0 +}] + +[sub_resource type="CircleShape2D" id="CircleShape2D_vwlp5"] +radius = 18.0 + +[node name="SawMoving" type="AnimatableBody2D" unique_id=1098290500] +script = ExtResource("1_6frwm") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1907671557] +position = Vector2(1.5258789e-05, 0) +shape = SubResource("CircleShape2D_ryup7") + +[node name="AnimationPlayer" type="AnimationPlayer" parent="." unique_id=1221437574] +libraries/ = SubResource("AnimationLibrary_3wt0e") + +[node name="SawBlade" type="AnimatedSprite2D" parent="." unique_id=760707152] +texture_filter = 1 +position = Vector2(1.5258789e-05, 0) +sprite_frames = SubResource("SpriteFrames_lmieu") +autoplay = "default" +frame_progress = 0.40998712 + +[node name="Area2D" type="Area2D" parent="." unique_id=1356546922] +position = Vector2(19.000013, 7) +rotation = -6.834404e-05 + +[node name="ShapeCast2D" type="CollisionShape2D" parent="Area2D" unique_id=1586514592] +position = Vector2(-18.999523, -7.0012984) +shape = SubResource("CircleShape2D_vwlp5") + +[connection signal="body_entered" from="Area2D" to="." method="on_contact"] diff --git a/world.tscn b/world.tscn index 33a9289..863a401 100644 --- a/world.tscn +++ b/world.tscn @@ -2925,6 +2925,15 @@ position = Vector2(-4788, -1801.9218) position = Vector2(-4352, -1796.0132) fullswing_cw = true +[node name="SawSwinging9" parent="." unique_id=653414671 instance=ExtResource("40_ryup7")] +position = Vector2(-4303, -2054.9783) +fullswing_cw = true + +[node name="SawSwinging10" parent="." unique_id=2137330479 instance=ExtResource("40_ryup7")] +position = Vector2(-4303, -2054.9783) +spawn_delay = 0.5 +fullswing_ccw = true + [node name="SawSwinging6" parent="." unique_id=87552658 instance=ExtResource("40_ryup7")] position = Vector2(-4352, -1796.0132) scale = Vector2(-1, -1) @@ -2976,4 +2985,8 @@ position = Vector2(-4904, -2045.1318) [node name="Spike21" parent="." unique_id=755059167 instance=ExtResource("47_fnoqa")] position = Vector2(-4870, -2045.1318) +[node name="HatPickup5" parent="." unique_id=2139510891 instance=ExtResource("38_yx0jh")] +position = Vector2(-4303, -2014.6074) +hat_type = "meatboy3" + [connection signal="toggled" from="CanvasLayer/MusicButton" to="CanvasLayer/MusicButton" method="_on_toggled"]