Code cleanup and minor fixes to Level 3

This commit is contained in:
VoidTwo
2021-12-09 04:08:28 -06:00
parent 9dce1e02cf
commit 2147d38874
27 changed files with 418 additions and 437 deletions

View File

@@ -0,0 +1,10 @@
extends Area2D
signal coin_grabbed
func _on_Node2D_body_entered(body: Node) -> void:
if body.get_name() == 'Player':
emit_signal("coin_grabbed")
print("coin!")
queue_free()

View File

@@ -0,0 +1,19 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Levels/Interactables/Coin.gd" type="Script" id=1]
[ext_resource path="res://Sprites/Assets/coin.png" type="Texture" id=2]
[sub_resource type="CircleShape2D" id=1]
radius = 6.38067
[node name="coin" type="Area2D"]
script = ExtResource( 1 )
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 0, 1 )
texture = ExtResource( 2 )
[node name="coin" type="CollisionShape2D" parent="."]
shape = SubResource( 1 )
[connection signal="body_entered" from="." to="." method="_on_Node2D_body_entered"]

View File

@@ -8,7 +8,7 @@ extends Node2D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
@@ -17,8 +17,8 @@ func _ready() -> void:
func _on_AnimationPlayer_animation_finished(anim_name: String) -> void:
$GemSprite.visible = false
$GemSprite.visible = false
func _on_AnimationPlayer_animation_started(anim_name: String) -> void:
$GemSprite.visible = true
$GemSprite.visible = true

View File

@@ -1,6 +1,6 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Sprites/Assets/resources_basic.png" type="Texture" id=1]
[ext_resource path="res://Sprites/Assets/Resources_Basic.png" type="Texture" id=1]
[ext_resource path="res://Levels/Interactables/Gem.gd" type="Script" id=2]
[sub_resource type="Animation" id=3]

View File

@@ -13,7 +13,7 @@ signal gem_collected
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
@@ -22,12 +22,12 @@ func _ready() -> void:
func _on_Player_Detector_area_entered(area: Area2D) -> void:
if area.get_parent().name == 'Player':
if is_opened == false:
$chestClosed.visible = false
$chestOpened.visible = true
$Gem.visible = true
$Gem/AnimationPlayer.play('rise')
is_opened = true
has_gem = false
emit_signal('gem_collected')
if area.get_parent().name == 'Player':
if is_opened == false:
$chestClosed.visible = false
$chestOpened.visible = true
$Gem.visible = true
$Gem/AnimationPlayer.play('rise')
is_opened = true
has_gem = false
emit_signal('gem_collected')