diff --git a/objects/npc/msx.gd b/objects/npc/msx.gd index dd3d1f2..0e4bfe8 100644 --- a/objects/npc/msx.gd +++ b/objects/npc/msx.gd @@ -2,10 +2,13 @@ extends KinematicBody2D var velocity = Vector2.ZERO var is_moving = false +var is_holding_shard = true onready var death_particles = $DeathSplatter onready var sprite = $Sprite onready var anims = $AnimationPlayer onready var raycast = $RayCast2D +onready var shard_position = $Position2D +const shard = preload("res://objects/collectibles/shard.tscn") func _ready(): raycast.add_exception($Area2D) @@ -21,6 +24,18 @@ func _physics_process(delta): anims.play("idle") else: anims.play("walk") + #Stop at the end of path and give shard + if position.x <= 80: + Debug.print(Game.shards_collected) + is_moving = false + velocity.x = 0 + if is_holding_shard: + var ShardInstance = shard.instance() + ShardInstance.global_position = Vector2(shard_position.global_position.x,shard_position.global_position.y) + ShardInstance.number = 1 + get_owner().add_child(ShardInstance) + is_holding_shard = false + func switch_action(): is_moving = true diff --git a/objects/npc/msx.tscn b/objects/npc/msx.tscn index 7f1cf93..b79e23b 100644 --- a/objects/npc/msx.tscn +++ b/objects/npc/msx.tscn @@ -9,7 +9,7 @@ [ext_resource path="res://graphics/player/sg_stab.png" type="Texture" id=7] [ext_resource path="res://graphics/player/sg_shoot_grounded.png" type="Texture" id=8] [ext_resource path="res://graphics/player/sword_stab.png" type="Texture" id=9] -[ext_resource path="res://graphics/player/jump.png" type="Texture" id=10] +[ext_resource path="res://graphics/player/sg_jump.png" type="Texture" id=10] [ext_resource path="res://shaders/recolor_border.shader" type="Shader" id=11] [ext_resource path="res://scripts/snap_sprite.gd" type="Script" id=12] [ext_resource path="res://objects/npc/msx.gd" type="Script" id=13] @@ -699,3 +699,9 @@ enabled = true cast_to = Vector2( 32, 0 ) collision_mask = 3 collide_with_areas = true + +[node name="Position2D" type="Position2D" parent="."] +position = Vector2( 17, 2 ) +__meta__ = { +"_gizmo_extents_": 0.0 +}