chairs
This commit is contained in:
@@ -12,6 +12,7 @@ const RAYCAST_RAGE: int = 32
|
||||
@export var tilemap: TileMapLayer
|
||||
var tilesize: int = 32
|
||||
var position_limit_rect: Rect2
|
||||
const STILL_POSITIONS: Array[String] = ["sit", "hand_down", "hand_side", "hand_up"]
|
||||
|
||||
func _ready() -> void:
|
||||
EventManager.player = self
|
||||
@@ -36,10 +37,10 @@ func _ready() -> void:
|
||||
func _process(_delta: float) -> void:
|
||||
if Input.is_action_just_pressed("interact") && raycast.is_colliding() && raycast.get_collider() is Interactable:
|
||||
var interactable: Interactable = raycast.get_collider()
|
||||
interactable.interact()
|
||||
interactable.interact(self)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if EventManager.player_free:
|
||||
if !STILL_POSITIONS.has(animated_sprite.animation) && EventManager.player_free:
|
||||
var input := Input.get_vector("move_left", "move_right", "move_up", "move_down").normalized()
|
||||
|
||||
var raycast_input := Vector2.ZERO
|
||||
@@ -52,18 +53,18 @@ func _physics_process(delta: float) -> void:
|
||||
|
||||
velocity = input * delta * SPEED * 3
|
||||
|
||||
move_and_slide()
|
||||
position = position.clamp(position_limit_rect.position, position_limit_rect.end)
|
||||
move_and_slide()
|
||||
position = position.clamp(position_limit_rect.position, position_limit_rect.end)
|
||||
|
||||
if velocity.length() != 0:
|
||||
animated_sprite.play()
|
||||
animated_sprite.flip_h = false
|
||||
if abs(velocity.x) > abs(velocity.y):
|
||||
animated_sprite.animation = "side"
|
||||
animated_sprite.flip_h = velocity.x < 0
|
||||
elif velocity.y < 0:
|
||||
animated_sprite.animation = "up"
|
||||
if velocity.length() != 0:
|
||||
animated_sprite.play()
|
||||
animated_sprite.flip_h = false
|
||||
if abs(velocity.x) > abs(velocity.y):
|
||||
animated_sprite.animation = "side"
|
||||
animated_sprite.flip_h = velocity.x < 0
|
||||
elif velocity.y < 0:
|
||||
animated_sprite.animation = "up"
|
||||
else:
|
||||
animated_sprite.animation = "down"
|
||||
else:
|
||||
animated_sprite.animation = "down"
|
||||
else:
|
||||
animated_sprite.stop()
|
||||
animated_sprite.stop()
|
||||
|
||||
Reference in New Issue
Block a user