Compare commits

..

2 Commits

Author SHA1 Message Date
Luna Brovchuk d67d1568ee Merge branch 'main' of http://meowo.cc:3000/meowo/LD54 2023-10-01 16:14:35 +02:00
Luna Brovchuk 8592cc29cb Fix Bullets 2023-10-01 16:14:17 +02:00
6 changed files with 15 additions and 11 deletions

View File

@ -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 )

View File

@ -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)

View File

@ -19,7 +19,7 @@ script = ExtResource( 2 )
use_parent_material = true
frames = ExtResource( 1 )
animation = "idle"
frame = 1
frame = 3
playing = true
centered = false

View File

@ -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 ]

View File

@ -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
@ -30,7 +30,7 @@ func draw_dashed_line(from, to, color, width, dash_length = 3, cap_end = false,
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
@ -62,6 +62,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
@ -69,7 +70,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 _process(_delta):
$Sprite.play("idle") if velocity == Vector2.ZERO else $Sprite.play("run")

View File

@ -1 +0,0 @@
extends Node