Skip to content

Commit

Permalink
Add wall speed raycasts
Browse files Browse the repository at this point in the history
  • Loading branch information
aurora-dot committed Dec 1, 2023
1 parent f8a60d3 commit 3c4781d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
10 changes: 8 additions & 2 deletions Tutorial.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=9 format=3 uid="uid://bm3psird6cm5g"]
[gd_scene load_steps=10 format=3 uid="uid://bm3psird6cm5g"]

[ext_resource type="TileSet" uid="uid://dr7mh3cylga6a" path="res://dungeon_tileset.tres" id="1_vij1b"]
[ext_resource type="Script" path="res://main.gd" id="1_y5b4c"]
Expand All @@ -8,6 +8,7 @@
[ext_resource type="AudioStream" uid="uid://dtlea0f0imbgf" path="res://output.mp3" id="6_j5gxd"]
[ext_resource type="Script" path="res://bgtriggert.gd" id="7_4db1h"]
[ext_resource type="PackedScene" uid="uid://bienc1t72huxe" path="res://pause.tscn" id="8_xi8q5"]
[ext_resource type="Script" path="res://wallspeed.gd" id="9_4tfg7"]

[node name="Tutorial" type="Node2D"]
script = ExtResource("1_y5b4c")
Expand All @@ -34,7 +35,7 @@ format = 2
layer_0/tile_data = PackedInt32Array(-325996, 524288, 13, -391532, 524288, 12, -458748, 131072, 5, -458747, 131072, 5, -458746, 131072, 5, -458745, 131072, 5, -524283, 524288, 13, -589819, 524288, 13, -655355, 524288, 12, 1901398, 131072, 5, 1901399, 131072, 5, 1901400, 131072, 5, 1901401, 131072, 5, 1901397, 131072, 5, 1835863, 524288, 13, 1770327, 524288, 13, 1704791, 524288, 12, 656699, 131072, 5, 656700, 131072, 5, 591163, 524288, 13, 525627, 524288, 13, 460091, 524288, 12, -260460, 131072, 5, -260459, 131072, 5)

[node name="Player" parent="." instance=ExtResource("2_42jvw")]
position = Vector2(35343, -325)
position = Vector2(98, -4)

[node name="MovingWall" parent="." instance=ExtResource("4_d2odg")]
position = Vector2(2.08165e-12, 520)
Expand All @@ -59,4 +60,9 @@ script = ExtResource("7_4db1h")
[node name="Pause" parent="CanvasLayer" instance=ExtResource("8_xi8q5")]
visible = false

[node name="RayCast2D2" type="RayCast2D" parent="."]
position = Vector2(1192, 0)
target_position = Vector2(17, -1192)
script = ExtResource("9_4tfg7")

[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
3 changes: 2 additions & 1 deletion main.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extends Node2D

var wall_should_move = false
var wall_speed = 175

# Called when the node enters the scene tree for the first time.
func _ready():
Expand All @@ -21,7 +22,7 @@ func _process(delta):
func _physics_process(delta):
if wall_should_move and not $Player.dead:
print("moving")
$MovingWall.position.x += delta * 175
$MovingWall.position.x += delta * wall_speed

if $Player.dead:
wall_should_move = false
Expand Down
16 changes: 16 additions & 0 deletions wallspeed.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
extends RayCast2D

@export var wall_speed = 0

# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

func _physics_process(delta):
if self.is_colliding() and self.get_collider().name == "Player":
get_parent().wall_speed = wall_speed

0 comments on commit 3c4781d

Please sign in to comment.