Compare commits

..

No commits in common. "701b705db57a27c7e4bb28a4474257e64dd99cc1" and "70aa197568b7f877189720d0a0a4594e1612339d" have entirely different histories.

3 changed files with 20 additions and 20 deletions

View File

@ -10,7 +10,6 @@ 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 )

View File

@ -1,6 +1,5 @@
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
@ -10,13 +9,13 @@ var target: EnemyClass
var slowed = false
var speed = 100
var draw_node
var bullet
onready var bullet = preload("res://src/models/bullet/Bullet.tscn")
var bullet_instance
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")
@ -41,17 +40,6 @@ 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()
@ -75,3 +63,14 @@ 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

View File

@ -71,22 +71,24 @@ 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