Skip to content

Commit

Permalink
Dano de obstáculo no jogador
Browse files Browse the repository at this point in the history
  • Loading branch information
mihailov-vf committed Jun 18, 2024
1 parent 83d296a commit 68c56fd
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
Binary file added projeto/elementos/som/bolha_2.wav
Binary file not shown.
12 changes: 12 additions & 0 deletions projeto/recursos/jogos/enchente/jogador/Sons.gd
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
extends AudioStreamPlayer

onready var sons = {
"agua": preload ("res://elementos/som/movimento_agua.wav"),
"dano": preload ("res://elementos/som/bolha_2.wav")
}

func _on_ControleFaixa3D_iniciou_movimento(_direcao, _alvo) -> void:
stop()
stream = sons.agua
play()


func _on_ControleFaixa3D_terminou_movimento() -> void:
yield(get_tree().create_timer(1.0), "timeout")
stop()

func _on_Vida_vida_alterada(alteracao: Vida.VidaAlterada) -> void:
if !alteracao.cura:
stop()
stream = sons.dano
play()
9 changes: 9 additions & 0 deletions projeto/recursos/jogos/enchente/jogador/playerLane3D.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,12 @@ func _on_ControladorArrasta_arrastado(chave):
print('a')
elif chave=='esquerda-0' or chave=='esquerda-1':
controle_faixa_3d.mover_esquerda()


func _on_AreaDano_body_entered(body: Node) -> void:
if body.is_in_group("obstaculo"):
vida.receber_dano(1.0)


func _on_Vida_vida_acabou() -> void:
TrocadorDeCenas.trocar_cena('res://recursos/feed_de_noticias/feed_de_noticia.tscn')
8 changes: 8 additions & 0 deletions projeto/recursos/jogos/enchente/jogador/playerLane3D.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ move_lock_z = true
script = ExtResource( 3 )

[node name="CollisionShape" type="CollisionShape" parent="."]
transform = Transform( 0.9, 0, 0, 0, 0.9, 0, 0, 0, 0.9, 0, 0, 0 )
shape = SubResource( 1 )

[node name="Sprite3D" type="Sprite3D" parent="."]
Expand All @@ -45,7 +46,14 @@ autoplay = true
stream = ExtResource( 7 )
script = ExtResource( 8 )

[node name="AreaDano" type="Area" parent="."]

[node name="CollisionShape" type="CollisionShape" parent="AreaDano"]
shape = SubResource( 1 )

[connection signal="iniciou_movimento" from="ControleFaixa3D" to="Sons" method="_on_ControleFaixa3D_iniciou_movimento"]
[connection signal="terminou_movimento" from="ControleFaixa3D" to="Sons" method="_on_ControleFaixa3D_terminou_movimento"]
[connection signal="arrastado" from="ControladorArrasta" to="." method="_on_ControladorArrasta_arrastado"]
[connection signal="vida_acabou" from="Vida" to="." method="_on_Vida_vida_acabou"]
[connection signal="vida_alterada" from="Vida" to="Sons" method="_on_Vida_vida_alterada"]
[connection signal="body_entered" from="AreaDano" to="." method="_on_AreaDano_body_entered"]

0 comments on commit 68c56fd

Please sign in to comment.