diff --git a/autoloads/audio.gd b/autoloads/audio.gd new file mode 100644 index 0000000..a5c711c --- /dev/null +++ b/autoloads/audio.gd @@ -0,0 +1,38 @@ +extends Node + +#Audio Channels +onready var ac_jump = $JumpSound +onready var ac_collectible = $CollecitbleSound +onready var ac_climb = $ClimbSound +onready var ac_die = $DieSound +onready var ac_music = $Music +onready var ac_cheat = $CodeEntrySound +onready var ac_boss = $BossSound +#Sounds +const a_gold = preload("res://audio/sounds/gold.wav") +const a_arrow = preload("res://audio/sounds/a_egg_collect.ogg") +const a_jump = preload("res://audio/sounds/jump.ogg") +const a_star = preload("res://audio/sounds/a_jinjo.ogg") +const a_shard = preload("res://audio/sounds/shard.wav") +const a_climb_up = preload("res://audio/sounds/a_climb.ogg") +const a_climb_down = preload("res://audio/sounds/a_bmilc.ogg") +const a_sword = preload("res://audio/sounds/sword.ogg") +const a_doublejump = preload("res://audio/sounds/a_bree.wav") +const a_shoot = preload("res://audio/sounds/a_egg_shoot.ogg") +const a_die = preload("res://audio/sounds/die.wav") +const a_die_skeleton = preload("res://audio/sounds/die_skeleton.wav") +const a_scrump_die = preload("res://audio/sounds/scrump_die.wav") +const a_die_robot = preload("res://audio/sounds/die_robot.wav") +const a_gover = preload("res://audio/sounds/gover.wav") +const a_boss_hurt = preload("res://audio/sounds/boss_hurt.wav") + + +#Plays a sound +func play_sound(snd,player): + player.set_stream(snd) + player._set_playing(true) + +#Play music, if same track is already playing do nothing +func play_music(song): + if Audio.ac_music.stream != song or Audio.ac_music.playing == false: + play_sound(song,ac_music) diff --git a/autoloads/game.tscn b/autoloads/audio.tscn similarity index 86% rename from autoloads/game.tscn rename to autoloads/audio.tscn index e479506..2cd210f 100644 --- a/autoloads/game.tscn +++ b/autoloads/audio.tscn @@ -1,9 +1,8 @@ [gd_scene load_steps=2 format=2] -[ext_resource path="res://autoloads/game.gd" type="Script" id=1] +[ext_resource path="res://autoloads/audio.gd" type="Script" id=1] -[node name="Game" type="Node"] -pause_mode = 2 +[node name="Audio" type="Node"] script = ExtResource( 1 ) [node name="Music" type="AudioStreamPlayer" parent="."] diff --git a/autoloads/debug.gd b/autoloads/debug.gd index 5aebf40..da57fc9 100644 --- a/autoloads/debug.gd +++ b/autoloads/debug.gd @@ -98,7 +98,7 @@ func _input(event): _on_entry() func _on_entry(): - Game.play_sound(Game.a_star, Game.ac_cheat) + Audio.play_sound(Audio.a_star, Audio.ac_cheat) Game.can_pause = false func _enter_code(): diff --git a/autoloads/game.gd b/autoloads/game.gd index 9b67987..73fe1e1 100644 --- a/autoloads/game.gd +++ b/autoloads/game.gd @@ -17,31 +17,6 @@ var high_score = 0 var lives = 2 var deaths = 0 var time = 0.0 -#Audio Channels -onready var ac_jump = $JumpSound -onready var ac_collectible = $CollecitbleSound -onready var ac_climb = $ClimbSound -onready var ac_die = $DieSound -onready var ac_music = $Music -onready var ac_cheat = $CodeEntrySound -onready var ac_boss = $BossSound -#Sounds -const a_gold = preload("res://audio/sounds/gold.wav") -const a_arrow = preload("res://audio/sounds/a_egg_collect.ogg") -const a_jump = preload("res://audio/sounds/jump.ogg") -const a_star = preload("res://audio/sounds/a_jinjo.ogg") -const a_shard = preload("res://audio/sounds/shard.wav") -const a_climb_up = preload("res://audio/sounds/a_climb.ogg") -const a_climb_down = preload("res://audio/sounds/a_bmilc.ogg") -const a_sword = preload("res://audio/sounds/sword.ogg") -const a_doublejump = preload("res://audio/sounds/a_bree.wav") -const a_shoot = preload("res://audio/sounds/a_egg_shoot.ogg") -const a_die = preload("res://audio/sounds/die.wav") -const a_die_skeleton = preload("res://audio/sounds/die_skeleton.wav") -const a_scrump_die = preload("res://audio/sounds/scrump_die.wav") -const a_die_robot = preload("res://audio/sounds/die_robot.wav") -const a_gover = preload("res://audio/sounds/gover.wav") -const a_boss_hurt = preload("res://audio/sounds/boss_hurt.wav") #Objects const block_text = preload("res://objects/hud/blocktext.tscn") const pause_screen = preload("res://objects/hud/pause_screen.tscn") @@ -64,11 +39,6 @@ func instance_node(node:PackedScene,x:float,y:float,parent): Instance.global_position = Vector2(x,y) parent.add_child(Instance) -#Plays a sound -func play_sound(snd,player): - player.set_stream(snd) - player._set_playing(true) - #Get position in sectors func get_sector(pos): return (pos / resolution).floor() @@ -92,14 +62,14 @@ func change_map(map): #Clear data func clear_collectibles(): - Game.score = 0 - Game.golds = 0 - Game.stars = [false,false,false,false,false] - Game.shards = 0 - Game.shards_collected = [false,false,false,false,false,false,false,false,false,false] - Game.arrows = 0 - Game.lives = 2 - Game.deaths = 0 + score = 0 + golds = 0 + stars = [false,false,false,false,false] + shards = 0 + shards_collected = [false,false,false,false,false,false,false,false,false,false] + arrows = 0 + lives = 2 + deaths = 0 #Save func save(): @@ -134,20 +104,20 @@ func timeify(input): #Restart level func restart_level(): - if Game.score > Game.high_score: Game.high_score = Game.score - Game.score = 0 - Game.golds = 0 - Game.stars = [false,false,false,false,false] - Game.shards = 0 - Game.arrows = 0 - Game.lives = 2 - Game.ac_climb.stop() - Game.ac_die.stop() + if score > high_score: high_score = score + score = 0 + golds = 0 + stars = [false,false,false,false,false] + shards = 0 + arrows = 0 + lives = 2 + Audio.ac_climb.stop() + Audio.ac_die.stop() Engine.time_scale = 1.0 for tween in get_tree().get_processed_tweens(): tween.kill() - Game.change_map(load(Game.get_map().filename)) - ac_music.stream_paused = false + change_map(load(get_map().filename)) + Audio.ac_music.stream_paused = false #Freeze frame func freeze_frame(time): @@ -158,12 +128,7 @@ func freeze_frame(time): #Check if 100%ed func has_collection_bonus(): - return Game.shards == 5 && Game.golds == 50 - -#Play music, if same track is already playing do nothing -func play_music(song): - if Game.ac_music.stream != song or Game.ac_music.playing == false: - play_sound(song,ac_music) + return shards == 5 && golds == 50 func _physics_process(delta): if Debug.entry == false: diff --git a/graphics/enemy/big_saw.png b/graphics/enemy/big_saw.png new file mode 100644 index 0000000..79a8611 Binary files /dev/null and b/graphics/enemy/big_saw.png differ diff --git a/graphics/enemy/big_saw.png.import b/graphics/enemy/big_saw.png.import new file mode 100644 index 0000000..1c3dfbc --- /dev/null +++ b/graphics/enemy/big_saw.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/big_saw.png-a44e3977b56835f580fa101393440339.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://graphics/enemy/big_saw.png" +dest_files=[ "res://.import/big_saw.png-a44e3977b56835f580fa101393440339.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/maps/level_select.gd b/maps/level_select.gd index 797c5ba..5f756f5 100644 --- a/maps/level_select.gd +++ b/maps/level_select.gd @@ -33,7 +33,7 @@ export var target_time_any = 0 func _ready(): Game.fade.fade_in(0.000000000000001) change_current_level(Game.current_level) - Game.ac_music.stop() + Audio.ac_music.stop() func _physics_process(delta): if Input.is_action_just_pressed("ui_up"): change_current_level(-1) diff --git a/maps/map.gd b/maps/map.gd index cff2dbd..162ea18 100644 --- a/maps/map.gd +++ b/maps/map.gd @@ -14,7 +14,7 @@ func _ready(): Game.fade.fade_in(0.4) Game.fade.connect("fade_finished", get_tree(), "set_pause", [false], CONNECT_ONESHOT) Game.fade.connect("fade_finished", Game, "set", ["can_pause", true], CONNECT_ONESHOT) - Game.play_music(music) + Audio.play_music(music) func _physics_process(delta): if Game.golds == 50 && Game.shards == 5: diff --git a/maps/test_room.tscn b/maps/test_room.tscn index d47a73d..fe80d03 100644 --- a/maps/test_room.tscn +++ b/maps/test_room.tscn @@ -169,7 +169,6 @@ material = SubResource( 4 ) position = Vector2( 120, 168 ) z_index = -3 frames = SubResource( 5 ) -frame = 1 playing = true [node name="SawTest4" type="AnimatedSprite" parent="."] @@ -177,6 +176,7 @@ material = SubResource( 4 ) position = Vector2( 160, 168 ) z_index = -3 frames = SubResource( 5 ) +frame = 1 playing = true [node name="SawTest5" type="AnimatedSprite" parent="."] @@ -184,6 +184,7 @@ material = SubResource( 4 ) position = Vector2( 56, 176 ) z_index = -3 frames = SubResource( 5 ) +frame = 1 playing = true [node name="RollingFiend" parent="." instance=ExtResource( 22 )] @@ -191,14 +192,12 @@ position = Vector2( 48, 120 ) [node name="AnimatedSprite" parent="RollingFiend" index="0"] visible = false -frame = 0 [node name="SawTest2" type="AnimatedSprite" parent="RollingFiend"] material = SubResource( 4 ) position = Vector2( 4, 4 ) z_index = -3 frames = SubResource( 5 ) -frame = 1 playing = true [editable path="RollingFiend"] diff --git a/objects/collectibles/arrow.gd b/objects/collectibles/arrow.gd index 4a94a12..dbd1b0f 100644 --- a/objects/collectibles/arrow.gd +++ b/objects/collectibles/arrow.gd @@ -7,5 +7,5 @@ func _on_Area2D_area_entered(area): if area.is_in_group("player"): Game.arrows += value Game.score += 25 - Game.play_sound(Game.a_arrow,Game.ac_collectible) + Audio.play_sound(Audio.a_arrow,Audio.ac_collectible) queue_free() diff --git a/objects/collectibles/gold.gd b/objects/collectibles/gold.gd index e1a1c8b..6f099e7 100644 --- a/objects/collectibles/gold.gd +++ b/objects/collectibles/gold.gd @@ -11,5 +11,5 @@ func _on_Area2D_area_entered(area): if area.is_in_group("player"): Game.golds += value Game.score += 5 - Game.play_sound(Game.a_gold,Game.ac_collectible) + Audio.play_sound(Audio.a_gold,Audio.ac_collectible) queue_free() diff --git a/objects/collectibles/shard.gd b/objects/collectibles/shard.gd index 542b439..1a6f4df 100644 --- a/objects/collectibles/shard.gd +++ b/objects/collectibles/shard.gd @@ -9,9 +9,9 @@ func _ready(): func _on_Area2D_area_entered(area): #Collect if area.is_in_group("player"): - Game.ac_music.stream_paused = true - Game.play_sound(Game.a_shard,Game.ac_collectible) - Game.ac_collectible.connect("finished", Game.ac_music, "set_stream_paused", [false]) + Audio.ac_music.stream_paused = true + Audio.play_sound(Audio.a_shard,Audio.ac_collectible) + Audio.ac_collectible.connect("finished", Audio.ac_music, "set_stream_paused", [false]) Game.score += 500 Game.shards += value Game.shards_collected[number] = true diff --git a/objects/collectibles/star.gd b/objects/collectibles/star.gd index c562c13..b129feb 100644 --- a/objects/collectibles/star.gd +++ b/objects/collectibles/star.gd @@ -23,12 +23,12 @@ func _ready(): func _on_Area2D_area_entered(area): #Collect if area.is_in_group("player"): - Game.play_sound(Game.a_star,Game.ac_collectible) + Audio.play_sound(Audio.a_star,Audio.ac_collectible) Game.score += 100 Game.stars[color] = true #5 Star reward if Game.stars[0] && Game.stars[1] && Game.stars[2] && Game.stars[3] && Game.stars[4]: - Game.play_sound(Game.a_shard,Game.ac_collectible) + Audio.play_sound(Audio.a_shard,Audio.ac_collectible) Game.shards += 1 Game.shards_collected[4] = true Game.score += 500 diff --git a/objects/enemy/boss/boss1.gd b/objects/enemy/boss/boss1.gd index b99c465..e61dd86 100644 --- a/objects/enemy/boss/boss1.gd +++ b/objects/enemy/boss/boss1.gd @@ -29,7 +29,7 @@ func _on_ShootTimer_timeout(): func die(): hp -= 1 - Game.play_sound(Game.a_boss_hurt,Game.ac_boss) + Audio.play_sound(Audio.a_boss_hurt,Audio.ac_boss) match hp: 2: emit_signal("entered_phase", 2) @@ -41,7 +41,7 @@ func die(): shoot_time = Vector2(0.3,0.5) 0: Game.instance_node(Gore,position.x,position.y,map) - Game.play_sound(Game.a_scrump_die,Game.ac_boss) + Audio.play_sound(Audio.a_scrump_die,Audio.ac_boss) emit_signal("entered_phase",4) queue_free() diff --git a/objects/enemy/enemy.gd b/objects/enemy/enemy.gd index e6f1c1a..a6ca371 100644 --- a/objects/enemy/enemy.gd +++ b/objects/enemy/enemy.gd @@ -21,7 +21,7 @@ signal died() export var score_for_killing = 0 export var blood = true -var death_sound = Game.a_die +var death_sound = Audio.a_die var death_blood_offset = Vector2.ZERO func _on_Hitbox_area_entered(area): @@ -36,7 +36,7 @@ func die(): death_particles.emitting = true get_parent().add_child(death_particles) - Game.play_sound(death_sound, Game.ac_die) + Audio.play_sound(death_sound, Audio.ac_die) Game.score += score_for_killing emit_signal("died") queue_free() diff --git a/objects/enemy/enemy_move_diagonal.gd b/objects/enemy/enemy_move_diagonal.gd index 1aa32d9..cf45db0 100644 --- a/objects/enemy/enemy_move_diagonal.gd +++ b/objects/enemy/enemy_move_diagonal.gd @@ -12,7 +12,7 @@ export(int, "Left To Right", "Right To Left") var move_direction onready var startpos = position func _ready(): - death_sound = Game.a_die_robot + death_sound = Audio.a_die_robot up_boundary *= 8 down_boundary *= 8 #Move in direction selected diff --git a/objects/enemy/explosion.gd b/objects/enemy/explosion.gd index cba6bac..b357993 100644 --- a/objects/enemy/explosion.gd +++ b/objects/enemy/explosion.gd @@ -2,7 +2,7 @@ extends "res://objects/enemy/enemy.gd" func _ready(): $AnimatedSprite.play("explode") - Game.play_sound(Game.a_die_robot,Game.ac_die) + Audio.play_sound(Audio.a_die_robot,Audio.ac_die) func _on_animation_finished(): queue_free() diff --git a/objects/enemy/skelarcher.gd b/objects/enemy/skelarcher.gd index ad99ef6..9321a03 100644 --- a/objects/enemy/skelarcher.gd +++ b/objects/enemy/skelarcher.gd @@ -17,7 +17,7 @@ onready var arrow_spawn_l = $ArrowSpawnL onready var arrow_spawn_r = $ArrowSpawnR func _ready(): - death_sound = Game.a_die_skeleton + death_sound = Audio.a_die_skeleton timer.start(shoot_time) func _on_Timer_timeout(): diff --git a/objects/environment/turret/turret.gd b/objects/environment/turret/turret.gd index 61998d8..276a963 100644 --- a/objects/environment/turret/turret.gd +++ b/objects/environment/turret/turret.gd @@ -35,4 +35,4 @@ func _physics_process(delta): bullet.direction = bullet.direction.rotated(rand_range(-bullet_spread, bullet_spread)) bullet.speed = bullet_speed get_parent().call_deferred("add_child", bullet) - Game.play_sound(Game.a_arrow, Game.ac_climb) + Audio.play_sound(Audio.a_arrow, Audio.ac_climb) diff --git a/objects/player/player.gd b/objects/player/player.gd index 43fd0ee..986a52f 100644 --- a/objects/player/player.gd +++ b/objects/player/player.gd @@ -125,7 +125,7 @@ func _process_idle_walk(): check_jump() #Goto Sword if Debug.allow_sword && Input.is_action_just_pressed("sword"): - Game.play_sound(Game.a_sword,Game.ac_jump) + Audio.play_sound(Audio.a_sword,Audio.ac_jump) current_state = State.SWORD return #Goto Shoot @@ -164,25 +164,25 @@ func _process_climb(): position.y += axis.y * 0.65 #Sound if axis.y == -1: - if Game.ac_climb.get_stream() != Game.a_climb_up: Game.play_sound(Game.a_climb_up,Game.ac_climb) + if Audio.ac_climb.get_stream() != Audio.a_climb_up: Audio.play_sound(Audio.a_climb_up,Audio.ac_climb) if axis.y == 1: - if Game.ac_climb.get_stream() != Game.a_climb_down: Game.play_sound(Game.a_climb_down,Game.ac_climb) - if axis.y == 0: Game.ac_climb.set_stream(null) + if Audio.ac_climb.get_stream() != Audio.a_climb_down: Audio.play_sound(Audio.a_climb_down,Audio.ac_climb) + if axis.y == 0: Audio.ac_climb.set_stream(null) #Manual Jump,, only works when holding neutral or away from ladder if axis.x != sprite.scale.x && Input.is_action_just_pressed("jump"): position.x -= sprite.scale.x * 3 velocity.y = -jump_force anims.set_speed_scale(1) current_state = State.FALL - Game.ac_climb.set_stream(null) + Audio.ac_climb.set_stream(null) return if climb_ray.get_collider() == null: if axis.y == -1: #Auto Jump velocity.y = -jump_force - Game.play_sound(Game.a_jump,Game.ac_jump) + Audio.play_sound(Audio.a_jump,Audio.ac_jump) #Auto dismount - Game.ac_climb.set_stream(null) + Audio.ac_climb.set_stream(null) current_state = State.FALL return #Side dismount @@ -190,7 +190,7 @@ func _process_climb(): position.x -= sprite.scale.x * 3 current_state = State.FALL anims.set_speed_scale(1) - Game.ac_climb.set_stream(null) + Audio.ac_climb.set_stream(null) return @@ -217,7 +217,7 @@ func _process_transport(delta): position += transport_direction * transport_speed * delta func spawn_arrow(): - Game.play_sound(Game.a_shoot,Game.ac_jump) + Audio.play_sound(Audio.a_shoot,Audio.ac_jump) var arrow = ArrowProjectile.instance() arrow.global_position = Vector2( global_position.x + arrowpos.x * sprite.scale.x, @@ -231,7 +231,7 @@ func check_jump(): if Input.is_action_just_pressed("jump"): #Detach ladder if current_state == State.CLIMB: - Game.ac_climb.set_stream(null) # stop climb sound + Audio.ac_climb.set_stream(null) # stop climb sound position.x -= sprite.scale.x * 3 else: dust_particles.restart() @@ -242,7 +242,7 @@ func check_jump(): velocity.y = 0 jump_pressure = 0 current_state = State.JUMP - Game.play_sound(Game.a_jump,Game.ac_jump) + Audio.play_sound(Audio.a_jump,Audio.ac_jump) anims.play("jump") velocity.y = -jump_force move(walk_speed,0,true) @@ -251,7 +251,7 @@ func check_double_jump(): if is_on_floor(): check_jump() if Input.is_action_just_pressed("jump") && can_doublejump: - Game.play_sound(Game.a_doublejump,Game.ac_jump) + Audio.play_sound(Audio.a_doublejump,Audio.ac_jump) can_doublejump = false velocity.y = -doublejump_force anims.play("doublejump") @@ -300,7 +300,7 @@ func exit_transport(): func die(): if can_die: - Game.ac_climb.set_stream(null) # stop climbing sound\ + Audio.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 @@ -319,11 +319,11 @@ func die(): new_particles.lifetime = 0.45 new_particles.speed_scale = 1.5 current_state = State.INACTIVE # Set to state where player is not controllable - Game.play_sound(Game.a_gover, Game.ac_die) + Audio.play_sound(Audio.a_gover, Audio.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.stream_paused = true + Audio.ac_music.stream_paused = true yield(time_tween, "finished") #Resume from freeze frame yield(get_tree().create_timer(1.0 * 0.1), "timeout") Game.call_deferred("restart_level") @@ -331,7 +331,7 @@ func die(): #Die Game.lives -= 1 Game.deaths += 1 - Game.play_sound(Game.a_die, Game.ac_die) + Audio.play_sound(Audio.a_die, Audio.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: diff --git a/project.godot b/project.godot index ef52571..5093992 100644 --- a/project.godot +++ b/project.godot @@ -26,10 +26,11 @@ config/icon="res://icon.png" [autoload] -Game="*res://autoloads/game.tscn" -Debug="*res://autoloads/debug.tscn" +Game="*res://autoloads/game.gd" +Audio="*res://autoloads/audio.tscn" LevelData="*res://autoloads/level_data.tscn" Save="*res://autoloads/save.gd" +Debug="*res://autoloads/debug.tscn" [display]