mirror of
https://github.com/Yadciel1/2048-Shooter.git
synced 2024-11-12 17:11:18 +01:00
86 lines
2.3 KiB
Plaintext
86 lines
2.3 KiB
Plaintext
[gd_scene load_steps=6 format=2]
|
|
|
|
[ext_resource path="res://enemy.png" type="Texture" id=1]
|
|
[ext_resource path="res://Font/super-legend-boy-font/SuperLegendBoy-4w8Y.ttf" type="DynamicFontData" id=2]
|
|
|
|
[sub_resource type="GDScript" id=1]
|
|
script/source = "extends KinematicBody2D
|
|
|
|
var velocity = Vector2(0,1)
|
|
var speed = 50
|
|
var life = 2
|
|
|
|
signal on_Death
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
var text = randi() % life as int
|
|
$Label.text = (text+1) as String
|
|
var Progressbars = get_tree().get_nodes_in_group(\"XP\")
|
|
for Progressbar in Progressbars:
|
|
self.connect(\"on_Death\",Progressbar, \"on_Death_listed\")
|
|
Progressbar.connect(\"full_bar\", self, \"set_speed\")
|
|
pass # Replace with function body.
|
|
|
|
func _physics_process(delta):
|
|
move_and_collide(velocity.normalized() * delta * speed)
|
|
pass
|
|
|
|
func _on_Area2D_area_entered(area):
|
|
if area.is_in_group(\"Bullet\"):
|
|
var text = $Label.text as int
|
|
if text > 1:
|
|
$Label.text = (text-1) as String
|
|
else:
|
|
var value = 1
|
|
emit_signal(\"on_Death\", value)
|
|
queue_free()
|
|
if area.is_in_group(\"Border\"):
|
|
get_tree().change_scene(\"res://GameOver.tscn\")
|
|
pass # Replace with function body.
|
|
|
|
func set_speed(value):
|
|
var Spawner = get_tree().get_nodes_in_group(\"Spawner\")
|
|
for Spawn in Spawner:
|
|
Spawn.e_speed += value
|
|
Spawn.e_life *= 1.2
|
|
"
|
|
|
|
[sub_resource type="RectangleShape2D" id=2]
|
|
extents = Vector2( 4, 4 )
|
|
|
|
[sub_resource type="DynamicFont" id=3]
|
|
size = 12
|
|
font_data = ExtResource( 2 )
|
|
|
|
[node name="Node2D" type="KinematicBody2D" groups=["Enemy"]]
|
|
position = Vector2( 64, 64 )
|
|
scale = Vector2( 12, 12 )
|
|
script = SubResource( 1 )
|
|
|
|
[node name="Sprite" type="Sprite" parent="."]
|
|
texture = ExtResource( 1 )
|
|
|
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
|
scale = Vector2( 0.9, 0.9 )
|
|
shape = SubResource( 2 )
|
|
|
|
[node name="Area2D" type="Area2D" parent="."]
|
|
|
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
|
shape = SubResource( 2 )
|
|
|
|
[node name="Label" type="Label" parent="."]
|
|
margin_left = -3.33333
|
|
margin_top = -4.0
|
|
margin_right = 8.66667
|
|
margin_bottom = 10.0
|
|
grow_horizontal = 2
|
|
grow_vertical = 2
|
|
rect_min_size = Vector2( 8, 8 )
|
|
rect_scale = Vector2( 0.545, 0.639 )
|
|
custom_fonts/font = SubResource( 3 )
|
|
text = "1"
|
|
|
|
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"]
|