added ms.x
This commit is contained in:
parent
2281627223
commit
739eb6e48a
4 changed files with 738 additions and 2 deletions
35
objects/npc/msx.gd
Normal file
35
objects/npc/msx.gd
Normal file
|
@ -0,0 +1,35 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
var velocity = Vector2.ZERO
|
||||
var is_moving = false
|
||||
onready var death_particles = $DeathSplatter
|
||||
onready var sprite = $Sprite
|
||||
onready var anims = $AnimationPlayer
|
||||
onready var raycast = $RayCast2D
|
||||
|
||||
func _ready():
|
||||
raycast.add_exception($Area2D)
|
||||
|
||||
func _physics_process(delta):
|
||||
if is_moving: velocity.x = -50
|
||||
#Stop when see something
|
||||
if raycast.is_colliding(): velocity.x = 0
|
||||
velocity.y += 128 * delta
|
||||
velocity = move_and_slide_with_snap(velocity, Vector2.DOWN, Vector2.UP, true)
|
||||
#Anims
|
||||
if velocity.x == 0:
|
||||
anims.play("idle")
|
||||
else:
|
||||
anims.play("walk")
|
||||
|
||||
func switch_action():
|
||||
is_moving = true
|
||||
|
||||
func die():
|
||||
#Create particles
|
||||
remove_child(death_particles)
|
||||
get_parent().add_child(death_particles)
|
||||
death_particles.global_position = global_position
|
||||
death_particles.emitting = true
|
||||
Audio.play_sound(Audio.a_die,Audio.ac_die)
|
||||
queue_free()
|
Loading…
Add table
Add a link
Reference in a new issue