diff --git a/res/shaders/colorize.tres b/res/shaders/colorize.tres index f7d36b5..dcdce01 100644 --- a/res/shaders/colorize.tres +++ b/res/shaders/colorize.tres @@ -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 ) diff --git a/src/models/bullet/Bullet.gd b/src/models/bullet/Bullet.gd index 1239bb3..bc0f701 100644 --- a/src/models/bullet/Bullet.gd +++ b/src/models/bullet/Bullet.gd @@ -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) diff --git a/src/models/enemies/bat/Bat.tscn b/src/models/enemies/bat/Bat.tscn index 7425150..cbd8d2a 100644 --- a/src/models/enemies/bat/Bat.tscn +++ b/src/models/enemies/bat/Bat.tscn @@ -19,7 +19,7 @@ script = ExtResource( 2 ) use_parent_material = true frames = ExtResource( 1 ) animation = "idle" -frame = 1 +frame = 3 playing = true centered = false diff --git a/src/models/player/Player.tscn b/src/models/player/Player.tscn index 7094e34..dbb1d8f 100644 --- a/src/models/player/Player.tscn +++ b/src/models/player/Player.tscn @@ -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 ] diff --git a/src/models/player/player.gd b/src/models/player/player.gd index 788a7d2..a721dee 100644 --- a/src/models/player/player.gd +++ b/src/models/player/player.gd @@ -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 @@ -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() diff --git a/src/scripts/draw_dashed_line.gd b/src/scripts/draw_dashed_line.gd deleted file mode 100644 index 61510e1..0000000 --- a/src/scripts/draw_dashed_line.gd +++ /dev/null @@ -1 +0,0 @@ -extends Node