Better respawn and knockback
This commit is contained in:
parent
869ef68d12
commit
c293efbc13
|
@ -6,5 +6,5 @@ func _process(delta):
|
||||||
if get_overlapping_bodies().size() != 0:
|
if get_overlapping_bodies().size() != 0:
|
||||||
print("1")
|
print("1")
|
||||||
if Input.is_action_pressed("open"):
|
if Input.is_action_pressed("open"):
|
||||||
print("2")
|
Player.current_scene = "res://levels/World.tscn"
|
||||||
get_tree().change_scene("res://levels/World.tscn")
|
get_tree().change_scene("res://levels/testtscn")
|
||||||
|
|
|
@ -19,7 +19,7 @@ tracks/0/keys = {
|
||||||
"values": [ 0, 1 ]
|
"values": [ 0, 1 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=3]
|
[sub_resource type="RectangleShape2D" id=2]
|
||||||
extents = Vector2( 14, 13 )
|
extents = Vector2( 14, 13 )
|
||||||
|
|
||||||
[node name="Door" type="Sprite"]
|
[node name="Door" type="Sprite"]
|
||||||
|
@ -35,5 +35,5 @@ script = ExtResource( 2 )
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||||
position = Vector2( 16, 19 )
|
position = Vector2( 16, 19 )
|
||||||
shape = SubResource( 3 )
|
shape = SubResource( 2 )
|
||||||
[connection signal="body_entered" from="Area2D" to="Area2D" method="_on_Area2D_body_entered"]
|
[connection signal="body_entered" from="Area2D" to="Area2D" method="_on_Area2D_body_entered"]
|
||||||
|
|
|
@ -17,7 +17,8 @@ func _ready():
|
||||||
|
|
||||||
|
|
||||||
func _on_TextureButton_pressed():
|
func _on_TextureButton_pressed():
|
||||||
get_tree().change_scene("res://levels/World.tscn")
|
Player.respawn()
|
||||||
|
get_tree().change_scene(Player.current_scene)
|
||||||
|
|
||||||
|
|
||||||
func _on_TextureButton2_pressed():
|
func _on_TextureButton2_pressed():
|
||||||
|
|
|
@ -21,5 +21,5 @@ func apply_gravity(delta, modifier = 1):
|
||||||
velocity.y += gravity * delta * modifier
|
velocity.y += gravity * delta * modifier
|
||||||
|
|
||||||
func do_knockback(normal):
|
func do_knockback(normal):
|
||||||
knockback = normal
|
knockback = Vector2(4, 4)
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,12 @@ func _physics_process(_delta):
|
||||||
if health <= 0:
|
if health <= 0:
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
|
func do_knockback(normal):
|
||||||
|
if $Hell.flip_h == true:
|
||||||
|
knockback = Vector2(-4, -4)
|
||||||
|
else:
|
||||||
|
knockback = Vector2(4, 0)
|
||||||
|
|
||||||
func shoot_fireball(direction):
|
func shoot_fireball(direction):
|
||||||
if ShootDelay.is_stopped():
|
if ShootDelay.is_stopped():
|
||||||
var temp = Hell_Projectile.instance()
|
var temp = Hell_Projectile.instance()
|
||||||
|
|
|
@ -9,13 +9,14 @@ func apply_gravity(delta, modifier = 1):
|
||||||
velocity.y += gravity * delta * modifier
|
velocity.y += gravity * delta * modifier
|
||||||
|
|
||||||
func _physics_process(_delta):
|
func _physics_process(_delta):
|
||||||
|
var dist = global_position.distance_to(Player.position)
|
||||||
|
|
||||||
if knockback != Vector2.ZERO:
|
if knockback != Vector2.ZERO:
|
||||||
knockback = lerp(knockback, Vector2.ZERO, 0.5)
|
knockback = lerp(knockback, Vector2.ZERO, 0.5)
|
||||||
move_and_slide(-knockback * knockback_amount)
|
move_and_slide(-knockback * knockback_amount)
|
||||||
if knockback.x < 1 and -1 < knockback.x and knockback.y < 1 and -1 < knockback.y:
|
if knockback.x < 1 and -1 < knockback.x and knockback.y < 1 and -1 < knockback.y:
|
||||||
knockback = Vector2.ZERO
|
knockback = Vector2.ZERO
|
||||||
return
|
return
|
||||||
var dist = global_position.distance_to(Player.position)
|
|
||||||
if $RayCast2D.get_collider() != null && $RayCast2D.get_collider().has_method("get_type") and $RayCast2D.get_collider().get_type() == "player":
|
if $RayCast2D.get_collider() != null && $RayCast2D.get_collider().has_method("get_type") and $RayCast2D.get_collider().get_type() == "player":
|
||||||
velocity = Vector2(0, 0)
|
velocity = Vector2(0, 0)
|
||||||
throw_bone(Vector2.LEFT)
|
throw_bone(Vector2.LEFT)
|
||||||
|
@ -30,13 +31,14 @@ func _physics_process(_delta):
|
||||||
if dist <= 400:
|
if dist <= 400:
|
||||||
velocity.x = position.direction_to(Globals.player).normalized().x
|
velocity.x = position.direction_to(Globals.player).normalized().x
|
||||||
else:
|
else:
|
||||||
velocity = Vector2(0, 0)
|
velocity = Vector2(0, 0)
|
||||||
|
|
||||||
if velocity.x > 0:
|
if velocity.x > 0:
|
||||||
$Skeleton.flip_h = false
|
$Skeleton.flip_h = false
|
||||||
elif velocity.x < 0:
|
elif velocity.x < 0:
|
||||||
$Skeleton.flip_h = true
|
$Skeleton.flip_h = true
|
||||||
|
|
||||||
|
|
||||||
# Kill
|
# Kill
|
||||||
if health <= 0:
|
if health <= 0:
|
||||||
queue_free()
|
queue_free()
|
||||||
|
@ -53,3 +55,9 @@ func throw_bone(direction):
|
||||||
temp.launch_vector(direction)
|
temp.launch_vector(direction)
|
||||||
ShootDelay.start()
|
ShootDelay.start()
|
||||||
|
|
||||||
|
func do_knockback(normal):
|
||||||
|
if $Skeleton.flip_h == true:
|
||||||
|
knockback = Vector2(-4, -4)
|
||||||
|
else:
|
||||||
|
knockback = Vector2(4, 0)
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,10 @@ onready var Hurtbox = $Area2D
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
speed = 50
|
speed = 50
|
||||||
|
health = 3.5
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
|
Player.current_scene = "res://levels/World.tscn"
|
||||||
if knockback != Vector2.ZERO:
|
if knockback != Vector2.ZERO:
|
||||||
knockback = lerp(knockback, Vector2.ZERO, 0.5)
|
knockback = lerp(knockback, Vector2.ZERO, 0.5)
|
||||||
move_and_slide(-knockback * knockback_amount)
|
move_and_slide(-knockback * knockback_amount)
|
||||||
|
@ -38,3 +40,9 @@ func deal_damage():
|
||||||
if body.has_method("get_type") && body.get_type() == "player":
|
if body.has_method("get_type") && body.get_type() == "player":
|
||||||
body.health -= contact_damage
|
body.health -= contact_damage
|
||||||
DamageCD.start()
|
DamageCD.start()
|
||||||
|
|
||||||
|
func do_knockback(normal):
|
||||||
|
if Spr.flip_h == true:
|
||||||
|
knockback = Vector2(-4, -4)
|
||||||
|
else:
|
||||||
|
knockback = Vector2(4, 0)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=23 format=2]
|
[gd_scene load_steps=24 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://meta/DungeonTilemap.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://meta/DungeonTilemap.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://Player/Player.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://Player/Player.tscn" type="PackedScene" id=2]
|
||||||
|
@ -9,11 +9,10 @@
|
||||||
[ext_resource path="res://art/Pedestal.png" type="Texture" id=7]
|
[ext_resource path="res://art/Pedestal.png" type="Texture" id=7]
|
||||||
[ext_resource path="res://Items/ChargeWandPickup.tscn" type="PackedScene" id=8]
|
[ext_resource path="res://Items/ChargeWandPickup.tscn" type="PackedScene" id=8]
|
||||||
[ext_resource path="res://art/ecoprojectile.png" type="Texture" id=9]
|
[ext_resource path="res://art/ecoprojectile.png" type="Texture" id=9]
|
||||||
|
[ext_resource path="res://ai/Skeleton Enemy.tscn" type="PackedScene" id=11]
|
||||||
[ext_resource path="res://art/Mana.png" type="Texture" id=12]
|
[ext_resource path="res://art/Mana.png" type="Texture" id=12]
|
||||||
[ext_resource path="res://Items/Door.tscn" type="PackedScene" id=13]
|
[ext_resource path="res://Items/Door.tscn" type="PackedScene" id=13]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
extents = Vector2( 169.977, 24.8286 )
|
extents = Vector2( 169.977, 24.8286 )
|
||||||
|
|
||||||
|
@ -263,7 +262,7 @@ margin_right = 1302.35
|
||||||
margin_bottom = 200.227
|
margin_bottom = 200.227
|
||||||
rect_scale = Vector2( 0.75, 0.75 )
|
rect_scale = Vector2( 0.75, 0.75 )
|
||||||
custom_fonts/font = SubResource( 2 )
|
custom_fonts/font = SubResource( 2 )
|
||||||
text = "Press 'E'and equip a projectile to be able to shoot"
|
text = "Press 'E'and equip a spell to be able to shoot"
|
||||||
autowrap = true
|
autowrap = true
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
|
@ -280,7 +279,7 @@ margin_right = 1453.41
|
||||||
margin_bottom = 142.983
|
margin_bottom = 142.983
|
||||||
rect_scale = Vector2( 0.5, 0.5 )
|
rect_scale = Vector2( 0.5, 0.5 )
|
||||||
custom_fonts/font = SubResource( 2 )
|
custom_fonts/font = SubResource( 2 )
|
||||||
text = "Each projectile does something different"
|
text = "Each spell does something different"
|
||||||
autowrap = true
|
autowrap = true
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
|
@ -289,13 +288,13 @@ __meta__ = {
|
||||||
[node name="sample_text4" type="Label" parent="text/Text6"]
|
[node name="sample_text4" type="Label" parent="text/Text6"]
|
||||||
anchor_top = -0.000655535
|
anchor_top = -0.000655535
|
||||||
anchor_bottom = -0.000655535
|
anchor_bottom = -0.000655535
|
||||||
margin_left = 1426.25
|
margin_left = 1425.66
|
||||||
margin_top = 59.1731
|
margin_top = 59.1731
|
||||||
margin_right = 1634.25
|
margin_right = 1633.66
|
||||||
margin_bottom = 167.173
|
margin_bottom = 167.173
|
||||||
rect_scale = Vector2( 0.45, 0.45 )
|
rect_scale = Vector2( 0.45, 0.45 )
|
||||||
custom_fonts/font = SubResource( 2 )
|
custom_fonts/font = SubResource( 2 )
|
||||||
text = "This projectile takes no mana but does little damage"
|
text = "This spell takes no mana but does little damage"
|
||||||
autowrap = true
|
autowrap = true
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
|
@ -340,7 +339,7 @@ margin_right = 2196.39
|
||||||
margin_bottom = 284.74
|
margin_bottom = 284.74
|
||||||
rect_scale = Vector2( 0.45, 0.45 )
|
rect_scale = Vector2( 0.45, 0.45 )
|
||||||
custom_fonts/font = SubResource( 2 )
|
custom_fonts/font = SubResource( 2 )
|
||||||
text = "Press 'F' to open"
|
text = "Press 'F' to open stuff"
|
||||||
autowrap = true
|
autowrap = true
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
|
@ -458,5 +457,8 @@ texture = ExtResource( 9 )
|
||||||
position = Vector2( 1581.08, 38.1216 )
|
position = Vector2( 1581.08, 38.1216 )
|
||||||
scale = Vector2( 2.66787, 2.66787 )
|
scale = Vector2( 2.66787, 2.66787 )
|
||||||
texture = ExtResource( 12 )
|
texture = ExtResource( 12 )
|
||||||
|
|
||||||
|
[node name="Skeleton Enemy" parent="." instance=ExtResource( 11 )]
|
||||||
|
position = Vector2( 149.132, 146.16 )
|
||||||
[connection signal="body_entered" from="Area2D" to="Player" method="_on_Area2D_body_entered"]
|
[connection signal="body_entered" from="Area2D" to="Player" method="_on_Area2D_body_entered"]
|
||||||
[connection signal="body_entered" from="Area2D" to="text/Text2" method="_on_body_entered"]
|
[connection signal="body_entered" from="Area2D" to="text/Text2" method="_on_body_entered"]
|
||||||
|
|
|
@ -161,6 +161,11 @@ inventory={
|
||||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":69,"unicode":0,"echo":false,"script":null)
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":69,"unicode":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
open={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":70,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[layer_names]
|
[layer_names]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue