spittin fiend
This commit is contained in:
parent
6825cd59c9
commit
dd66cc2a84
6 changed files with 65 additions and 4 deletions
|
|
@ -6,4 +6,4 @@ func _physics_process(delta: float) -> void:
|
||||||
|
|
||||||
|
|
||||||
func _on_timer_timeout() -> void:
|
func _on_timer_timeout() -> void:
|
||||||
shoot()
|
shoot(%Marker2D.global_position)
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,10 @@ extends Node2D
|
||||||
@export var projectile = preload("res://objects/projectile/enemy_projectile.tscn")
|
@export var projectile = preload("res://objects/projectile/enemy_projectile.tscn")
|
||||||
@export var move_speed = 0.0
|
@export var move_speed = 0.0
|
||||||
|
|
||||||
func shoot():
|
func shoot(pos):
|
||||||
var Projectile = projectile.instantiate()
|
var Projectile = projectile.instantiate()
|
||||||
Projectile.speed.x = shoot_speed.x + randf_range(-shoot_variance.x,shoot_variance.x)
|
Projectile.speed.x = shoot_speed.x + randf_range(-shoot_variance.x,shoot_variance.x)
|
||||||
Projectile.speed.y = shoot_speed.y + randf_range(-shoot_variance.y,shoot_variance.y)
|
Projectile.speed.y = shoot_speed.y + randf_range(-shoot_variance.y,shoot_variance.y)
|
||||||
Projectile.position = %Marker2D.global_position
|
Projectile.position = pos
|
||||||
get_parent().add_child(Projectile)
|
get_parent().add_child(Projectile)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,4 @@ func _ready() -> void:
|
||||||
|
|
||||||
|
|
||||||
func _on_timer_timeout() -> void:
|
func _on_timer_timeout() -> void:
|
||||||
shoot()
|
shoot(%Marker2D.global_position)
|
||||||
|
|
|
||||||
25
objects/enemies/spitting_fiend/spitting_fiend.gd
Normal file
25
objects/enemies/spitting_fiend/spitting_fiend.gd
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
extends Enemy
|
||||||
|
|
||||||
|
@export var multi_shoot_speed = 0.0
|
||||||
|
|
||||||
|
func multi_shoot():
|
||||||
|
shoot_speed.x = multi_shoot_speed
|
||||||
|
shoot_speed.y = 0.0
|
||||||
|
shoot(%Right.global_position)
|
||||||
|
|
||||||
|
shoot_speed.x = -multi_shoot_speed
|
||||||
|
shoot_speed.y = 0.0
|
||||||
|
shoot(%Left.global_position)
|
||||||
|
|
||||||
|
shoot_speed.y = multi_shoot_speed
|
||||||
|
shoot_speed.x = 0.0
|
||||||
|
shoot(%Down.global_position)
|
||||||
|
|
||||||
|
shoot_speed.y = -multi_shoot_speed
|
||||||
|
shoot_speed.x = 0.0
|
||||||
|
shoot(%Up.global_position)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _on_timer_timeout() -> void:
|
||||||
|
multi_shoot()
|
||||||
1
objects/enemies/spitting_fiend/spitting_fiend.gd.uid
Normal file
1
objects/enemies/spitting_fiend/spitting_fiend.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dewgsa8je6l6l
|
||||||
35
objects/enemies/spitting_fiend/spitting_fiend.tscn
Normal file
35
objects/enemies/spitting_fiend/spitting_fiend.tscn
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://dfrj00ro4rm5l"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://dewgsa8je6l6l" path="res://objects/enemies/spitting_fiend/spitting_fiend.gd" id="1_mfr0l"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bh178ledlvf3o" path="res://assets/graphics/spitting_fiend.png" id="2_34xv4"]
|
||||||
|
|
||||||
|
[node name="SpittingFiend" type="Node2D"]
|
||||||
|
script = ExtResource("1_mfr0l")
|
||||||
|
multi_shoot_speed = 100.0
|
||||||
|
shoot_speed = Vector2(100, 100)
|
||||||
|
metadata/_custom_type_script = "uid://d2k5tlvpqokqr"
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="."]
|
||||||
|
autostart = true
|
||||||
|
|
||||||
|
[node name="Up" type="Marker2D" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
position = Vector2(0, -12)
|
||||||
|
|
||||||
|
[node name="Right" type="Marker2D" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
position = Vector2(16, 2)
|
||||||
|
|
||||||
|
[node name="Down" type="Marker2D" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
position = Vector2(1, 14)
|
||||||
|
|
||||||
|
[node name="Left" type="Marker2D" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
position = Vector2(-14, 0)
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
position = Vector2(1, 1)
|
||||||
|
texture = ExtResource("2_34xv4")
|
||||||
|
|
||||||
|
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue