Compare commits
No commits in common. "d67d1568ee771bffd33f4e9a2fec1724b1f4d4da" and "d010f9a17f6fb1ebbce3cad4a691783d6bbbed86" have entirely different histories.
d67d1568ee
...
d010f9a17f
|
@ -15,5 +15,5 @@ void fragment(){
|
|||
|
||||
[resource]
|
||||
shader = SubResource( 3 )
|
||||
shader_param/active = true
|
||||
shader_param/color = Color( 1, 1, 1, 0 )
|
||||
shader_param/active = false
|
||||
shader_param/color = Color( 1, 1, 1, 1 )
|
||||
|
|
|
@ -2,11 +2,7 @@ extends KinematicBody2D
|
|||
|
||||
var speed = 128
|
||||
var velocity = Vector2.ZERO
|
||||
var target
|
||||
|
||||
func _physics_process(delta):
|
||||
if target != null:
|
||||
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)
|
||||
func _physics_process(_delta):
|
||||
velocity.x = speed
|
||||
move_and_slide(velocity)
|
||||
|
|
|
@ -19,7 +19,7 @@ script = ExtResource( 2 )
|
|||
use_parent_material = true
|
||||
frames = ExtResource( 1 )
|
||||
animation = "idle"
|
||||
frame = 3
|
||||
frame = 1
|
||||
playing = true
|
||||
centered = false
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ tracks/0/loop_wrap = true
|
|||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.9 ),
|
||||
"times": PoolRealArray( 0, 2 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ true, false ]
|
||||
|
|
|
@ -13,7 +13,7 @@ var speed = 100
|
|||
var draw_node
|
||||
var bullet
|
||||
|
||||
func draw_dashed_line(from, to, color, width, dash_length = 4, cap_end = false, antialiased = false):
|
||||
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
|
||||
|
@ -62,7 +62,6 @@ func area_entered(area):
|
|||
|
||||
func _shoot():
|
||||
bullet = bullet_preload.instance()
|
||||
bullet.target = target
|
||||
get_parent().add_child(bullet)
|
||||
bullet.global_position.x = self.global_position.x + 12
|
||||
bullet.global_position.y = self.global_position.y - 4
|
||||
|
@ -70,7 +69,7 @@ func _shoot():
|
|||
func _draw():
|
||||
if target != null:
|
||||
var dist2enemy = position.distance_to(target.global_position)
|
||||
draw_dashed_line(Vector2(12, 12), target.global_position - self.global_position + Vector2(8, 7), Color("ffde00"), 1)
|
||||
draw_dashed_line(Vector2(12, 8), target.global_position - self.global_position + Vector2(8, 7), Color("ffde00"), 1)
|
||||
|
||||
func _process(_delta):
|
||||
$Sprite.play("idle") if velocity == Vector2.ZERO else $Sprite.play("run")
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
extends Node
|
Loading…
Reference in New Issue