Compare commits
2 Commits
547e0f449e
...
a7c0c45486
Author | SHA1 | Date |
---|---|---|
Luna Brovchuk | a7c0c45486 | |
Luna Brovchuk | 6f9c058b93 |
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
extends Node
|
Loading…
Reference in New Issue