Compare commits
2 Commits
70aa197568
...
701b705db5
Author | SHA1 | Date |
---|---|---|
Luna Brovchuk | 701b705db5 | |
Luna Brovchuk | 5083b945aa |
|
@ -10,6 +10,7 @@ extents = Vector2( 3.5, 3 )
|
|||
extents = Vector2( 6, 4 )
|
||||
|
||||
[node name="Bat" type="KinematicBody2D" groups=["bat", "enemy"]]
|
||||
z_index = 1
|
||||
collision_layer = 2
|
||||
collision_mask = 2
|
||||
script = ExtResource( 2 )
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
onready var bullet_preload = preload("res://src/models/bullet/Bullet.tscn")
|
||||
var outline_material = load("res://res/shaders/outline_material.tres")
|
||||
var speed_multiplier: float = 1.0
|
||||
var invincibility_timer = .0
|
||||
|
@ -9,13 +10,13 @@ var target: EnemyClass
|
|||
var slowed = false
|
||||
var speed = 100
|
||||
|
||||
onready var bullet = preload("res://src/models/bullet/Bullet.tscn")
|
||||
var bullet_instance
|
||||
var draw_node
|
||||
var bullet
|
||||
|
||||
func _process(_delta):
|
||||
if Input.is_action_just_pressed("shoot"):
|
||||
_shoot()
|
||||
|
||||
update()
|
||||
|
||||
func get_input():
|
||||
var input_direction = Input.get_vector("left", "right", "up", "down")
|
||||
|
@ -40,6 +41,17 @@ func area_entered(area):
|
|||
invincible = true
|
||||
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):
|
||||
get_input()
|
||||
|
||||
|
@ -63,14 +75,3 @@ func _physics_process(delta):
|
|||
velocity = move_and_slide(velocity * speed_multiplier)
|
||||
choose_target()
|
||||
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
|
||||
|
|
|
@ -71,24 +71,22 @@ shape = SubResource( 3 )
|
|||
position = Vector2( 160, 109.875 )
|
||||
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="TrashCan" parent="View/Enemies" instance=ExtResource( 13 )]
|
||||
|
||||
[node name="Bat" parent="View/Enemies" instance=ExtResource( 14 )]
|
||||
z_index = 1
|
||||
|
||||
[node name="Bat2" parent="View/Enemies" instance=ExtResource( 14 )]
|
||||
position = Vector2( 142, 54 )
|
||||
z_index = 1
|
||||
|
||||
[node name="Ghost" parent="View/Enemies" instance=ExtResource( 15 )]
|
||||
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="."]
|
||||
layer = 3
|
||||
|
||||
|
|
Loading…
Reference in New Issue