niveau: les pics tuent
Lorsque la princesse rentre en collision avec un pic, elle meurt et recommence au début du jeu.
This commit is contained in:
16
princesse.gd
16
princesse.gd
@@ -51,6 +51,11 @@ var falling_step : int = -1
|
||||
|
||||
var pressing_wall = false
|
||||
|
||||
|
||||
const PLATFORM_LAYER = 1 << (5 - 1) # collision layer 5
|
||||
const PICS_BLOCK_LAYER = 1 << (6 - 1) # collision layer 6
|
||||
var layer_of_collision = null
|
||||
|
||||
func walk(direction:int) -> int:
|
||||
# Fait marcher le personnage.
|
||||
|
||||
@@ -179,7 +184,16 @@ func _physics_process(delta: float) -> void:
|
||||
animation.scale.x *= -1
|
||||
|
||||
floor_stop_on_slope = not platform_detector.is_colliding()
|
||||
move_and_slide() # Character is colliding
|
||||
var collision = move_and_slide()
|
||||
if collision:
|
||||
var collider = get_last_slide_collision().get_collider()
|
||||
|
||||
if collider is TileMap:
|
||||
var tile_rid = get_last_slide_collision().get_collider_rid()
|
||||
layer_of_collision = PhysicsServer2D.body_get_collision_layer(tile_rid)
|
||||
if layer_of_collision == PICS_BLOCK_LAYER:
|
||||
get_tree(). reload_current_scene()
|
||||
|
||||
|
||||
var anim := get_new_animation(false)
|
||||
if anim != animation.animation:
|
||||
|
||||
Reference in New Issue
Block a user