A dungeon delver roguelike using Pathfinder 2nd edition rules
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Implemented ramp up and ramp down for rotation and fixed bug involving rotation for ramp up and ramp down for movement

+27 -19
+27 -19
camera/camera.gd
··· 22 22 var up_down_released_time: float = 0.0 23 23 var rotate_pressed_time: float = 0.0 24 24 var rotate_released_time: float = 0.0 25 - var last_move_direction: Vector3 = Vector3.ZERO 26 - 27 - @export var move_direction: Vector3 25 + var move_dir: Vector3 = Vector3.ZERO 26 + var move_direction: Vector3 27 + var rotate_direction: float = 0.0 28 28 29 29 func _physics_process(delta: float) -> void: 30 30 if Input.is_action_just_pressed("Right") or Input.is_action_just_pressed("Left"): 31 31 left_right_pressed_time = Time.get_unix_time_from_system() 32 32 left_right_released_time = -1.0 33 + move_dir.x = Input.get_action_strength("Right") - Input.get_action_strength("Left") 33 34 34 35 if Input.is_action_just_released("Right") or Input.is_action_just_released("Left"): 35 36 left_right_released_time = Time.get_unix_time_from_system() 36 - last_move_direction = move_direction 37 37 38 38 if Input.is_action_just_pressed("Up") or Input.is_action_just_pressed("Down"): 39 39 up_down_pressed_time = Time.get_unix_time_from_system() 40 40 up_down_released_time = -1.0 41 + move_dir.z = Input.get_action_strength("Down") - Input.get_action_strength("Up") 41 42 42 43 if Input.is_action_just_released("Up") or Input.is_action_just_released("Down"): 43 44 up_down_released_time = Time.get_unix_time_from_system() 44 - last_move_direction = move_direction 45 45 46 46 if Input.is_action_just_pressed("RotateLeft") or Input.is_action_just_pressed("RotateRight"): 47 47 rotate_pressed_time = Time.get_unix_time_from_system() 48 48 rotate_released_time = -1.0 49 + 50 + if Input.is_action_just_pressed("RotateLeft"): 51 + rotate_direction -= 1.0 52 + 53 + if Input.is_action_just_pressed("RotateRight"): 54 + rotate_direction += 1.0 49 55 50 56 if Input.is_action_just_released("RotateLeft") or Input.is_action_just_released("RotateRight"): 51 57 rotate_released_time = Time.get_unix_time_from_system() ··· 61 67 62 68 move_direction *= move_speed 63 69 70 + var old_rotation: float = global_rotation_degrees.y 71 + move_direction = move_direction.rotated(Vector3.UP, deg_to_rad(old_rotation)) 72 + var changed: bool = false 73 + 64 74 if move_direction.x == 0.0: 65 - if last_move_direction.x > 0.0: 66 - move_direction.x = move_speed * left_right_adsr 67 - elif last_move_direction.x < 0.0: 68 - move_direction.x = move_speed * left_right_adsr * -1.0 75 + move_direction.x = move_speed * left_right_adsr * move_dir.x 76 + changed = true 69 77 70 78 if move_direction.x == 0.0: 71 - last_move_direction.x = 0.0 79 + move_dir.x = 0.0 72 80 73 81 if move_direction.z == 0.0: 74 - if last_move_direction.z > 0.0: 75 - move_direction.z = move_speed * up_down_adsr 76 - elif last_move_direction.z < 0.0: 77 - move_direction.z = move_speed * up_down_adsr * -1.0 82 + move_direction.z = move_speed * up_down_adsr * move_dir.z 83 + changed = true 78 84 79 85 if move_direction.z == 0.0: 80 - last_move_direction.z = 0.0 86 + move_dir.z = 0.0 81 87 82 - var rotate_direction: float = (Input.get_action_strength("RotateRight") - Input.get_action_strength("RotateLeft")) * rotate_adsr 83 - var old_rotation: float = global_rotation_degrees.y 88 + if changed: 89 + move_direction = move_direction.rotated(Vector3.UP, deg_to_rad(old_rotation)) 84 90 85 - move_direction = move_direction.rotated(Vector3.UP, deg_to_rad(old_rotation)) 86 91 global_translate(move_direction) 87 - rotate(Vector3.UP, rotate_direction * rotate_speed) 92 + rotate(Vector3.UP, rotate_direction * rotate_speed * rotate_adsr) 93 + 94 + if rotate_adsr == 0.0: 95 + rotate_direction = 0.0 88 96 89 97 func adsr(attack: float, decay: float, sustain: float, release: float, held: bool, time: float, pressed: float, released: float) -> float: 90 98 var p: float