fix post-proto

* ajout d'un fondu de musique au changement de phase
* résolution de bugs en tout genre
This commit is contained in:
2025-11-14 16:43:52 +01:00
parent d3ea21e212
commit dbe8f03531
37 changed files with 411 additions and 147 deletions

View File

@@ -1,6 +1,7 @@
extends CharacterBody2D
class_name Player
const ACTION_AREA_UPDATE_TIME=0.05 # When creating an action_zone, we make sure that the area setup correctly by waiting a little
const MAX_REACH = 100
const HOLDING_ITEM_SPRITE_SIZE = 20.
@@ -12,9 +13,8 @@ var planet : Planet :
get(): return terrain if terrain is Planet else null
@export var speed = 350
var has_just_received_instruction : bool = false # pour récupérer les zones dans les action_area, une frame doit être passée depuis la création de la zone
var data : PlayerData
var last_action_area_movement_timer : float = 100.
var controlling_player : bool = true :
set(v):
@@ -54,18 +54,20 @@ func _pass_day():
func _end_pass_day():
controlling_player = true
func _process(_delta):
func _process(delta):
last_action_area_movement_timer += delta
if controlling_player:
var old_velocity=velocity
calculate_direction()
if instruction and instruction.can_be_done(self) and not has_just_received_instruction:
if (
last_action_area_movement_timer >= ACTION_AREA_UPDATE_TIME
and instruction and instruction.can_be_done(self)
):
instruction.do(self)
instruction = null
move_preview_zone(get_global_mouse_position())
has_just_received_instruction = false
# Sound
if old_velocity.length()==0 and velocity.length()!=0:
play_sfx("move")
@@ -94,7 +96,7 @@ func calculate_direction():
if input_direction.length() != 0:
instruction = null
if instruction:
if instruction and instruction.position.distance_to(global_position) > (MAX_REACH - 1.):
input_direction = self.global_position.direction_to(instruction.position)
velocity = input_direction * speed
@@ -112,7 +114,6 @@ func can_interact(interactable : Interactable):
func try_interact(interactable : Interactable):
if interactable:
has_just_received_instruction = true
instruction = InteractableInstruction.new(
interactable
)
@@ -148,7 +149,6 @@ func delete_item(item: Item):
data.inventory.remove_item(item)
func try_use_item(item : Item, use_position : Vector2):
has_just_received_instruction = true
setup_action_zone(use_position, item)
instruction = ItemActionInstruction.new(
use_position,
@@ -224,6 +224,7 @@ func setup_action_zone(zone_position : Vector2, item: Item) -> ActionZone:
action_zone.destroy()
action_zone = generate_action_zone(item)
action_zone.move_to_position(zone_position)
last_action_area_movement_timer = 0.
return action_zone
func move_preview_zone(zone_position : Vector2):
@@ -251,7 +252,7 @@ class Instruction:
position = _pos
func can_be_done(player : Player):
return player.global_position.distance_to(position) < 10
return player.global_position.distance_to(position) < player.MAX_REACH
func do(_player : Player):
pass
@@ -267,7 +268,9 @@ class ItemActionInstruction extends Instruction:
item = _item
func can_be_done(player : Player):
return player.global_position.distance_to(position) < player.MAX_REACH
return (
player.global_position.distance_to(position) < player.MAX_REACH
)
func do(player : Player):
player.use_item(item)