diff --git a/graphics/enemy/cop/cop_walk.png b/graphics/enemy/cop/cop_walk.png index 39d05c1..48f5750 100644 Binary files a/graphics/enemy/cop/cop_walk.png and b/graphics/enemy/cop/cop_walk.png differ diff --git a/objects/enemy/cop.gd b/objects/enemy/cop.gd index a913f98..3fd13f3 100644 --- a/objects/enemy/cop.gd +++ b/objects/enemy/cop.gd @@ -5,7 +5,7 @@ export var walk_speed = 25.0 export var left_boundary = 0.0 setget _set_left_boundary export var right_boundary = 0.0 setget _set_right_boundary export var direction = 1.0 -export var idle_turns = 4 +export var idle_turns = 0 export var turn_time = 0.5 export var shoot_time = 1.0 @@ -76,12 +76,23 @@ func _do_turn(): get_tree().create_timer(turn_time, false).connect("timeout", self, "_do_turn") return sprite.play("idle") + # still pause with zero "turns" + if idle_turns <= 0: + # set turns to -1 to stop walking + turns = -1 + # wait for turn_tie + yield(get_tree().create_timer(turn_time, false), "timeout") + sprite.scale.x *= -1.0 + # wait a bit after turning + get_tree().create_timer(turn_time, false).connect("timeout", self, "set", ["turns", 0]) + return sprite.scale.x *= -1.0 if turns < idle_turns * 2: turns += 1 get_tree().create_timer(turn_time, false).connect("timeout", self, "_do_turn") else: - turns = 0 + get_tree().create_timer(turn_time, false).connect("timeout", self, "set", ["turns", 0]) +# turns = 0 func _stop_shoot(): shooting = false @@ -95,7 +106,7 @@ func _stop_shoot(): func _draw(): if Engine.editor_hint: var left = -left_boundary * 8.0 - var right = right_boundary * 8.0 + var right = right_boundary * 8.0 + 8.0 draw_line( Vector2(left, 0.0), Vector2(right, 0.0), diff --git a/objects/enemy/cop.tscn b/objects/enemy/cop.tscn index c715083..2a776da 100644 --- a/objects/enemy/cop.tscn +++ b/objects/enemy/cop.tscn @@ -62,13 +62,13 @@ colors = PoolColorArray( 1, 1, 1, 1, 1, 1, 0.290196, 1 ) [node name="Cop" type="Node2D"] script = ExtResource( 1 ) -idle_turns = 2 [node name="AnimatedSprite" type="AnimatedSprite" parent="."] +show_behind_parent = true material = SubResource( 7 ) position = Vector2( 5, -2 ) frames = SubResource( 6 ) -animation = "shoot" +animation = "idle" playing = true [node name="ShootPosition" type="Position2D" parent="AnimatedSprite"]