added the option for iframes
This commit is contained in:
parent
19dd1809a2
commit
39a6c027c4
3 changed files with 56 additions and 39 deletions
|
@ -50,6 +50,7 @@ tile_data = PoolIntArray( 851973, 0, 65537, 851976, 1, 0, 917512, 1, 0, 983048,
|
|||
|
||||
[node name="Player" parent="." instance=ExtResource( 2 )]
|
||||
position = Vector2( 48, 144 )
|
||||
use_iframes = true
|
||||
|
||||
[node name="Boss1" parent="." instance=ExtResource( 1 )]
|
||||
position = Vector2( 168, 112 )
|
||||
|
|
|
@ -4,6 +4,7 @@ const ArrowProjectile = preload("res://objects/player/arrow_projectile.tscn")
|
|||
|
||||
##CLEAN UP CODE LATER
|
||||
##Movement
|
||||
export var use_iframes = false
|
||||
export var walk_speed = 50
|
||||
export var gravity = 12
|
||||
export var max_fall_speed = INF
|
||||
|
@ -18,11 +19,13 @@ onready var sword_sprite = $SwordSprite
|
|||
onready var sword_hitbox = $SwordArea
|
||||
onready var death_particles = $DeathSplatter
|
||||
onready var dust_particles = $DustParticles
|
||||
onready var iframe_timer = $IframeTimer
|
||||
#Map
|
||||
onready var map = get_owner()
|
||||
##States
|
||||
enum State {IDLE,WALK,JUMP,FALL,STUNNED,CLIMB,SWORD,SHOOT,INACTIVE,TRANSPORT}
|
||||
var current_state = State.IDLE
|
||||
var can_die = true
|
||||
##Runtime
|
||||
var axis = Vector2.ZERO #Current direction being held
|
||||
var trail_color = Color(0.25,0,1,0.4)
|
||||
|
@ -296,6 +299,7 @@ func exit_transport():
|
|||
current_state = State.FALL
|
||||
|
||||
func die():
|
||||
if can_die:
|
||||
Game.ac_climb.set_stream(null) # stop climbing sound\
|
||||
#If the player is already dead, don't kill them again
|
||||
if current_state == State.INACTIVE:
|
||||
|
@ -332,6 +336,10 @@ func die():
|
|||
#Reduce points if playing in infinite lives mode
|
||||
if Game.use_lives == false && Game.lives < 0:
|
||||
Game.score = max(0,Game.score - 500)
|
||||
#Iframes after respawn
|
||||
if use_iframes:
|
||||
iframe_timer.start()
|
||||
can_die = false
|
||||
|
||||
#Respawn player
|
||||
current_state = State.IDLE
|
||||
|
@ -371,3 +379,7 @@ func _on_SwordArea_area_entered(area):
|
|||
|
||||
func _on_Area2D_body_entered(body):
|
||||
if body.is_in_group("death"): die()
|
||||
|
||||
|
||||
func _on_IframeTimer_timeout():
|
||||
can_die = true
|
||||
|
|
|
@ -711,6 +711,10 @@ scale_amount = 0.25
|
|||
scale_amount_random = 0.5
|
||||
scale_amount_curve = SubResource( 43 )
|
||||
|
||||
[node name="IframeTimer" type="Timer" parent="."]
|
||||
wait_time = 0.3
|
||||
|
||||
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]
|
||||
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_AnimationPlayer_animation_finished"]
|
||||
[connection signal="area_entered" from="SwordArea" to="." method="_on_SwordArea_area_entered"]
|
||||
[connection signal="timeout" from="IframeTimer" to="." method="_on_IframeTimer_timeout"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue