added infinite lives mode

This commit is contained in:
pennyrigate 2023-02-13 02:30:44 -05:00
parent f19a49f6e7
commit ed04bf1c2e
13 changed files with 109 additions and 11 deletions

View file

@ -17,6 +17,11 @@ export (Color) var bonus_color
func _ready():
Game.time = 0
#Change graphics depending on if lives are on
if Game.use_lives:
$LivesHead.visible = true
else:
$DeathsHead.visible = true
func _physics_process(delta):
#Gold Counter
@ -35,7 +40,10 @@ func _physics_process(delta):
arrow_counter.text = str(Game.arrows)
##TOUCH UP LATER
#Lives counter
lives_counter.text = str(Game.lives)
if Game.use_lives:
lives_counter.text = str(Game.lives)
else:
lives_counter.text = str(Game.deaths)
#Life bonus color
if Game.lives == 2:
lives_counter.modulate = bonus_color

View file

@ -1,7 +1,9 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=9 format=2]
[ext_resource path="res://graphics/hud/stars_hud.png" type="Texture" id=1]
[ext_resource path="res://graphics/hud/lives_head.png" type="Texture" id=2]
[ext_resource path="res://graphics/hud/hud.png" type="Texture" id=3]
[ext_resource path="res://graphics/hud/deaths_head.png" type="Texture" id=4]
[ext_resource path="res://objects/hud/hud.gd" type="Script" id=6]
[ext_resource path="res://scripts/theme.tres" type="Theme" id=10]
@ -72,6 +74,16 @@ texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 32, 0, 8, 8 )
[node name="LivesHead" type="Sprite" parent="."]
visible = false
position = Vector2( 234, 6 )
texture = ExtResource( 2 )
[node name="DeathsHead" type="Sprite" parent="."]
visible = false
position = Vector2( 236, 6 )
texture = ExtResource( 4 )
[node name="ScoreText" type="Label" parent="."]
margin_left = 137.0
margin_top = -1.0

View file

@ -296,32 +296,44 @@ func exit_transport():
current_state = State.FALL
func die():
Game.ac_climb.set_stream(null) # stop climbing sound
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:
return
#Create particles
var new_particles = death_particles.duplicate()
get_parent().add_child(new_particles)
new_particles.global_position = global_position
new_particles.emitting = true
sprite.visible = false
current_state = State.INACTIVE
position = Game.respawn_point
if Game.lives <= 0:
current_state = State.INACTIVE # Set to state where player is not controllable
position = Game.respawn_point # Set respawn point
if Game.lives <= 0 && Game.use_lives:
#Gover
#Particles
new_particles.amount = 64
new_particles.lifetime = 0.45
new_particles.speed_scale = 1.5
current_state = State.INACTIVE
current_state = State.INACTIVE # Set to state where player is not controllable
Game.play_sound(Game.a_gover, Game.ac_die)
#Slow down time
var time_tween = get_tree().create_tween()
time_tween.tween_property(Engine, "time_scale", 0.1, 0.3)
Game.ac_music.stop()
yield(time_tween, "finished")
yield(time_tween, "finished") #Resume from freeze frame
yield(get_tree().create_timer(1.0 * 0.1), "timeout")
Game.call_deferred("restart_level")
else:
#Die
Game.lives -= 1
Game.deaths += 1
Game.play_sound(Game.a_die, Game.ac_die)
yield(Game.freeze_frame(0.3), "timeout")
#Reduce points if playing in infinite lives mode
if Game.use_lives == false && Game.lives < 0:
Game.score = max(0,Game.score - 500)
#Respawn player
current_state = State.IDLE
sprite.visible = true