accroche: s'accrocher requiert une action
Avant la princesse se colait au mur quoi qu'il arrive. Ce n'était pas très agréable dans le gameplay. La raison principale, un soudain et régulier changement de sprite. Plutôt que de tweaker ça, j'ai décidé de choisir l'approche façon céleste où il faut enfoncer une touche pour s'accrocher au mur. La touche en question c'est control sur clavier Et l1/l2 sur la manette
This commit is contained in:
18
princesse.gd
18
princesse.gd
@@ -50,6 +50,7 @@ var jump_key_counter : int = 0
|
||||
var falling_step : int = -1
|
||||
|
||||
var pressing_wall = false
|
||||
var grab_wall = false
|
||||
|
||||
|
||||
const PLATFORM_LAYER = 1 << (5 - 1) # collision layer 5
|
||||
@@ -108,9 +109,10 @@ func fall() -> int:
|
||||
falling_step = -1
|
||||
return velocity.y
|
||||
else:
|
||||
falling_step = min(falling_step+1, FALL_SPEED_TABLE.size()-1)
|
||||
if pressing_wall:
|
||||
falling_step = min(falling_step, FALL_SPEED_TABLE.size()-5)
|
||||
if grab_wall:
|
||||
falling_step = max(falling_step-1, 1)
|
||||
else:
|
||||
falling_step = min(falling_step+1, FALL_SPEED_TABLE.size()-1)
|
||||
return FALL_SPEED_TABLE[falling_step] * FALLING_SPEED
|
||||
|
||||
|
||||
@@ -137,6 +139,9 @@ func end_jump():
|
||||
jump_key_counter = 0
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
pressing_wall = is_on_wall_only()
|
||||
grab_wall = pressing_wall and Input.is_action_pressed("grab" + action_suffix)
|
||||
|
||||
if Input.is_action_just_pressed("jump" + action_suffix):
|
||||
if is_on_floor():
|
||||
if not jumping:
|
||||
@@ -163,7 +168,6 @@ func _physics_process(delta: float) -> void:
|
||||
"move_right" + action_suffix
|
||||
)
|
||||
|
||||
pressing_wall = is_on_wall_only() and not is_zero_approx(axis)
|
||||
|
||||
if not is_zero_approx(axis):
|
||||
if axis < 0:
|
||||
@@ -180,10 +184,10 @@ func _physics_process(delta: float) -> void:
|
||||
else:
|
||||
animation.scale.x = -1.0
|
||||
|
||||
if pressing_wall and not jumping:
|
||||
if grab_wall and not jumping:
|
||||
animation.scale.x *= -1
|
||||
|
||||
floor_stop_on_slope = not platform_detector.is_colliding()
|
||||
#floor_stop_on_slope = not platform_detector.is_colliding()
|
||||
var collision = move_and_slide()
|
||||
if collision:
|
||||
var collider = get_last_slide_collision().get_collider()
|
||||
@@ -211,7 +215,7 @@ func get_new_animation(is_shooting := false) -> String:
|
||||
animation_new = "idle"
|
||||
else:
|
||||
if velocity.y > 0.0:
|
||||
if pressing_wall:
|
||||
if grab_wall:
|
||||
animation_new = "wall_stick"
|
||||
else:
|
||||
if walking_step > 0:
|
||||
|
||||
@@ -44,6 +44,13 @@ jump={
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":true,"script":null)
|
||||
]
|
||||
}
|
||||
grab={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194326,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":9,"pressure":0.0,"pressed":true,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":10,"pressure":0.0,"pressed":true,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[layer_names]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user