Compare commits

..

2 Commits

Author SHA1 Message Date
Luna Brovchuk a7c0c45486 Merge branch 'main' of http://meowo.cc:3000/meowo/LD54 2023-10-01 15:53:43 +02:00
Luna Brovchuk 6f9c058b93 Make Line Dashed 2023-10-01 15:53:39 +02:00
4 changed files with 29 additions and 4 deletions

View File

@ -4,7 +4,7 @@
[ext_resource path="res://src/models/enemies/bat/bat.gd" type="Script" id=2] [ext_resource path="res://src/models/enemies/bat/bat.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1] [sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 3.5, 3 ) extents = Vector2( 4, 3 )
[sub_resource type="RectangleShape2D" id=2] [sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 6, 4 ) extents = Vector2( 6, 4 )
@ -19,7 +19,7 @@ script = ExtResource( 2 )
use_parent_material = true use_parent_material = true
frames = ExtResource( 1 ) frames = ExtResource( 1 )
animation = "idle" animation = "idle"
frame = 3 frame = 1
playing = true playing = true
centered = false centered = false

View File

@ -4,7 +4,7 @@
[ext_resource path="res://src/models/enemies/ghost/ghost.gd" type="Script" id=2] [ext_resource path="res://src/models/enemies/ghost/ghost.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1] [sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 5.5, 5.5 ) extents = Vector2( 7, 9 )
[node name="Ghost" type="KinematicBody2D" groups=["enemy"]] [node name="Ghost" type="KinematicBody2D" groups=["enemy"]]
z_index = 2 z_index = 2

View File

@ -13,6 +13,30 @@ var speed = 100
var draw_node var draw_node
var bullet 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): func _process(_delta):
if Input.is_action_just_pressed("shoot"): if Input.is_action_just_pressed("shoot"):
_shoot() _shoot()
@ -50,7 +74,7 @@ func _shoot():
func _draw(): func _draw():
if target != null: if target != null:
var dist2enemy = position.distance_to(target.global_position) 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): func _physics_process(delta):
get_input() get_input()

View File

@ -0,0 +1 @@
extends Node