Skip to content

Commit

Permalink
feat: respawn player after falling in a pit
Browse files Browse the repository at this point in the history
  • Loading branch information
russmatney committed Dec 7, 2024
1 parent 1529d03 commit 7df23a4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 9 deletions.
Empty file.
2 changes: 1 addition & 1 deletion src/dino/players/PlayerCamera.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ frequency = 0.5
randomize_noise_seed = 1
noise_seed = 0
positional_noise = true
rotational_noise = true
rotational_noise = false
positional_multiplier_x = 1.0
positional_multiplier_y = 1.0
rotational_multiplier = 1.0
Expand Down
7 changes: 3 additions & 4 deletions src/dino/players/TDPlayer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,12 @@ func clear_forced_movement_target():

## pits ###################################################################

signal fell_in_pit
func on_pit_entered():
# TODO damage?
fell_in_pit.emit()
# TODO damage? death?
machine.transit("Fall")

# await get_tree().create_timer(1.0).timeout
# Dino.respawn_player({player=self})

## collision ###########################################################

# Should be called immediately after move_and_slide in physics_process
Expand Down
11 changes: 9 additions & 2 deletions src/dino/players/topdown_machine/Fall.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@ var fall_time = 0.6
var fall_ttl
var fall_scale_factor = 0.2

var og_scale
var og_modulate

## enter ###########################################################

func enter(opts = {}):
actor.anim.play("fall")
if actor.anim.sprite_frames.has_animation("fall"):
actor.anim.play("fall")
Sounds.play(Sounds.S.fall)
fall_ttl = U.get_(opts, "fall_time", fall_time)
actor.velocity = Vector2.ZERO

og_scale = actor.scale
og_modulate = actor.modulate.a
var tween = create_tween()
tween.tween_property(actor, "scale", Vector2.ONE*fall_scale_factor, fall_ttl)
tween.tween_property(actor, "modulate:a", 0.0, fall_ttl)
Expand All @@ -29,7 +35,8 @@ func enter(opts = {}):
## exit ###########################################################

func exit():
pass
actor.scale = og_scale
actor.modulate.a = og_modulate


## input ###########################################################
Expand Down
9 changes: 8 additions & 1 deletion src/games/shirt/ShirtGame.gd
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ func _ready():
Dino.player_ready.connect(func(p):
Log.pr("player ready", p)
if p:
set_player(p), CONNECT_DEFERRED)
set_player(p)

# quick respawn after falling, useful for debugging/testing
U._connect(p.fell_in_pit, func():
Log.pr("fell in pit, respawning in 1s")
await get_tree().create_timer(1.0).timeout
Dino.respawn_active_player())
, CONNECT_DEFERRED)

Dino.create_new_player({entity=player_entity, genre=DinoData.Genre.TopDown})

Expand Down
7 changes: 6 additions & 1 deletion src/games/shirt/rooms/CaveEntrance.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[gd_scene load_steps=7 format=4 uid="uid://bedv8kv4u2p14"]
[gd_scene load_steps=8 format=4 uid="uid://bedv8kv4u2p14"]

[ext_resource type="PackedScene" uid="uid://bsg0351mx3b4u" path="res://addons/MetroidvaniaSystem/Nodes/RoomInstance.tscn" id="1_tponc"]
[ext_resource type="Script" path="res://src/dino/PlayerSpawner.gd" id="3_c4ibp"]
[ext_resource type="PackedScene" uid="uid://bs0c5xn0vglfn" path="res://src/dino/entities/PlayerSpawnPoint.tscn" id="4_8mr57"]
[ext_resource type="PackedScene" uid="uid://bid88q8ils016" path="res://src/dino/entities/checkpoints/Candle.tscn" id="6_frx7o"]
[ext_resource type="PackedScene" uid="uid://cosk30larse70" path="res://src/tilemaps/cave_topdown/TDCaveFloorTiles16.tscn" id="6_x3g40"]
[ext_resource type="PackedScene" uid="uid://ddklv6bc7o134" path="res://src/dino/entities/lights/SmallLight.tscn" id="7_pr6hy"]
[ext_resource type="PackedScene" uid="uid://drpxr83sltsot" path="res://src/tilemaps/cave_topdown/TDCaveWallTiles16.tscn" id="8_j4mmv"]

[node name="Map" type="Node2D"]
Expand Down Expand Up @@ -47,3 +48,7 @@ position = Vector2(104, 144)

[node name="Candle7" parent="." groups=["metro_checkpoints"] instance=ExtResource("6_frx7o")]
position = Vector2(248, 128)

[node name="SmallLight" parent="." instance=ExtResource("7_pr6hy")]
position = Vector2(240, 376)
freeze = true

0 comments on commit 7df23a4

Please sign in to comment.