diff --git a/src/models/enemies/bat/Bat.tscn b/src/models/enemies/bat/Bat.tscn index a6a385d..7425150 100644 --- a/src/models/enemies/bat/Bat.tscn +++ b/src/models/enemies/bat/Bat.tscn @@ -4,7 +4,7 @@ [ext_resource path="res://src/models/enemies/bat/bat.gd" type="Script" id=2] [sub_resource type="RectangleShape2D" id=1] -extents = Vector2( 3.5, 3 ) +extents = Vector2( 4, 3 ) [sub_resource type="RectangleShape2D" id=2] extents = Vector2( 6, 4 ) @@ -19,7 +19,7 @@ script = ExtResource( 2 ) use_parent_material = true frames = ExtResource( 1 ) animation = "idle" -frame = 3 +frame = 1 playing = true centered = false diff --git a/src/models/enemies/ghost/Ghost.tscn b/src/models/enemies/ghost/Ghost.tscn index 6d47d9f..29d8b9f 100644 --- a/src/models/enemies/ghost/Ghost.tscn +++ b/src/models/enemies/ghost/Ghost.tscn @@ -4,7 +4,7 @@ [ext_resource path="res://src/models/enemies/ghost/ghost.gd" type="Script" id=2] [sub_resource type="RectangleShape2D" id=1] -extents = Vector2( 5.5, 5.5 ) +extents = Vector2( 7, 9 ) [node name="Ghost" type="KinematicBody2D" groups=["enemy"]] z_index = 2 diff --git a/src/models/player/player.gd b/src/models/player/player.gd index c974b62..788a7d2 100644 --- a/src/models/player/player.gd +++ b/src/models/player/player.gd @@ -13,6 +13,30 @@ var speed = 100 var draw_node var bullet +func draw_dashed_line(from, to, color, width, dash_length = 3, cap_end = false, antialiased = false): + var length = (to - from).length() + var normal = (to - from).normalized() + var dash_step = normal * dash_length + + if length < dash_length: + draw_line(from, to, color, width, antialiased) + return + + else: + var draw_flag = true + var segment_start = from + var steps = length/dash_length + for start_length in range(0, steps + 1): + var segment_end = segment_start + dash_step + if draw_flag: + draw_line(segment_start, segment_end, color, width, antialiased) + + segment_start = segment_end + draw_flag = !draw_flag + + if cap_end: + draw_line(segment_start, to, color, width, antialiased) + func _process(_delta): if Input.is_action_just_pressed("shoot"): _shoot() @@ -50,7 +74,7 @@ func _shoot(): func _draw(): if target != null: var dist2enemy = position.distance_to(target.global_position) - draw_line(Vector2(12, 8), target.global_position - self.global_position + Vector2(8, 7), Color("ffde00")) + draw_dashed_line(Vector2(12, 8), target.global_position - self.global_position + Vector2(8, 7), Color("ffde00"), 1) func _physics_process(delta): get_input() diff --git a/src/scripts/draw_dashed_line.gd b/src/scripts/draw_dashed_line.gd new file mode 100644 index 0000000..61510e1 --- /dev/null +++ b/src/scripts/draw_dashed_line.gd @@ -0,0 +1 @@ +extends Node