mirror of
https://github.com/Yadciel1/2048-Shooter.git
synced 2025-06-16 03:05:22 +02:00
Big_update
This commit is contained in:
48
Objects/Bullet.tscn
Normal file
48
Objects/Bullet.tscn
Normal file
@ -0,0 +1,48 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://box.png" type="Texture" id=1]
|
||||
|
||||
[sub_resource type="GDScript" id=3]
|
||||
resource_name = "Bullet"
|
||||
script/source = "extends KinematicBody2D
|
||||
|
||||
|
||||
var velocity = Vector2(0,-1)
|
||||
var speed = 300
|
||||
var hit_power = 2
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = \"text\"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
func _physics_process(delta):
|
||||
move_and_collide(velocity.normalized() * delta * speed)
|
||||
pass
|
||||
"
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 3.33333, 3.33333 )
|
||||
|
||||
[node name="Bullet" type="KinematicBody2D"]
|
||||
scale = Vector2( 1.5, 1.5 )
|
||||
z_index = 1
|
||||
script = SubResource( 3 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( 3.73522e-06, -3.41733e-06 )
|
||||
scale = Vector2( 1.1, 1.1 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="." groups=["Bullet"]]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
position = Vector2( 5.96046e-08, -5.96046e-08 )
|
||||
shape = SubResource( 2 )
|
107
Objects/Entity.tscn
Normal file
107
Objects/Entity.tscn
Normal file
@ -0,0 +1,107 @@
|
||||
[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 pre_bullet_hit = preload(\"res://Objects/bullet_hit.tscn\")
|
||||
var velocity = Vector2(0,1)
|
||||
var speed = 50
|
||||
var life = 2
|
||||
var rng = RandomNumberGenerator.new()
|
||||
|
||||
signal on_Death
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
rng.randomize()
|
||||
var text = rng.randi_range(life/2, life)
|
||||
life = text
|
||||
$Label.text = (text) as String
|
||||
if(life > 9):
|
||||
pass
|
||||
var Progressbars = get_tree().get_nodes_in_group(\"XP\")
|
||||
for Progressbar in Progressbars:
|
||||
self.connect(\"on_Death\",Progressbar, \"on_Death_listed\")
|
||||
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 Bullet = area.get_parent()
|
||||
var text = $Label.text as int
|
||||
var value = 1
|
||||
var bullet_hit = pre_bullet_hit.instance()
|
||||
var GameNode = find_parent(\"Game\")
|
||||
if text >= Bullet.hit_power:
|
||||
if text > Bullet.hit_power:
|
||||
$Label.text = (text-Bullet.hit_power) as String
|
||||
GameNode.add_child(bullet_hit)
|
||||
bullet_hit.global_position = Bullet.global_position
|
||||
bullet_hit.play()
|
||||
Bullet.queue_free()
|
||||
if text == Bullet.hit_power:
|
||||
GameNode.add_child(bullet_hit)
|
||||
bullet_hit.global_position = Bullet.global_position
|
||||
bullet_hit.play()
|
||||
emit_signal(\"on_Death\", value)
|
||||
Bullet.queue_free()
|
||||
queue_free()
|
||||
else:
|
||||
GameNode.add_child(bullet_hit)
|
||||
bullet_hit.global_position = Bullet.global_position
|
||||
bullet_hit.play()
|
||||
Bullet.hit_power -= life
|
||||
emit_signal(\"on_Death\", value)
|
||||
queue_free()
|
||||
if area.is_in_group(\"Border\"):
|
||||
area.get_node(\"LifeBar\").value -= $Label.text as int
|
||||
queue_free()
|
||||
pass # Replace with function body.
|
||||
"
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 4, 4 )
|
||||
|
||||
[sub_resource type="DynamicFont" id=3]
|
||||
size = 12
|
||||
font_data = ExtResource( 2 )
|
||||
|
||||
[node name="Entity" 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_colors/font_color = Color( 1, 0, 0, 1 )
|
||||
custom_colors/font_outline_modulate = Color( 0, 0, 0, 1 )
|
||||
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
|
||||
custom_fonts/font = SubResource( 3 )
|
||||
text = "1"
|
||||
|
||||
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"]
|
74
Objects/Overlay.tscn
Normal file
74
Objects/Overlay.tscn
Normal file
@ -0,0 +1,74 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://Font/super-legend-boy-font/SuperLegendBoy-4w8Y.ttf" type="DynamicFontData" id=1]
|
||||
|
||||
[sub_resource type="GDScript" id=1]
|
||||
script/source = "extends Control
|
||||
|
||||
onready var pBar = $CanvasLayer/ProgressBar
|
||||
|
||||
signal full_bar
|
||||
signal score
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
if ($CanvasLayer/Score.text as int % 100) == 0:
|
||||
emit_signal(\"score\")
|
||||
if pBar.value == pBar.max_value:
|
||||
var value = 0.5
|
||||
emit_signal(\"full_bar\", value)
|
||||
pBar.value = 0
|
||||
pBar.max_value *= 2
|
||||
pass
|
||||
|
||||
func on_Death_listed(value):
|
||||
pBar.value += value
|
||||
var score = $CanvasLayer/Score.text as int
|
||||
$CanvasLayer/Score.text = (score+1) as String
|
||||
"
|
||||
|
||||
[sub_resource type="DynamicFont" id=2]
|
||||
font_data = ExtResource( 1 )
|
||||
|
||||
[sub_resource type="DynamicFont" id=3]
|
||||
size = 24
|
||||
font_data = ExtResource( 1 )
|
||||
|
||||
[node name="Overlay" type="Control" groups=["XP"]]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_bottom = -1040.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = SubResource( 1 )
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="ProgressBar" type="ProgressBar" parent="CanvasLayer"]
|
||||
modulate = Color( 0, 1, 0.972549, 1 )
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
margin_left = -144.0
|
||||
margin_top = 48.0
|
||||
margin_right = 48.0
|
||||
margin_bottom = 62.0
|
||||
rect_scale = Vector2( 1.5, 1.5 )
|
||||
custom_fonts/font = SubResource( 2 )
|
||||
max_value = 16.0
|
||||
|
||||
[node name="Score" type="Label" parent="CanvasLayer"]
|
||||
margin_left = 256.0
|
||||
margin_top = 16.0
|
||||
margin_right = 296.0
|
||||
margin_bottom = 39.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
custom_fonts/font = SubResource( 3 )
|
||||
text = "0"
|
||||
align = 1
|
||||
valign = 1
|
135
Objects/Panzer.tscn
Normal file
135
Objects/Panzer.tscn
Normal file
@ -0,0 +1,135 @@
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://assets/Tank Town V2.png" type="Texture" id=1]
|
||||
|
||||
[sub_resource type="GDScript" id=1]
|
||||
script/source = "extends Node2D
|
||||
|
||||
var Time = 0
|
||||
const bulletPath = preload(\"res:///Objects/Bullet.tscn\")
|
||||
var speed = 3
|
||||
onready var old_slot = null
|
||||
onready var GameNode
|
||||
var PanzerType = null
|
||||
var hit_power = 2
|
||||
|
||||
func _ready():
|
||||
GameNode = find_parent(\"Game\")
|
||||
GameNode.connect(\"speed_shoot\", self, \"set_shoot_speed\")
|
||||
pass
|
||||
|
||||
func _process(delta):
|
||||
if get_parent().is_class(\"Panel\"):
|
||||
old_slot = get_parent()
|
||||
PanzerType(PanzerType)
|
||||
Time += delta
|
||||
if Time > speed and get_parent() != GameNode: #wenn er nicht gehoben wird dann:
|
||||
shoot()
|
||||
Time = 0
|
||||
pass
|
||||
|
||||
func shoot():
|
||||
$Shoot.visible = true
|
||||
$Shoot/AnimationPlayer.play(\"Shoot\")
|
||||
var bullet = bulletPath.instance()
|
||||
bullet.hit_power = hit_power
|
||||
find_parent(\"Game\").add_child(bullet)
|
||||
bullet.position = $Position2D.global_position
|
||||
|
||||
func set_shoot_speed(value):
|
||||
if speed != 0.5:
|
||||
speed -= value
|
||||
print(speed)
|
||||
pass
|
||||
|
||||
func PanzerType(PanzerType):
|
||||
if PanzerType == null:
|
||||
pass
|
||||
if PanzerType == 1:
|
||||
pass
|
||||
if PanzerType == 2:
|
||||
$Sprite.region_rect = Rect2(0, 64, 16, 16)
|
||||
if PanzerType == 3:
|
||||
$Sprite.region_rect = Rect2(0, 80, 16, 16)
|
||||
if PanzerType == 4:
|
||||
$Sprite.modulate = Color(0.875, 0, 1)
|
||||
$Sprite.region_rect = Rect2(0, 80, 16, 16)
|
||||
|
||||
|
||||
|
||||
|
||||
func _on_AnimationPlayer_shoot_finished(anim_name):
|
||||
$Shoot.visible = false
|
||||
pass # Replace with function body.
|
||||
"
|
||||
|
||||
[sub_resource type="Animation" id=2]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 0,
|
||||
"values": [ 60 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
resource_name = "Shoot"
|
||||
length = 0.6
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.6 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ 60, 63 ]
|
||||
}
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=4]
|
||||
extents = Vector2( 12, 12 )
|
||||
|
||||
[node name="ShooterObject" type="Node2D"]
|
||||
position = Vector2( 64, 64 )
|
||||
scale = Vector2( 2, 2 )
|
||||
z_index = 1
|
||||
script = SubResource( 1 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
scale = Vector2( 3, 3 )
|
||||
texture = ExtResource( 1 )
|
||||
region_enabled = true
|
||||
region_rect = Rect2( 0, 48, 16, 16 )
|
||||
|
||||
[node name="Position2D" type="Position2D" parent="."]
|
||||
position = Vector2( 0.5, -28 )
|
||||
|
||||
[node name="Shoot" type="Node2D" parent="."]
|
||||
visible = false
|
||||
position = Vector2( 0, -40 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="Shoot"]
|
||||
scale = Vector2( 2, 2 )
|
||||
texture = ExtResource( 1 )
|
||||
hframes = 10
|
||||
vframes = 12
|
||||
frame = 60
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="Shoot"]
|
||||
anims/RESET = SubResource( 2 )
|
||||
anims/Shoot = SubResource( 3 )
|
||||
|
||||
[node name="panzerArea" type="Area2D" parent="." groups=["Panzer"]]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="panzerArea"]
|
||||
shape = SubResource( 4 )
|
||||
|
||||
[connection signal="animation_finished" from="Shoot/AnimationPlayer" to="." method="_on_AnimationPlayer_shoot_finished"]
|
35
Objects/PanzerButton.tscn
Normal file
35
Objects/PanzerButton.tscn
Normal file
@ -0,0 +1,35 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://Font/super-legend-boy-font/SuperLegendBoy-4w8Y.ttf" type="DynamicFontData" id=1]
|
||||
|
||||
[sub_resource type="DynamicFont" id=5]
|
||||
font_data = ExtResource( 1 )
|
||||
|
||||
[sub_resource type="GDScript" id=6]
|
||||
script/source = "extends Button
|
||||
|
||||
var Panzer = preload(\"res://Objects/Panzer.tscn\")
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = \"text\"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
"
|
||||
|
||||
[node name="PanzerButton" type="Button"]
|
||||
margin_left = 132.0
|
||||
margin_right = 260.0
|
||||
margin_bottom = 128.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_fonts/font = SubResource( 5 )
|
||||
text = "Panzer"
|
||||
script = SubResource( 6 )
|
45
Objects/Slot.gd
Normal file
45
Objects/Slot.gd
Normal file
@ -0,0 +1,45 @@
|
||||
extends Panel
|
||||
|
||||
var PanzerType = preload("res://Objects/Panzer.tscn")
|
||||
var Panzer = null
|
||||
var start_panzer = 0
|
||||
|
||||
func _process(delta):
|
||||
if start_panzer > 0:
|
||||
if randi() % 2 == 0:
|
||||
Panzer = PanzerType.instance()
|
||||
add_child(Panzer)
|
||||
start_panzer -= 1
|
||||
|
||||
|
||||
func pickFromSlot():
|
||||
remove_child(Panzer)
|
||||
var GameNode = find_parent("Game")
|
||||
GameNode.add_child(Panzer)
|
||||
Panzer = null
|
||||
|
||||
func putIntoSlot(new_panzer):
|
||||
Panzer = new_panzer
|
||||
Panzer.position = Vector2(64, 64)
|
||||
var GameNode = find_parent("Game")
|
||||
GameNode.remove_child(Panzer)
|
||||
add_child(Panzer)
|
||||
|
||||
func upgradePanzerInSlot():
|
||||
Panzer.hit_power *= 2
|
||||
if Panzer.PanzerType != null:
|
||||
Panzer.PanzerType += 1
|
||||
else:
|
||||
Panzer.PanzerType = 2
|
||||
pass
|
||||
|
||||
func _set_start_panzer(value):
|
||||
start_panzer += value
|
||||
|
||||
|
||||
func _on_slotshape_area_entered(area):
|
||||
if area.is_in_group("Panzer"):
|
||||
var GameNode = find_parent("Game")
|
||||
if GameNode.holding_item != null:
|
||||
GameNode.hover = self
|
||||
pass # Replace with function body.
|
27
Objects/Slot.tscn
Normal file
27
Objects/Slot.tscn
Normal file
@ -0,0 +1,27 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://Objects/Slot.gd" type="Script" id=1]
|
||||
[ext_resource path="res://box.png" type="Texture" id=2]
|
||||
|
||||
[sub_resource type="StyleBoxTexture" id=2]
|
||||
texture = ExtResource( 2 )
|
||||
region_rect = Rect2( 0, 0, 8, 8 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=3]
|
||||
extents = Vector2( 56, 56 )
|
||||
|
||||
[node name="Slot" type="Panel"]
|
||||
margin_right = 128.0
|
||||
margin_bottom = 128.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
rect_pivot_offset = Vector2( 64, 64 )
|
||||
custom_styles/panel = SubResource( 2 )
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="slotshape" type="Area2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="slotshape"]
|
||||
position = Vector2( 64, 64 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[connection signal="area_entered" from="slotshape" to="." method="_on_slotshape_area_entered"]
|
47
Objects/Spawner.gd
Normal file
47
Objects/Spawner.gd
Normal file
@ -0,0 +1,47 @@
|
||||
extends Panel
|
||||
|
||||
var enemy_pre = preload("res://Objects/Entity.tscn")
|
||||
var item_pre = preload("res://Objects/item.tscn")
|
||||
var enemy = null
|
||||
var item = null
|
||||
var e_speed = 50
|
||||
var e_life = 2
|
||||
var spawn_rate = 4
|
||||
var rng = RandomNumberGenerator.new()
|
||||
var Time = 0
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
rng.randomize()
|
||||
if rng.randi_range(0, spawn_rate) == 0:
|
||||
enemy = enemy_pre.instance()
|
||||
add_child(enemy)
|
||||
var Progressbars = get_tree().get_nodes_in_group("XP")
|
||||
for Progressbar in Progressbars:
|
||||
Progressbar.connect("full_bar", self, "set_spawn_values")
|
||||
pass
|
||||
|
||||
func _process(delta):
|
||||
Time += delta
|
||||
if Time > 3.5:
|
||||
rng.randomize()
|
||||
if rng.randi_range(0, spawn_rate) == 0:
|
||||
if rng.randi_range(0, 10) != 0:
|
||||
enemy = enemy_pre.instance()
|
||||
enemy.speed = e_speed
|
||||
enemy.life = e_life
|
||||
add_child(enemy)
|
||||
else:
|
||||
item = item_pre.instance()
|
||||
item.speed = e_speed
|
||||
add_child(item)
|
||||
Time = 0
|
||||
|
||||
|
||||
|
||||
func set_spawn_values(value):
|
||||
e_speed += value
|
||||
e_life *= 2
|
||||
if (spawn_rate > 2):
|
||||
spawn_rate -= 1
|
||||
pass
|
88
Objects/bullet_hit.tscn
Normal file
88
Objects/bullet_hit.tscn
Normal file
@ -0,0 +1,88 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://assets/Tank Town V2.png" type="Texture" id=1]
|
||||
|
||||
[sub_resource type="GDScript" id=3]
|
||||
script/source = "extends Node2D
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = \"text\"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
func play():
|
||||
$AnimationPlayer.play(\"Hit\")
|
||||
pass
|
||||
|
||||
func _on_AnimationPlayer_animation_finished(anim_name):
|
||||
queue_free()
|
||||
pass # Replace with function body.
|
||||
"
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
resource_name = "Hit"
|
||||
length = 0.3
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.3 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ 70, 75 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=2]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("AnimationPlayer:reset_on_save")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 0,
|
||||
"values": [ true ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("Sprite:frame")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 0,
|
||||
"values": [ 70 ]
|
||||
}
|
||||
|
||||
[node name="bullet_hit" type="Node2D"]
|
||||
script = SubResource( 3 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
scale = Vector2( 2, 2 )
|
||||
texture = ExtResource( 1 )
|
||||
hframes = 10
|
||||
vframes = 12
|
||||
frame = 70
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/Hit = SubResource( 1 )
|
||||
anims/RESET = SubResource( 2 )
|
||||
|
||||
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_AnimationPlayer_animation_finished"]
|
72
Objects/item.tscn
Normal file
72
Objects/item.tscn
Normal file
@ -0,0 +1,72 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://assets/Tank Town V2.png" type="Texture" id=1]
|
||||
|
||||
[sub_resource type="GDScript" id=1]
|
||||
script/source = "extends KinematicBody2D
|
||||
|
||||
var pre_bullet_hit = preload(\"res://Objects/bullet_hit.tscn\")
|
||||
var velocity = Vector2(0,1)
|
||||
var speed = 50
|
||||
var life = 1
|
||||
var rng = RandomNumberGenerator.new()
|
||||
|
||||
signal on_Death
|
||||
signal badget
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
rng.randomize()
|
||||
var Progressbars = get_tree().get_nodes_in_group(\"XP\")
|
||||
for Progressbar in Progressbars:
|
||||
self.connect(\"on_Death\",Progressbar, \"on_Death_listed\")
|
||||
var GameNode = find_parent(\"Game\")
|
||||
connect(\"badget\", GameNode, \"_enable_Panzer\")
|
||||
pass # Replace with function body.
|
||||
|
||||
func _physics_process(delta):
|
||||
move_and_collide(velocity.normalized() * delta * speed)
|
||||
pass
|
||||
|
||||
|
||||
func _on_Area2D_area_entered(area):
|
||||
var value = 1
|
||||
var bullet_hit = pre_bullet_hit.instance()
|
||||
var GameNode = find_parent(\"Game\")
|
||||
if area.is_in_group(\"Bullet\"):
|
||||
var Bullet = area.get_parent()
|
||||
GameNode.add_child(bullet_hit)
|
||||
bullet_hit.global_position = Bullet.global_position
|
||||
bullet_hit.play()
|
||||
emit_signal(\"on_Death\", value)
|
||||
emit_signal(\"badget\", value)
|
||||
queue_free()
|
||||
pass # Replace with function body.
|
||||
"
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=3]
|
||||
extents = Vector2( 7, 7 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 7.83333, 7.83333 )
|
||||
|
||||
[node name="Item" type="KinematicBody2D"]
|
||||
position = Vector2( 64, 64 )
|
||||
scale = Vector2( 8, 8 )
|
||||
script = SubResource( 1 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 1 )
|
||||
hframes = 10
|
||||
vframes = 12
|
||||
frame = 48
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"]
|
Reference in New Issue
Block a user