1 changed files with 0 additions and 55 deletions
			
			
		@ -1,55 +0,0 @@
				@@ -1,55 +0,0 @@
					 | 
				
			||||
extends KinematicBody2D | 
				
			||||
 | 
				
			||||
 | 
				
			||||
# Declare member variables here. Examples: | 
				
			||||
# var a = 2 | 
				
			||||
# var b = "text" | 
				
			||||
 | 
				
			||||
 | 
				
			||||
# Called when the node enters the scene tree for the first time. | 
				
			||||
var moveSpeed : int = 180 | 
				
			||||
var vel = Vector2() | 
				
			||||
var facingDir = Vector2() | 
				
			||||
onready var rayCast = $RayCast2D | 
				
			||||
onready var anim = $AnimatedSprite | 
				
			||||
 | 
				
			||||
func _ready(): | 
				
			||||
	pass | 
				
			||||
 | 
				
			||||
func _physics_process(delta): | 
				
			||||
	handle_interactions() | 
				
			||||
	handle_movements() | 
				
			||||
 | 
				
			||||
func handle_interactions(): | 
				
			||||
	if Input.is_action_just_pressed("ui_accept"): | 
				
			||||
		for body in $Area2D.get_overlapping_areas(): | 
				
			||||
			if body.has_method("show_dialogue"): | 
				
			||||
				body.show_dialogue() | 
				
			||||
				return | 
				
			||||
 | 
				
			||||
func handle_movements(): | 
				
			||||
	vel = Vector2(-1, 0) | 
				
			||||
   | 
				
			||||
	# inputs | 
				
			||||
	if Input.is_action_pressed("move_up"): | 
				
			||||
		vel.y = -1 | 
				
			||||
		facingDir = Vector2(-1, -1) | 
				
			||||
	if Input.is_action_pressed("move_down"): | 
				
			||||
		vel.y = 1 | 
				
			||||
		facingDir = Vector2(-1, 1) | 
				
			||||
	if Input.is_action_pressed("move_left"): | 
				
			||||
		vel.x = -1 | 
				
			||||
		facingDir = Vector2(-1, 0) | 
				
			||||
   | 
				
			||||
	# move the player | 
				
			||||
	move_and_slide(vel * moveSpeed, Vector2.ZERO) | 
				
			||||
	manage_animations() | 
				
			||||
 | 
				
			||||
func play_animation (anim_name): | 
				
			||||
	if anim.animation != anim_name: | 
				
			||||
		anim.play(anim_name) | 
				
			||||
 | 
				
			||||
func manage_animations (): | 
				
			||||
	if vel.x < 0: | 
				
			||||
		play_animation("MoveLeft") | 
				
			||||
 | 
				
			||||
					Loading…
					
					
				
		Reference in new issue