2048-Shooter/Panzer.tscn
2022-11-24 16:00:50 +01:00

52 lines
1.1 KiB
Plaintext

[gd_scene load_steps=3 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://Bullet.tscn\")
var speed = 2.5
onready var GameNode
func _ready():
GameNode = find_parent(\"Game\")
GameNode.connect(\"speed_shoot\", self, \"set_shoot_speed\")
pass
func _process(delta):
Time += delta
if Time > speed and get_parent() != GameNode: #wenn er nicht gehoben wird dann:
shoot()
Time = 0
pass
func shoot():
var bullet = bulletPath.instance()
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
"
[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 )
z_index = 1
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 0, 48, 16, 16 )
[node name="Position2D" type="Position2D" parent="."]
position = Vector2( 0.5, -28 )