Improved moving platform
This commit is contained in:
1 parent
7bcdfb1f7a
commit
2342c5b372
13 files changed
+55
-21
No files matched your search
@@ -9,7 +9,6 @@ func _process(delta: float) -> void:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
func on_contact(body: Node2D) -> void:
|
func on_contact(body: Node2D) -> void:
|
||||||
print(body)
|
|
||||||
$AudioStreamPlayer2D.play()
|
$AudioStreamPlayer2D.play()
|
||||||
visible = false
|
visible = false
|
||||||
%Player2D.coins += 1
|
%Player2D.coins += 1
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ func _process(delta: float) -> void:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
func on_contact(body: Node2D) -> void:
|
func on_contact(body: Node2D) -> void:
|
||||||
print(body)
|
|
||||||
$AudioStreamPlayer2D.play()
|
$AudioStreamPlayer2D.play()
|
||||||
visible = false
|
visible = false
|
||||||
%Player2D.coins += 1
|
%Player2D.coins += 1
|
||||||
|
|||||||
@@ -11,4 +11,3 @@ func on_contact(body: Node2D) -> void:
|
|||||||
print("SLASH KILL")
|
print("SLASH KILL")
|
||||||
%Player2D/Jetpack/DeathSound.play()
|
%Player2D/Jetpack/DeathSound.play()
|
||||||
%Player2D.on_death(false,%Player2D.position)
|
%Player2D.on_death(false,%Player2D.position)
|
||||||
print(body)
|
|
||||||
@@ -12,7 +12,6 @@ func _ready() -> void:
|
|||||||
add_to_group("Hidden")
|
add_to_group("Hidden")
|
||||||
|
|
||||||
func check_for_pair() -> String:
|
func check_for_pair() -> String:
|
||||||
print(paired_teleporter)
|
|
||||||
return paired_teleporter
|
return paired_teleporter
|
||||||
|
|
||||||
func disable():
|
func disable():
|
||||||
|
|||||||
@@ -1,11 +1,21 @@
|
|||||||
extends RigidBody2D
|
extends RigidBody2D
|
||||||
|
|
||||||
var max_distance = position + Vector2(1,0)
|
var max_distance = position + Vector2(1,0)
|
||||||
|
var move_speed = 0.01
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
print("START POSITION: " + str(position))
|
add_to_group("MovingPlatform")
|
||||||
pass
|
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
print("NEW POSITION :" + str(position))
|
print(max_distance)
|
||||||
position.x = move_toward(position.x, max_distance.x, 1)
|
position.x = move_toward(position.x, max_distance.x, move_speed)
|
||||||
|
|
||||||
|
func on_enter(body) -> void:
|
||||||
|
print("ON MOVING PLATFORM")
|
||||||
|
if %Player2D.is_on_floor():
|
||||||
|
%Player2D.is_on_moving_platform = true
|
||||||
|
%Player2D.platform_speed = move_speed
|
||||||
|
|
||||||
|
func on_leave(body) -> void:
|
||||||
|
print("OFF MOVING PLATFORM")
|
||||||
|
%Player2D.is_on_moving_platform = false
|
||||||
@@ -4,7 +4,10 @@
|
|||||||
[ext_resource type="Texture2D" uid="uid://blbaaqyrt8dtk" path="res://art/block/block.png" id="1_m1vtb"]
|
[ext_resource type="Texture2D" uid="uid://blbaaqyrt8dtk" path="res://art/block/block.png" id="1_m1vtb"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_f3sb7"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_f3sb7"]
|
||||||
size = Vector2(16, 14)
|
size = Vector2(32, 16)
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_3uo2v"]
|
||||||
|
size = Vector2(38, 23)
|
||||||
|
|
||||||
[node name="Block" type="RigidBody2D" unique_id=1409784601]
|
[node name="Block" type="RigidBody2D" unique_id=1409784601]
|
||||||
gravity_scale = 0.0
|
gravity_scale = 0.0
|
||||||
@@ -12,8 +15,26 @@ freeze = true
|
|||||||
script = ExtResource("1_3uo2v")
|
script = ExtResource("1_3uo2v")
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1866755047]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1866755047]
|
||||||
|
position = Vector2(0, -2)
|
||||||
shape = SubResource("RectangleShape2D_f3sb7")
|
shape = SubResource("RectangleShape2D_f3sb7")
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1680278216]
|
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1680278216]
|
||||||
texture_filter = 1
|
texture_filter = 1
|
||||||
|
position = Vector2(-8, -2)
|
||||||
texture = ExtResource("1_m1vtb")
|
texture = ExtResource("1_m1vtb")
|
||||||
|
|
||||||
|
[node name="Sprite2D2" type="Sprite2D" parent="." unique_id=549053101]
|
||||||
|
texture_filter = 1
|
||||||
|
position = Vector2(8, -2)
|
||||||
|
texture = ExtResource("1_m1vtb")
|
||||||
|
|
||||||
|
[node name="Area2D" type="Area2D" parent="." unique_id=1910272404]
|
||||||
|
|
||||||
|
[node name="ShapeCast2D" type="CollisionShape2D" parent="Area2D" unique_id=934904308]
|
||||||
|
position = Vector2(0, -3.5)
|
||||||
|
shape = SubResource("RectangleShape2D_3uo2v")
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="." to="." method="on_enter"]
|
||||||
|
[connection signal="body_exited" from="." to="." method="on_leave"]
|
||||||
|
[connection signal="body_entered" from="Area2D" to="." method="on_enter"]
|
||||||
|
[connection signal="body_exited" from="Area2D" to="." method="on_leave"]
|
||||||
@@ -11,4 +11,3 @@ func on_contact(body: Node2D) -> void:
|
|||||||
print("SLASH KILL")
|
print("SLASH KILL")
|
||||||
%Player2D/Jetpack/DeathSound.play()
|
%Player2D/Jetpack/DeathSound.play()
|
||||||
%Player2D.on_death(false,%Player2D.position)
|
%Player2D.on_death(false,%Player2D.position)
|
||||||
print(body)
|
|
||||||
@@ -12,7 +12,6 @@ func _process(delta: float) -> void:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
func on_contact(body: Node2D) -> void:
|
func on_contact(body: Node2D) -> void:
|
||||||
print(body)
|
|
||||||
$AudioStreamPlayer2D.play(0)
|
$AudioStreamPlayer2D.play(0)
|
||||||
visible = false
|
visible = false
|
||||||
picked_up.emit()
|
picked_up.emit()
|
||||||
|
|||||||
+5
-4
@@ -11,6 +11,9 @@ const JUMP_VELOCITY = -410.0
|
|||||||
const DASH_LENGTH = 0.2
|
const DASH_LENGTH = 0.2
|
||||||
const BACKGROUND_COLOR = Color(Color.ORANGE.r + 0.80,Color.ORANGE.g + 0.20,Color.ORANGE.b - 0.10)
|
const BACKGROUND_COLOR = Color(Color.ORANGE.r + 0.80,Color.ORANGE.g + 0.20,Color.ORANGE.b - 0.10)
|
||||||
|
|
||||||
|
var is_on_moving_platform = false
|
||||||
|
var platform_speed = 0
|
||||||
|
|
||||||
var death_cooldown = 0.0
|
var death_cooldown = 0.0
|
||||||
var fall_timer = 0.0
|
var fall_timer = 0.0
|
||||||
var teleport_cooldown = 0
|
var teleport_cooldown = 0
|
||||||
@@ -93,8 +96,6 @@ func spawn_ghost(ghost_position):
|
|||||||
var ghost = preload("res://ghost.tscn")
|
var ghost = preload("res://ghost.tscn")
|
||||||
ghost = ghost.instantiate()
|
ghost = ghost.instantiate()
|
||||||
get_parent().add_child(ghost)
|
get_parent().add_child(ghost)
|
||||||
print(ghost)
|
|
||||||
print(ghost.position)
|
|
||||||
ghost.position = ghost_position
|
ghost.position = ghost_position
|
||||||
|
|
||||||
func on_death(instant = false, player_position = position):
|
func on_death(instant = false, player_position = position):
|
||||||
@@ -122,16 +123,16 @@ func on_death(instant = false, player_position = position):
|
|||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
if Input.is_key_pressed(Key.KEY_W) or Input.is_key_pressed(Key.KEY_A) or Input.is_key_pressed(Key.KEY_S) or Input.is_key_pressed(Key.KEY_D):
|
if Input.is_key_pressed(Key.KEY_W) or Input.is_key_pressed(Key.KEY_A) or Input.is_key_pressed(Key.KEY_S) or Input.is_key_pressed(Key.KEY_D):
|
||||||
print("KEYBOARD")
|
|
||||||
controller_ui = false
|
controller_ui = false
|
||||||
elif Input.get_action_strength("move_horizontal") > 0:
|
elif Input.get_action_strength("move_horizontal") > 0:
|
||||||
print("CONTROLLER")
|
|
||||||
controller_ui = true
|
controller_ui = true
|
||||||
|
|
||||||
if Input.is_action_just_released("restart") or (Input.is_action_pressed("controller_restart_left") and Input.is_action_pressed("controller_restart_right")):
|
if Input.is_action_just_released("restart") or (Input.is_action_pressed("controller_restart_left") and Input.is_action_pressed("controller_restart_right")):
|
||||||
get_tree().reload_current_scene()
|
get_tree().reload_current_scene()
|
||||||
|
|
||||||
if is_on_floor():
|
if is_on_floor():
|
||||||
|
if is_on_moving_platform:
|
||||||
|
%Player2D.position.x += platform_speed
|
||||||
last_ground_point = global_position
|
last_ground_point = global_position
|
||||||
#spawn_point = last_ground_point
|
#spawn_point = last_ground_point
|
||||||
|
|
||||||
|
|||||||
@@ -11,4 +11,3 @@ func on_contact(body: Node2D) -> void:
|
|||||||
print("SLASH KILL")
|
print("SLASH KILL")
|
||||||
%Player2D/Jetpack/DeathSound.play()
|
%Player2D/Jetpack/DeathSound.play()
|
||||||
%Player2D.on_death(false,%Player2D.position)
|
%Player2D.on_death(false,%Player2D.position)
|
||||||
print(body)
|
|
||||||
@@ -11,7 +11,6 @@ func _ready() -> void:
|
|||||||
add_to_group("TELEPORTERS")
|
add_to_group("TELEPORTERS")
|
||||||
|
|
||||||
func check_for_pair() -> String:
|
func check_for_pair() -> String:
|
||||||
#print(paired_teleporter)
|
|
||||||
return paired_teleporter
|
return paired_teleporter
|
||||||
|
|
||||||
func disable():
|
func disable():
|
||||||
|
|||||||
@@ -10,7 +10,5 @@ func _ready() -> void:
|
|||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
#print(DisplayServer.window_get_size().x)
|
|
||||||
#print(DisplayServer.window_get_size().y)
|
|
||||||
mesh.size.x = DisplayServer.window_get_size().x * 4
|
mesh.size.x = DisplayServer.window_get_size().x * 4
|
||||||
mesh.size.y = DisplayServer.window_get_size().y * 4
|
mesh.size.y = DisplayServer.window_get_size().y * 4
|
||||||
+14
-2
@@ -41,7 +41,7 @@ scale = Vector2(1, 1.0155824)
|
|||||||
|
|
||||||
[node name="Player2D" parent="." unique_id=889851478 instance=ExtResource("1_aqk2v")]
|
[node name="Player2D" parent="." unique_id=889851478 instance=ExtResource("1_aqk2v")]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
position = Vector2(-4838, 217.6091)
|
position = Vector2(-4833.9995, 356.4457)
|
||||||
rotation = 0.0005533503
|
rotation = 0.0005533503
|
||||||
safe_margin = 0.08
|
safe_margin = 0.08
|
||||||
|
|
||||||
@@ -51,7 +51,13 @@ position = Vector2(-4673, 390.9087)
|
|||||||
[node name="LongerBlock" parent="StartingArea" unique_id=1619185575 instance=ExtResource("6_dwbse")]
|
[node name="LongerBlock" parent="StartingArea" unique_id=1619185575 instance=ExtResource("6_dwbse")]
|
||||||
position = Vector2(-17, -17.72377)
|
position = Vector2(-17, -17.72377)
|
||||||
|
|
||||||
[node name="LongerBlock2" parent="StartingArea" unique_id=426800863 instance=ExtResource("6_dwbse")]
|
[node name="LongerBlock3" parent="StartingArea" unique_id=426800863 instance=ExtResource("6_dwbse")]
|
||||||
|
position = Vector2(-353, -17.72383)
|
||||||
|
|
||||||
|
[node name="LongerBlock4" parent="StartingArea" unique_id=470273291 instance=ExtResource("6_dwbse")]
|
||||||
|
position = Vector2(-354, -128.99002)
|
||||||
|
|
||||||
|
[node name="LongerBlock2" parent="StartingArea" unique_id=806639319 instance=ExtResource("6_dwbse")]
|
||||||
position = Vector2(650, -17.72377)
|
position = Vector2(650, -17.72377)
|
||||||
|
|
||||||
[node name="LongerBlock5" parent="StartingArea" unique_id=1844119708 instance=ExtResource("6_dwbse")]
|
[node name="LongerBlock5" parent="StartingArea" unique_id=1844119708 instance=ExtResource("6_dwbse")]
|
||||||
@@ -940,4 +946,10 @@ sign_text = "TAKE A LEAP"
|
|||||||
[node name="Block20" parent="." unique_id=1489084043 instance=ExtResource("34_w44yn")]
|
[node name="Block20" parent="." unique_id=1489084043 instance=ExtResource("34_w44yn")]
|
||||||
position = Vector2(-4824, 299.3356)
|
position = Vector2(-4824, 299.3356)
|
||||||
|
|
||||||
|
[node name="VerticalLongBlock9" parent="." unique_id=1737292270 instance=ExtResource("4_pkg7o")]
|
||||||
|
position = Vector2(-4866, 311.15155)
|
||||||
|
|
||||||
|
[node name="VerticalLongBlock10" parent="." unique_id=952105658 instance=ExtResource("4_pkg7o")]
|
||||||
|
position = Vector2(-5189, 322.96738)
|
||||||
|
|
||||||
[connection signal="toggled" from="CanvasLayer/MusicButton" to="CanvasLayer/MusicButton" method="_on_toggled"]
|
[connection signal="toggled" from="CanvasLayer/MusicButton" to="CanvasLayer/MusicButton" method="_on_toggled"]
|
||||||
Reference in new issue
Block a user