Fixed platform drop, added heal item
This commit is contained in:
parent
0c6003a4b3
commit
f19bda7886
7 changed files with 55 additions and 3 deletions
6
heal_item.gd
Normal file
6
heal_item.gd
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
extends Item
|
||||
@export var heal_amount = 1
|
||||
|
||||
func collect():
|
||||
if(player.current_hp < player.max_hp):
|
||||
player.current_hp += heal_amount
|
||||
1
heal_item.gd.uid
Normal file
1
heal_item.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b43fudwi47qfd
|
||||
17
heal_item.tscn
Normal file
17
heal_item.tscn
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://b00185vygcka1"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b43fudwi47qfd" path="res://heal_item.gd" id="1_3vbv8"]
|
||||
[ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="2_48lih"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_hvhjo"]
|
||||
|
||||
[node name="HealItem" type="Area2D"]
|
||||
script = ExtResource("1_3vbv8")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
scale = Vector2(7, 7)
|
||||
shape = SubResource("CircleShape2D_hvhjo")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
modulate = Color(1, 1, 0, 1)
|
||||
texture = ExtResource("2_48lih")
|
||||
20
item.gd
Normal file
20
item.gd
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
class_name Item extends Area2D
|
||||
@onready var player = get_tree().get_root().get_node("main/Player")
|
||||
|
||||
func _ready() -> void:
|
||||
self.connect("body_entered", _on_body_entered)
|
||||
|
||||
func _on_body_entered(body: Node2D):
|
||||
if(body.name == "Player"):
|
||||
set_deferred("monitoring", false)
|
||||
set_deferred("monitorable", false)
|
||||
call_deferred("reparent", player)
|
||||
collect_animation()
|
||||
if(self.has_method("collect")):
|
||||
collect()
|
||||
|
||||
func collect_animation():
|
||||
self.visible = false
|
||||
|
||||
func collect():
|
||||
push_error("Please specify item collection behavior")
|
||||
1
item.gd.uid
Normal file
1
item.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c0uftljafcroy
|
||||
10
main.tscn
10
main.tscn
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://cxo6bq26huau7"]
|
||||
[gd_scene load_steps=10 format=3 uid="uid://cxo6bq26huau7"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cmaovvr15b3qk" path="res://player/player.tscn" id="2_1bvp3"]
|
||||
[ext_resource type="Script" uid="uid://vgxh2xdevat7" path="res://world/earth.gd" id="2_lquwl"]
|
||||
|
|
@ -7,6 +7,8 @@
|
|||
[ext_resource type="PackedScene" uid="uid://cjsrtswk4vgf2" path="res://healthbar/healthbar.tscn" id="6_7mycd"]
|
||||
[ext_resource type="PackedScene" uid="uid://dpdn2php3ydsv" path="res://death_screen/death_screen.tscn" id="7_5vw27"]
|
||||
[ext_resource type="PackedScene" uid="uid://4l3elvxpghw8" path="res://platform.tscn" id="7_272bh"]
|
||||
[ext_resource type="PackedScene" uid="uid://b00185vygcka1" path="res://heal_item.tscn" id="8_5vw27"]
|
||||
[ext_resource type="PackedScene" uid="uid://chu67ci7sl488" path="res://enemies/ghost.tscn" id="9_kek77"]
|
||||
|
||||
[node name="main" type="Node2D"]
|
||||
|
||||
|
|
@ -47,6 +49,12 @@ visible = false
|
|||
position = Vector2(900, -3000)
|
||||
scale = Vector2(5, 3.1)
|
||||
|
||||
[node name="HealItem" parent="." instance=ExtResource("8_5vw27")]
|
||||
position = Vector2(0, -3150)
|
||||
|
||||
[node name="Ghost" parent="." instance=ExtResource("9_kek77")]
|
||||
position = Vector2(0, -3000)
|
||||
|
||||
[connection signal="health_changed" from="Player" to="CanvasLayer/Healthbar" method="_on_player_health_changed"]
|
||||
[connection signal="player_died" from="Player" to="CanvasLayer/DeathScreen" method="_on_player_player_died"]
|
||||
[connection signal="timeout" from="Building Generator/Timer" to="Building Generator" method="_on_timer_timeout"]
|
||||
|
|
|
|||
|
|
@ -99,10 +99,9 @@ func manage_velocity(delta: float) -> void:
|
|||
var dropped = false
|
||||
if(not is_on_floor()):
|
||||
air_jumps_current -= 1;
|
||||
print("Not Grounded")
|
||||
elif (Input.is_action_pressed("drop")):
|
||||
dropped = true
|
||||
self.position.y += 3
|
||||
self.position += earth_aligner.global_from_local(Vector2(0,3))
|
||||
if(not dropped):
|
||||
local_velocity.y = -jump_strength
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue