Compare commits
2 Commits
d010f9a17f
...
d67d1568ee
Author | SHA1 | Date |
---|---|---|
Luna Brovchuk | d67d1568ee | |
Luna Brovchuk | 8592cc29cb |
|
@ -15,5 +15,5 @@ void fragment(){
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
shader = SubResource( 3 )
|
shader = SubResource( 3 )
|
||||||
shader_param/active = false
|
shader_param/active = true
|
||||||
shader_param/color = Color( 1, 1, 1, 1 )
|
shader_param/color = Color( 1, 1, 1, 0 )
|
||||||
|
|
|
@ -2,7 +2,11 @@ extends KinematicBody2D
|
||||||
|
|
||||||
var speed = 128
|
var speed = 128
|
||||||
var velocity = Vector2.ZERO
|
var velocity = Vector2.ZERO
|
||||||
|
var target
|
||||||
|
|
||||||
func _physics_process(_delta):
|
func _physics_process(delta):
|
||||||
velocity.x = speed
|
if target != null:
|
||||||
move_and_slide(velocity)
|
var target_texture = target.get_node("Sprite").frames.get_frame("idle", 0)
|
||||||
|
var target_sprite_size = Vector2(target_texture.get_width(), target_texture.get_width())
|
||||||
|
var target_center = target.global_position + (target_sprite_size / 2)
|
||||||
|
self.global_position = self.global_position.move_toward(target_center, delta * speed)
|
||||||
|
|
|
@ -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 = 1
|
frame = 3
|
||||||
playing = true
|
playing = true
|
||||||
centered = false
|
centered = false
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ tracks/0/loop_wrap = true
|
||||||
tracks/0/imported = false
|
tracks/0/imported = false
|
||||||
tracks/0/enabled = true
|
tracks/0/enabled = true
|
||||||
tracks/0/keys = {
|
tracks/0/keys = {
|
||||||
"times": PoolRealArray( 0, 2 ),
|
"times": PoolRealArray( 0, 0.9 ),
|
||||||
"transitions": PoolRealArray( 1, 1 ),
|
"transitions": PoolRealArray( 1, 1 ),
|
||||||
"update": 1,
|
"update": 1,
|
||||||
"values": [ true, false ]
|
"values": [ true, false ]
|
||||||
|
|
|
@ -13,7 +13,7 @@ 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):
|
func draw_dashed_line(from, to, color, width, dash_length = 4, cap_end = false, antialiased = false):
|
||||||
var length = (to - from).length()
|
var length = (to - from).length()
|
||||||
var normal = (to - from).normalized()
|
var normal = (to - from).normalized()
|
||||||
var dash_step = normal * dash_length
|
var dash_step = normal * dash_length
|
||||||
|
@ -62,6 +62,7 @@ func area_entered(area):
|
||||||
|
|
||||||
func _shoot():
|
func _shoot():
|
||||||
bullet = bullet_preload.instance()
|
bullet = bullet_preload.instance()
|
||||||
|
bullet.target = target
|
||||||
get_parent().add_child(bullet)
|
get_parent().add_child(bullet)
|
||||||
bullet.global_position.x = self.global_position.x + 12
|
bullet.global_position.x = self.global_position.x + 12
|
||||||
bullet.global_position.y = self.global_position.y - 4
|
bullet.global_position.y = self.global_position.y - 4
|
||||||
|
@ -69,7 +70,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_dashed_line(Vector2(12, 8), target.global_position - self.global_position + Vector2(8, 7), Color("ffde00"), 1)
|
draw_dashed_line(Vector2(12, 12), target.global_position - self.global_position + Vector2(8, 7), Color("ffde00"), 1)
|
||||||
|
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
$Sprite.play("idle") if velocity == Vector2.ZERO else $Sprite.play("run")
|
$Sprite.play("idle") if velocity == Vector2.ZERO else $Sprite.play("run")
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
extends Node
|
|
Loading…
Reference in New Issue