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

@ -14,6 +14,7 @@ var arrows = 0
var score = 0 var score = 0
var high_score = 0 var high_score = 0
var lives = 2 var lives = 2
var deaths = 0
var time = 0.0 var time = 0.0
#Audio Channels #Audio Channels
onready var ac_jump = $JumpSound onready var ac_jump = $JumpSound
@ -39,13 +40,17 @@ const a_gover = preload("res://audio/sounds/gover.wav")
#Objects #Objects
const block_text = preload("res://objects/hud/blocktext.tscn") const block_text = preload("res://objects/hud/blocktext.tscn")
const pause_screen = preload("res://objects/hud/pause_screen.tscn") const pause_screen = preload("res://objects/hud/pause_screen.tscn")
#Game info
var respawn_point = Vector2(32,166) #Respawn point var respawn_point = Vector2(32,166) #Respawn point
var current_level = 0 #Current level being played var current_level = 0 #Current level being played
var current_file = 1 #Current save file var current_file = 1 #Current save file
var shards_collected = [false,false,false,false,false,false,false,false,false,false] var shards_collected = [false,false,false,false,false,false,false,false,false,false]
var is_marathon_mode = false
var use_lives = false
func _ready(): func _ready():
Save.load_file(current_file) Save.load_file(current_file)
Save.load_options()
#Instances a node #Instances a node
func instance_node(node:PackedScene,x:float,y:float,parent): func instance_node(node:PackedScene,x:float,y:float,parent):
@ -83,6 +88,7 @@ func clear_collectibles():
Game.shards_collected = [false,false,false,false,false,false,false,false,false,false] Game.shards_collected = [false,false,false,false,false,false,false,false,false,false]
Game.arrows = 0 Game.arrows = 0
Game.lives = 2 Game.lives = 2
Game.deaths = 0
#Save #Save
func save(): func save():
@ -98,6 +104,8 @@ func save():
for i in 8: for i in 8:
if shards_collected[i]: if shards_collected[i]:
Save.set_shard_collected(save_id, i, true) Save.set_shard_collected(save_id, i, true)
# set options
Save.set_options()
# save file # save file
Save.save_file(current_file) Save.save_file(current_file)

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/deaths_head.png-8207d14882a026c4638e68f6f058ba2f.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://graphics/hud/deaths_head.png"
dest_files=[ "res://.import/deaths_head.png-8207d14882a026c4638e68f6f058ba2f.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 760 B

After

Width:  |  Height:  |  Size: 673 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 420 B

BIN
graphics/hud/lives_head.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

View file

@ -2,15 +2,15 @@
importer="texture" importer="texture"
type="StreamTexture" type="StreamTexture"
path="res://.import/hud_old.png-375dbe46e18dedab40b4fcb3c0bcf043.stex" path="res://.import/lives_head.png-d13195bbf6be6456364b8977d7fcec9a.stex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
[deps] [deps]
source_file="res://graphics/hud/hud_old.png" source_file="res://graphics/hud/lives_head.png"
dest_files=[ "res://.import/hud_old.png-375dbe46e18dedab40b4fcb3c0bcf043.stex" ] dest_files=[ "res://.import/lives_head.png-d13195bbf6be6456364b8977d7fcec9a.stex" ]
[params] [params]

View file

@ -9,6 +9,7 @@ onready var high_score_any = $HighScoreAny
onready var high_score_100 = $HighScore100 onready var high_score_100 = $HighScore100
onready var levelarrow_up = $LevelArrowUp onready var levelarrow_up = $LevelArrowUp
onready var levelarrow_down = $LevelArrowDown onready var levelarrow_down = $LevelArrowDown
onready var lives_mode_text = $LivesModeText
#Shards #Shards
onready var shards = [ onready var shards = [
$ShardGraphics/Shard, $ShardGraphics/Shard,
@ -48,6 +49,14 @@ func _physics_process(delta):
if Input.is_action_just_pressed("jump"): if Input.is_action_just_pressed("jump"):
Game.current_level = current_level Game.current_level = current_level
Game.change_map(level.scene) Game.change_map(level.scene)
#Toggle lives mode
if Input.is_action_just_pressed("shoot"):
Game.use_lives = !Game.use_lives
Game.save()
if Game.use_lives:
lives_mode_text.text = "lives are on press z to change this"
else:
lives_mode_text.text = "lives are off press z to change this"
func change_current_shard(amount): func change_current_shard(amount):
if current_shard + amount != -1 && current_shard + amount != 8: #Check if in range if current_shard + amount != -1 && current_shard + amount != 8: #Check if in range

View file

@ -91,6 +91,14 @@ text = "Collect all coins
" "
align = 1 align = 1
[node name="LivesModeText" type="Label" parent="."]
margin_left = 2.0
margin_top = 176.0
margin_right = 258.0
margin_bottom = 190.0
theme = ExtResource( 1 )
text = "lives are off press z to change this"
[node name="ShardGraphics" type="Node2D" parent="."] [node name="ShardGraphics" type="Node2D" parent="."]
position = Vector2( 0, 7 ) position = Vector2( 0, 7 )

View file

@ -17,6 +17,11 @@ export (Color) var bonus_color
func _ready(): func _ready():
Game.time = 0 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): func _physics_process(delta):
#Gold Counter #Gold Counter
@ -35,7 +40,10 @@ func _physics_process(delta):
arrow_counter.text = str(Game.arrows) arrow_counter.text = str(Game.arrows)
##TOUCH UP LATER ##TOUCH UP LATER
#Lives counter #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 #Life bonus color
if Game.lives == 2: if Game.lives == 2:
lives_counter.modulate = bonus_color 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/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/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://objects/hud/hud.gd" type="Script" id=6]
[ext_resource path="res://scripts/theme.tres" type="Theme" id=10] [ext_resource path="res://scripts/theme.tres" type="Theme" id=10]
@ -72,6 +74,16 @@ texture = ExtResource( 1 )
region_enabled = true region_enabled = true
region_rect = Rect2( 32, 0, 8, 8 ) 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="."] [node name="ScoreText" type="Label" parent="."]
margin_left = 137.0 margin_left = 137.0
margin_top = -1.0 margin_top = -1.0

View file

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

View file

@ -22,12 +22,18 @@ func get_level_data(save_id):
shards = shards shards = shards
} }
func load_options():
Game.use_lives = file.get_value("options","uselives",Game.use_lives)
func set_shard_collected(save_id, index, collected = true): func set_shard_collected(save_id, index, collected = true):
file.set_value(save_id, "shard_%d" % index, collected) file.set_value(save_id, "shard_%d" % index, collected)
func set_score(save_id, score, is_100 = false): func set_score(save_id, score, is_100 = false):
file.set_value(save_id, "score_100" if is_100 else "score_any", int(score)) file.set_value(save_id, "score_100" if is_100 else "score_any", int(score))
func set_options():
file.set_value("options","uselives",Game.use_lives)
func set_time(save_id, time, is_100 = false): func set_time(save_id, time, is_100 = false):
file.set_value(save_id, "time_100" if is_100 else "time_any", float(time)) file.set_value(save_id, "time_100" if is_100 else "time_any", float(time))