new enemy work
This commit is contained in:
parent
783fc7c877
commit
6825cd59c9
12 changed files with 241 additions and 0 deletions
9
objects/enemies/belough/belough.gd
Normal file
9
objects/enemies/belough/belough.gd
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
extends Enemy
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
position.x += move_speed * delta
|
||||||
|
if position.x > 340.0: position.x = -22.0
|
||||||
|
|
||||||
|
|
||||||
|
func _on_timer_timeout() -> void:
|
||||||
|
shoot()
|
||||||
1
objects/enemies/belough/belough.gd.uid
Normal file
1
objects/enemies/belough/belough.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dn8flbhiqt6fv
|
||||||
69
objects/enemies/belough/belough.tscn
Normal file
69
objects/enemies/belough/belough.tscn
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
[gd_scene load_steps=6 format=3 uid="uid://cbjv7fecdoet5"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://dn8flbhiqt6fv" path="res://objects/enemies/belough/belough.gd" id="1_u1v7t"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://ecb1qd6euubm" path="res://assets/graphics/belough.png" id="2_62uax"]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_nkf7n"]
|
||||||
|
resource_name = "flap"
|
||||||
|
length = 0.3
|
||||||
|
loop_mode = 1
|
||||||
|
step = 0.0333333
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:flip_v")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0.0333333, 0.133333),
|
||||||
|
"transitions": PackedFloat32Array(1, 1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [false, true]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_qevrr"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:flip_v")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [false]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_xotlt"]
|
||||||
|
_data = {
|
||||||
|
&"RESET": SubResource("Animation_qevrr"),
|
||||||
|
&"flap": SubResource("Animation_nkf7n")
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Belough" type="Node2D"]
|
||||||
|
script = ExtResource("1_u1v7t")
|
||||||
|
shoot_speed = Vector2(0, 100)
|
||||||
|
shoot_variance = Vector2(0, 100)
|
||||||
|
move_speed = 100.0
|
||||||
|
metadata/_custom_type_script = "uid://d2k5tlvpqokqr"
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
position = Vector2(0, -5)
|
||||||
|
texture = ExtResource("2_62uax")
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
|
libraries = {
|
||||||
|
&"": SubResource("AnimationLibrary_xotlt")
|
||||||
|
}
|
||||||
|
autoplay = "flap"
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="."]
|
||||||
|
autostart = true
|
||||||
|
|
||||||
|
[node name="Marker2D" type="Marker2D" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
position = Vector2(-5, -3)
|
||||||
|
|
||||||
|
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||||
15
objects/enemies/enemy.gd
Normal file
15
objects/enemies/enemy.gd
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
class_name Enemy
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
@export var shoot_speed = Vector2.ZERO
|
||||||
|
@export var shoot_variance = Vector2.ZERO
|
||||||
|
@export var projectile = preload("res://objects/projectile/enemy_projectile.tscn")
|
||||||
|
@export var move_speed = 0.0
|
||||||
|
|
||||||
|
func shoot():
|
||||||
|
var Projectile = projectile.instantiate()
|
||||||
|
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.position = %Marker2D.global_position
|
||||||
|
get_parent().add_child(Projectile)
|
||||||
|
|
||||||
1
objects/enemies/enemy.gd.uid
Normal file
1
objects/enemies/enemy.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://d2k5tlvpqokqr
|
||||||
6
objects/enemies/enemy.tscn
Normal file
6
objects/enemies/enemy.tscn
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://rx1115pdgjxv"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://d2k5tlvpqokqr" path="res://objects/enemies/enemy.gd" id="1_peg6m"]
|
||||||
|
|
||||||
|
[node name="Enemy" type="Node2D"]
|
||||||
|
script = ExtResource("1_peg6m")
|
||||||
8
objects/enemies/kith/kith.gd
Normal file
8
objects/enemies/kith/kith.gd
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
extends Enemy
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func _on_timer_timeout() -> void:
|
||||||
|
shoot()
|
||||||
1
objects/enemies/kith/kith.gd.uid
Normal file
1
objects/enemies/kith/kith.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://b2j71opc4k4v2
|
||||||
67
objects/enemies/kith/kith.tscn
Normal file
67
objects/enemies/kith/kith.tscn
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
[gd_scene load_steps=6 format=3 uid="uid://cyn42vceeg8n3"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://b2j71opc4k4v2" path="res://objects/enemies/kith/kith.gd" id="1_odjmv"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://de27ah8re36mp" path="res://assets/graphics/kith.png" id="1_oqwi1"]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_jq7tw"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:flip_h")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [false]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_odjmv"]
|
||||||
|
resource_name = "move"
|
||||||
|
length = 0.3
|
||||||
|
loop_mode = 1
|
||||||
|
step = 0.0333333
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:flip_h")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.166667),
|
||||||
|
"transitions": PackedFloat32Array(1, 1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [false, true]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_8mwcc"]
|
||||||
|
_data = {
|
||||||
|
&"RESET": SubResource("Animation_jq7tw"),
|
||||||
|
&"move": SubResource("Animation_odjmv")
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Kith" type="Node2D"]
|
||||||
|
script = ExtResource("1_odjmv")
|
||||||
|
shoot_speed = Vector2(0, -100)
|
||||||
|
shoot_variance = Vector2(0, 30)
|
||||||
|
metadata/_custom_type_script = "uid://d2k5tlvpqokqr"
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
texture = ExtResource("1_oqwi1")
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
|
libraries = {
|
||||||
|
&"": SubResource("AnimationLibrary_8mwcc")
|
||||||
|
}
|
||||||
|
autoplay = "move"
|
||||||
|
|
||||||
|
[node name="Marker2D" type="Marker2D" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
position = Vector2(0, -6)
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="."]
|
||||||
|
autostart = true
|
||||||
|
|
||||||
|
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||||
8
objects/projectile/enemy_projectile.gd
Normal file
8
objects/projectile/enemy_projectile.gd
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
@export var speed = Vector2.ZERO
|
||||||
|
var velocity = Vector2.ZERO
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
velocity = speed * delta
|
||||||
|
position += velocity
|
||||||
1
objects/projectile/enemy_projectile.gd.uid
Normal file
1
objects/projectile/enemy_projectile.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dgkxxvgayfuhl
|
||||||
55
objects/projectile/enemy_projectile.tscn
Normal file
55
objects/projectile/enemy_projectile.tscn
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
[gd_scene load_steps=6 format=3 uid="uid://c030i00x5v5an"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bjf5qye1b63mr" path="res://assets/graphics/shot.png" id="1_0qrq8"]
|
||||||
|
[ext_resource type="Script" uid="uid://dgkxxvgayfuhl" path="res://objects/projectile/enemy_projectile.gd" id="1_x3qif"]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_x3qif"]
|
||||||
|
resource_name = "ani"
|
||||||
|
length = 0.2
|
||||||
|
loop_mode = 1
|
||||||
|
step = 0.0333333
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:rotation")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.2),
|
||||||
|
"transitions": PackedFloat32Array(1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [0.0, 6.28319]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_w3guv"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:rotation")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [0.0]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_o706m"]
|
||||||
|
_data = {
|
||||||
|
&"RESET": SubResource("Animation_w3guv"),
|
||||||
|
&"ani": SubResource("Animation_x3qif")
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="EnemyProjectile" type="Node2D"]
|
||||||
|
script = ExtResource("1_x3qif")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
texture = ExtResource("1_0qrq8")
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
|
libraries = {
|
||||||
|
&"": SubResource("AnimationLibrary_o706m")
|
||||||
|
}
|
||||||
|
autoplay = "ani"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue