From ed04bf1c2ed41ced830a913a625eeaf0bc985658 Mon Sep 17 00:00:00 2001 From: pennyrigate Date: Mon, 13 Feb 2023 02:30:44 -0500 Subject: [PATCH] added infinite lives mode --- game.gd | 8 ++++ graphics/hud/deaths_head.png | Bin 0 -> 176 bytes graphics/hud/deaths_head.png.import | 35 ++++++++++++++++++ graphics/hud/hud.png | Bin 760 -> 673 bytes graphics/hud/hud_old.png | Bin 420 -> 0 bytes graphics/hud/lives_head.png | Bin 0 -> 208 bytes ...d_old.png.import => lives_head.png.import} | 6 +-- maps/level_select.gd | 9 +++++ maps/level_select.tscn | 8 ++++ objects/hud/hud.gd | 10 ++++- objects/hud/hud.tscn | 14 ++++++- objects/player/player.gd | 24 +++++++++--- scripts/save.gd | 6 +++ 13 files changed, 109 insertions(+), 11 deletions(-) create mode 100644 graphics/hud/deaths_head.png create mode 100644 graphics/hud/deaths_head.png.import delete mode 100644 graphics/hud/hud_old.png create mode 100644 graphics/hud/lives_head.png rename graphics/hud/{hud_old.png.import => lives_head.png.import} (70%) diff --git a/game.gd b/game.gd index 8f4e0f5..e2aa6a1 100644 --- a/game.gd +++ b/game.gd @@ -14,6 +14,7 @@ var arrows = 0 var score = 0 var high_score = 0 var lives = 2 +var deaths = 0 var time = 0.0 #Audio Channels onready var ac_jump = $JumpSound @@ -39,13 +40,17 @@ const a_gover = preload("res://audio/sounds/gover.wav") #Objects const block_text = preload("res://objects/hud/blocktext.tscn") const pause_screen = preload("res://objects/hud/pause_screen.tscn") +#Game info var respawn_point = Vector2(32,166) #Respawn point var current_level = 0 #Current level being played var current_file = 1 #Current save file var shards_collected = [false,false,false,false,false,false,false,false,false,false] +var is_marathon_mode = false +var use_lives = false func _ready(): Save.load_file(current_file) + Save.load_options() #Instances a node 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.arrows = 0 Game.lives = 2 + Game.deaths = 0 #Save func save(): @@ -98,6 +104,8 @@ func save(): for i in 8: if shards_collected[i]: Save.set_shard_collected(save_id, i, true) + # set options + Save.set_options() # save file Save.save_file(current_file) diff --git a/graphics/hud/deaths_head.png b/graphics/hud/deaths_head.png new file mode 100644 index 0000000000000000000000000000000000000000..5570267c629aa22507433c6c38d1353ff10b1d5f GIT binary patch literal 176 zcmeAS@N?(olHy`uVBq!ia0vp^>_E)H!3HEvS)PI@#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DkxL735kHCP2G=<4a>7$Ol~+Skd;puoZ0{rf%3Y)w~_ebW=9 zwH6&%$ye%nLR&&au1@{c7r}ow<~=>KYw3*0TR$SK624ikT{UH;ZQ+d_q8T}kMyp?_ SMtlPr$l&Sf=d#Wzp$Pz(&Ne0h literal 0 HcmV?d00001 diff --git a/graphics/hud/deaths_head.png.import b/graphics/hud/deaths_head.png.import new file mode 100644 index 0000000..3a303ff --- /dev/null +++ b/graphics/hud/deaths_head.png.import @@ -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 diff --git a/graphics/hud/hud.png b/graphics/hud/hud.png index 3e35403472ab9c6ea549c6cbb7708f734a5f0752..53bafb2b9ffa4f86bec920f6cbf051804609373a 100644 GIT binary patch literal 673 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K54s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RwjuI(~TJ|URX0W zM#dW{V$9&l0DurnpAEs*4q8Dhm*;| zG@r@g$eosiO?g$P$}EJ#7?-9o^i;SdDt>t*|ECA!jdd+Q7$USDdFnFXbOQz!gQu&X J%Q~loCIHISolO7$ diff --git a/graphics/hud/lives_head.png b/graphics/hud/lives_head.png new file mode 100644 index 0000000000000000000000000000000000000000..89a9694a4fddc236938a2122304f8cc99a3a5b98 GIT binary patch literal 208 zcmeAS@N?(olHy`uVBq!ia0vp^AT|dFGm!kQGOqVM%xNb!1@J z*w6hZkrl`n4e$wZ{aEak75pLV%$;Y6;!xS0y|9{F#DRqZu3}SNedOnvF qj!x-~3hck+I_>!(_6yHF7n$=^GDLiTdS@+AGlQqApUXO@geCwg{XrA} literal 0 HcmV?d00001 diff --git a/graphics/hud/hud_old.png.import b/graphics/hud/lives_head.png.import similarity index 70% rename from graphics/hud/hud_old.png.import rename to graphics/hud/lives_head.png.import index d689cbe..72aeb31 100644 --- a/graphics/hud/hud_old.png.import +++ b/graphics/hud/lives_head.png.import @@ -2,15 +2,15 @@ importer="texture" type="StreamTexture" -path="res://.import/hud_old.png-375dbe46e18dedab40b4fcb3c0bcf043.stex" +path="res://.import/lives_head.png-d13195bbf6be6456364b8977d7fcec9a.stex" metadata={ "vram_texture": false } [deps] -source_file="res://graphics/hud/hud_old.png" -dest_files=[ "res://.import/hud_old.png-375dbe46e18dedab40b4fcb3c0bcf043.stex" ] +source_file="res://graphics/hud/lives_head.png" +dest_files=[ "res://.import/lives_head.png-d13195bbf6be6456364b8977d7fcec9a.stex" ] [params] diff --git a/maps/level_select.gd b/maps/level_select.gd index c161f78..9dbc36b 100644 --- a/maps/level_select.gd +++ b/maps/level_select.gd @@ -9,6 +9,7 @@ onready var high_score_any = $HighScoreAny onready var high_score_100 = $HighScore100 onready var levelarrow_up = $LevelArrowUp onready var levelarrow_down = $LevelArrowDown +onready var lives_mode_text = $LivesModeText #Shards onready var shards = [ $ShardGraphics/Shard, @@ -48,6 +49,14 @@ func _physics_process(delta): if Input.is_action_just_pressed("jump"): Game.current_level = current_level 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): if current_shard + amount != -1 && current_shard + amount != 8: #Check if in range diff --git a/maps/level_select.tscn b/maps/level_select.tscn index f3d3ad5..94e26a1 100644 --- a/maps/level_select.tscn +++ b/maps/level_select.tscn @@ -91,6 +91,14 @@ text = "Collect all coins " 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="."] position = Vector2( 0, 7 ) diff --git a/objects/hud/hud.gd b/objects/hud/hud.gd index 64ea1d0..cbf2734 100644 --- a/objects/hud/hud.gd +++ b/objects/hud/hud.gd @@ -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 diff --git a/objects/hud/hud.tscn b/objects/hud/hud.tscn index 5c7e1e7..07b9ecb 100644 --- a/objects/hud/hud.tscn +++ b/objects/hud/hud.tscn @@ -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 diff --git a/objects/player/player.gd b/objects/player/player.gd index 51b9cf7..ee90327 100644 --- a/objects/player/player.gd +++ b/objects/player/player.gd @@ -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 diff --git a/scripts/save.gd b/scripts/save.gd index cb04878..c94bcf5 100644 --- a/scripts/save.gd +++ b/scripts/save.gd @@ -22,12 +22,18 @@ func get_level_data(save_id): 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): file.set_value(save_id, "shard_%d" % index, collected) func set_score(save_id, score, is_100 = false): 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): file.set_value(save_id, "time_100" if is_100 else "time_any", float(time))