Fix Bullets
parent
a7c0c45486
commit
8592cc29cb
|
@ -15,5 +15,5 @@ void fragment(){
|
|||
|
||||
[resource]
|
||||
shader = SubResource( 3 )
|
||||
shader_param/active = false
|
||||
shader_param/color = Color( 1, 1, 1, 1 )
|
||||
shader_param/active = true
|
||||
shader_param/color = Color( 1, 1, 1, 0 )
|
||||
|
|
|
@ -2,7 +2,11 @@ extends KinematicBody2D
|
|||
|
||||
var speed = 128
|
||||
var velocity = Vector2.ZERO
|
||||
var target
|
||||
|
||||
func _physics_process(_delta):
|
||||
velocity.x = speed
|
||||
move_and_slide(velocity)
|
||||
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)
|
||||
|
|
|
@ -19,7 +19,7 @@ script = ExtResource( 2 )
|
|||
use_parent_material = true
|
||||
frames = ExtResource( 1 )
|
||||
animation = "idle"
|
||||
frame = 1
|
||||
frame = 3
|
||||
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, 2 ),
|
||||
"times": PoolRealArray( 0, 0.9 ),
|
||||
"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 = 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 normal = (to - from).normalized()
|
||||
var dash_step = normal * dash_length
|
||||
|
@ -67,6 +67,7 @@ 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
|
||||
|
@ -74,7 +75,7 @@ func _shoot():
|
|||
func _draw():
|
||||
if target != null:
|
||||
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 _physics_process(delta):
|
||||
get_input()
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
extends Node
|
Loading…
Reference in New Issue