Compare commits

..

2 Commits

Author SHA1 Message Date
Luna Brovchuk 701b705db5 Merge branch 'main' of http://meowo.cc:3000/meowo/LD54 2023-10-01 15:45:34 +02:00
Luna Brovchuk 5083b945aa "Fix" Line 2023-10-01 15:45:32 +02:00
3 changed files with 20 additions and 20 deletions

View File

@ -10,6 +10,7 @@ extents = Vector2( 3.5, 3 )
extents = Vector2( 6, 4 ) extents = Vector2( 6, 4 )
[node name="Bat" type="KinematicBody2D" groups=["bat", "enemy"]] [node name="Bat" type="KinematicBody2D" groups=["bat", "enemy"]]
z_index = 1
collision_layer = 2 collision_layer = 2
collision_mask = 2 collision_mask = 2
script = ExtResource( 2 ) script = ExtResource( 2 )

View File

@ -1,5 +1,6 @@
extends KinematicBody2D extends KinematicBody2D
onready var bullet_preload = preload("res://src/models/bullet/Bullet.tscn")
var outline_material = load("res://res/shaders/outline_material.tres") var outline_material = load("res://res/shaders/outline_material.tres")
var speed_multiplier: float = 1.0 var speed_multiplier: float = 1.0
var invincibility_timer = .0 var invincibility_timer = .0
@ -9,13 +10,13 @@ var target: EnemyClass
var slowed = false var slowed = false
var speed = 100 var speed = 100
onready var bullet = preload("res://src/models/bullet/Bullet.tscn") var draw_node
var bullet_instance var bullet
func _process(_delta): func _process(_delta):
if Input.is_action_just_pressed("shoot"): if Input.is_action_just_pressed("shoot"):
_shoot() _shoot()
update()
func get_input(): func get_input():
var input_direction = Input.get_vector("left", "right", "up", "down") var input_direction = Input.get_vector("left", "right", "up", "down")
@ -40,6 +41,17 @@ func area_entered(area):
invincible = true invincible = true
invincibility_timer = .0 invincibility_timer = .0
func _shoot():
bullet = bullet_preload.instance()
get_parent().add_child(bullet)
bullet.global_position.x = self.global_position.x + 12
bullet.global_position.y = self.global_position.y - 4
func _draw():
if target != null:
var dist2enemy = position.distance_to(target.global_position)
draw_line(Vector2(12, 8), target.global_position - self.global_position + Vector2(8, 7), Color("ffde00"))
func _physics_process(delta): func _physics_process(delta):
get_input() get_input()
@ -63,14 +75,3 @@ func _physics_process(delta):
velocity = move_and_slide(velocity * speed_multiplier) velocity = move_and_slide(velocity * speed_multiplier)
choose_target() choose_target()
target.material = outline_material target.material = outline_material
func _shoot():
bullet_instance = bullet.instance()
get_parent().add_child(bullet_instance)
bullet_instance.global_position.x = get_node("../Player").global_position.x + 12
bullet_instance.global_position.y = get_node("../Player").global_position.y - 4
func _draw():
var distance_2_enemy = position.distance_to(Vector2(100, 100))
draw_line(Vector2(12, 8), Vector2(distance_2_enemy * cos(self.global_position.x), distance_2_enemy * sin(self.global_position.y)), Color(255, 255, 255))
#TODO replace self.global_position.x,y to enemy x,y

View File

@ -71,24 +71,22 @@ shape = SubResource( 3 )
position = Vector2( 160, 109.875 ) position = Vector2( 160, 109.875 )
shape = SubResource( 3 ) shape = SubResource( 3 )
[node name="Player" parent="View" instance=ExtResource( 5 )]
position = Vector2( 46, 42 )
z_index = 1
[node name="Enemies" type="Node2D" parent="View"] [node name="Enemies" type="Node2D" parent="View"]
[node name="TrashCan" parent="View/Enemies" instance=ExtResource( 13 )] [node name="TrashCan" parent="View/Enemies" instance=ExtResource( 13 )]
[node name="Bat" parent="View/Enemies" instance=ExtResource( 14 )] [node name="Bat" parent="View/Enemies" instance=ExtResource( 14 )]
z_index = 1
[node name="Bat2" parent="View/Enemies" instance=ExtResource( 14 )] [node name="Bat2" parent="View/Enemies" instance=ExtResource( 14 )]
position = Vector2( 142, 54 ) position = Vector2( 142, 54 )
z_index = 1
[node name="Ghost" parent="View/Enemies" instance=ExtResource( 15 )] [node name="Ghost" parent="View/Enemies" instance=ExtResource( 15 )]
position = Vector2( 509, 100 ) position = Vector2( 509, 100 )
[node name="Player" parent="View" instance=ExtResource( 5 )]
position = Vector2( 46, 42 )
z_index = 1
[node name="UIWrapper" type="CanvasLayer" parent="."] [node name="UIWrapper" type="CanvasLayer" parent="."]
layer = 3 layer = 3