Working towards attacking and where to put optional states.

This commit is contained in:
Nitsud Yarg 2024-06-02 11:11:26 -07:00
parent 50c1c9db51
commit 3854b2ae32
5 changed files with 21 additions and 3 deletions

View File

@ -159,7 +159,7 @@ __meta__ = {
}
[node name="Player" parent="." instance=ExtResource( 2 )]
position = Vector2( 642, 62 )
position = Vector2( 137, 54 )
[node name="CameraControl" type="Position2D" parent="."]
process_priority = 1

View File

@ -117,7 +117,7 @@ actor_type = "Enemy"
position = Vector2( 11, -7 )
frames = SubResource( 20 )
animation = "idle"
frame = 1
frame = 0
__meta__ = {
"_aseprite_wizard_config_": {
"layer": "",
@ -165,7 +165,9 @@ cast_to = Vector2( 0, 17 )
collide_with_areas = true
[node name="PlayerDetection" type="RayCast2D" parent="." index="7"]
enabled = true
cast_to = Vector2( 21, 0 )
collision_mask = 2
[node name="Hitbox_Component" type="Area2D" parent="." index="8"]

View File

@ -2,14 +2,23 @@ extends MovementComponent
onready var idle_timeout = $IdleTimeout
onready var edge_detector:RayCast2D = $"../EdgeDetection"
onready var player_detector:RayCast2D = $"../PlayerDetection"
var flip_flop = false
var wants_to_attack = false
func process_physics(delta):
if current_movement_state == "move" and edge_detector.is_colliding() == false:
#print(owner.name, "uh oh gonna fall!")
stop()
return
if player_detector.is_colliding():
print(owner.name, " wants to attack")
stop()
wants_to_attack = true
return
else:
wants_to_attack = false
func process(delta):
if current_movement_state == "idle" and idle_timeout.time_left == 0:
@ -29,3 +38,6 @@ func process(delta):
idle_timeout.start()
stop()
return
func wants_shoot() -> bool:
return wants_to_attack

View File

@ -6,6 +6,10 @@ export var debug_component: bool = false
onready var desired_movement_vector: Vector2 = Vector2(0,0)
var current_movement_state:String
# Since animactor state machine can actually view properties from this type
# I'm thinking about moving the velocity tracker in here instead of player.
var velocity = Vector2(0,0)
#Can't use floats here, switched to constants.
#enum directions {UP = -1, DOWN = 1, LEFT, RIGHT}

View File

@ -50,7 +50,7 @@ script = ExtResource( 8 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = SubResource( 75 )
frame = 3
frame = 1
playing = true
flip_h = true
__meta__ = {