Pickup flute
This commit is contained in:
parent
204848fcf1
commit
142500fdd8
9 changed files with 181 additions and 39 deletions
|
@ -21,11 +21,15 @@ var flute_cooldown = 0.5
|
|||
var tambour_cooldown = 3.0
|
||||
var lyre_cooldown = 1
|
||||
|
||||
var slot = []
|
||||
var slotstr = []
|
||||
var instrument_list = [
|
||||
"",
|
||||
""
|
||||
]
|
||||
|
||||
var vie = 10
|
||||
|
||||
signal instrument_switch
|
||||
|
||||
func _ready() -> void:
|
||||
flute = load("res://scripts/Instrument/Flute.gd").new()
|
||||
flute.set_scene_parent(get_tree().get_root())
|
||||
|
@ -36,31 +40,10 @@ func _ready() -> void:
|
|||
lyre = load("res://scripts/Instrument/Lyre.gd").new()
|
||||
lyre.set_scene_parent(get_tree().get_root())
|
||||
|
||||
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
move_and_slide()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
var direction : Vector2 = Vector2.ZERO
|
||||
direction.x = Input.get_action_raw_strength("BOUGER_DROITE") - Input.get_action_raw_strength("BOUGER_GAUCHE")
|
||||
direction.y = Input.get_action_raw_strength("BOUGER_BAS") - Input.get_action_raw_strength("BOUGER_HAUT")
|
||||
|
||||
if direction != Vector2.ZERO:
|
||||
if direction == previous_direction:
|
||||
if direction.x != 0 and direction.y != 0:
|
||||
boost_speed = min(boost_speed + acceleration / 16, (max_boost_speed - move_speed) / 8)
|
||||
else:
|
||||
boost_speed = min(boost_speed + acceleration, max_boost_speed - move_speed)
|
||||
else:
|
||||
boost_speed = 0
|
||||
|
||||
previous_direction = direction
|
||||
velocity = direction * (move_speed + boost_speed)
|
||||
else:
|
||||
velocity = Vector2.ZERO
|
||||
|
||||
func play_music(delta : float):
|
||||
var direction_balle = Vector2.ZERO
|
||||
var angle = 0
|
||||
var angle_lyre = 0
|
||||
|
@ -81,7 +64,7 @@ func _process(delta: float) -> void:
|
|||
direction_balle = Vector2(-1, 0)
|
||||
angle = 90
|
||||
angle_lyre = 180
|
||||
|
||||
|
||||
if flute_timer > 0:
|
||||
flute_timer -= delta
|
||||
|
||||
|
@ -90,19 +73,46 @@ func _process(delta: float) -> void:
|
|||
|
||||
if lyre_timer > 0:
|
||||
lyre_timer -= delta
|
||||
|
||||
if flute and flute_timer <= 0.0 and direction_balle != Vector2.ZERO:
|
||||
|
||||
if instrument_list.has("flute") and flute_timer <= 0.0 and direction_balle != Vector2.ZERO:
|
||||
flute.jouer_melodie(position, direction_balle, angle)
|
||||
flute_timer = flute_cooldown
|
||||
|
||||
if tambour and tambour_timer <= 0.0 and direction_balle != Vector2.ZERO:
|
||||
if instrument_list.has("tambour") and tambour_timer <= 0.0 and direction_balle != Vector2.ZERO:
|
||||
tambour.jouer_melodie(position)
|
||||
tambour_timer = tambour_cooldown
|
||||
|
||||
if lyre and lyre_timer <= 0.0 and direction_balle != Vector2.ZERO:
|
||||
if instrument_list.has("lyre") and lyre_timer <= 0.0 and direction_balle != Vector2.ZERO :
|
||||
lyre.jouer_melodie(position, direction_balle, angle_lyre)
|
||||
lyre_timer = lyre_cooldown
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
var direction : Vector2 = Vector2.ZERO
|
||||
direction.x = Input.get_action_raw_strength("BOUGER_DROITE") - Input.get_action_raw_strength("BOUGER_GAUCHE")
|
||||
direction.y = Input.get_action_raw_strength("BOUGER_BAS") - Input.get_action_raw_strength("BOUGER_HAUT")
|
||||
|
||||
if direction != Vector2.ZERO:
|
||||
if direction == previous_direction:
|
||||
if direction.x != 0 and direction.y != 0:
|
||||
boost_speed = min(boost_speed + acceleration / 16, (max_boost_speed - move_speed) / 8)
|
||||
else:
|
||||
boost_speed = min(boost_speed + acceleration, max_boost_speed - move_speed)
|
||||
else:
|
||||
boost_speed = 0
|
||||
|
||||
previous_direction = direction
|
||||
velocity = direction * (move_speed + boost_speed)
|
||||
else:
|
||||
velocity = Vector2.ZERO
|
||||
|
||||
play_music(delta)
|
||||
|
||||
func pick_up(instrument : String) :
|
||||
if len(instrument_list) < 2 :
|
||||
instrument_list.append(instrument)
|
||||
else :
|
||||
instrument_list[0] = instrument_list[1]
|
||||
instrument_list[1] = instrument
|
||||
instrument_switch.emit()
|
||||
|
||||
func take_damage(dmg : int) :
|
||||
vie -= dmg
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue