forked from team-sg/hero-mark-2
All audio stuff moved to audio autoload and removed game.tscn in favor of just game.gd
This commit is contained in:
parent
30cfad6e7e
commit
e1a30188a6
21 changed files with 134 additions and 97 deletions
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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():
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue