bcp de characters

This commit is contained in:
E250429F
2026-09-03 09:43:13 +02:00
parent a061aff066
commit 025a866eef
1175 changed files with 85837 additions and 286 deletions
+108 -17
View File
@@ -1,8 +1,7 @@
extends CharacterBody3D
var SPEED = 20
var JUMP_VELOCITY = 8
var SPEED = 7
@onready var arm: Node3D = $arm
@onready var model: Node3D = $model
@@ -24,16 +23,24 @@ var footstep_sounds: Array[AudioStream] = [
preload("res://assets/audio/footsteps/dirt_step_4.wav")
]
var footstep_timer: float = 0.0
const FOOTSTEP_DELAY: float = 0.15
const FOOTSTEP_DELAY: float = 0.24
@onready var pause: Control = $pause
# animations
@onready var anim_player: AnimationPlayer = $character/AnimationPlayer
# boulangerie MOULIN
var item : int = 0 # 0 rien, 1 abricot, 2 citron, 3 mirtylle
var topping : int = 0 # 0 rien, 1 meringue, 2 croisillon
@onready var area_tarte: Area3D = $Area3DTarte
@onready var tarte_holded: StaticBody3D = $tarte
var can_play : bool = true
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
label_tuto.text = Sauvegarde.get_text("tuto_1")
if third_person:
camera.make_current()
@@ -48,28 +55,70 @@ func _input(_event):
else:
pause.resume()
func _process(delta: float) -> void:
if Input.is_action_just_pressed("give"):
var objects_in_front = area_tarte.get_overlapping_bodies()
# check if there is a client in the box
for obj in objects_in_front:
if obj.is_in_group("client"):
if obj.get_parent().ready_to_take_pie:
var l = get_conversion_pie()
obj.get_parent().give_item( l[0], l[1] )
reset_pie()
return
# no client was found
for obj in objects_in_front:
if obj.is_in_group("tarte"):
set_item_topping( obj.item, obj.topping, obj.reset)
return
func _physics_process(delta: float) -> void:
# Add the gravity.
#print("global position; ", global_position)
if not is_on_floor():
velocity += get_gravity() * delta
# Handle jump
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY
# Get the input direction and handle the movement/deceleration.
var input_dir := Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED
#var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
#if direction:
#velocity.x = direction.x * SPEED
#velocity.z = direction.z * SPEED
#else:
#velocity.x = move_toward(velocity.x, 0, SPEED)
#velocity.z = move_toward(velocity.z, 0, SPEED)
if input_dir.length() < 0.1:
input_dir = Vector2.ZERO
var direction = (spring_arm.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
# On ne déplace et on ne tourne le joueur que si une vraie direction est donnée
if can_play:
if direction.length() > 0.1:
anim_player.play("RootAction_001", -1, 3)
velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED
# 2. CORRECTION DE LA ROTATION INVERSÉE
# Si le joueur tourne toujours à l'envers, enlève les signes "-" devant velocity.x et velocity.z
var target_angle = atan2(-velocity.x, -velocity.z)
# Le 10.0 est bien, il permet au modèle 3D de se tourner vite sans faire de coup sec.
rotation.y = lerp_angle(rotation.y, target_angle, 10.0 * delta)
else:
anim_player.stop()
# Le joueur s'arrête doucement
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)
anim_player.stop()
# footstep sounds
if is_on_floor() and Vector2(velocity.x, velocity.z).length() > 0.5:
if is_on_floor() and Vector2(velocity.x, velocity.z).length() > 0.5 and can_play:
footstep_timer -= delta
if footstep_timer <= 0.0:
play_random_footstep()
@@ -80,10 +129,52 @@ func _physics_process(delta: float) -> void:
if can_play:
move_and_slide()
# PARTIE BOULANGERIE MOULIN
func set_item_topping( new_item : int, new_topping : int, reset:bool ):
if reset:
tarte_holded.visible = false
else:
tarte_holded.visible = true
if new_item != 0 or reset:
item = new_item
tarte_holded.item = new_item
if new_topping != 0 or reset:
topping = new_topping
tarte_holded.topping = topping
tarte_holded.setup_color_and_name()
func reset_pie():
item = 0
tarte_holded.item = 0
topping = 0
tarte_holded.topping = 0
tarte_holded.visible = false
func get_conversion_pie():
var possible_pies = [Sauvegarde.get_text("pie1"), Sauvegarde.get_text("pie2"), Sauvegarde.get_text("pie3")]
var possible_toppings = [Sauvegarde.get_text("topping1"), Sauvegarde.get_text("topping2"), "Aucun"]
if item != 0:
return [ possible_pies[ item - 1 ], possible_toppings[ topping -1 ] ]
return [ "", possible_toppings[ topping -1 ] ]
func play_random_footstep( pitch=[0.85, 1.15] ) -> void:
var random_index = randi() % footstep_sounds.size()
audio_footstep.stream = footstep_sounds[random_index]
audio_footstep.pitch_scale = randf_range( pitch[0], pitch[1] )
audio_footstep.play()
func set_dialog_mode( npc_pos=Vector3.ZERO, force_pos=-1):
can_play = !can_play
spring_arm.set_dialog_mode( npc_pos, force_pos )
func set_default_cam():
if third_person:
camera.set_current(true)
else:
camera_pov.set_current(true)