From 0b224093692253ac3b257c86179a549e2f2d5869 Mon Sep 17 00:00:00 2001 From: Melon Bread Date: Thu, 16 May 2024 13:43:51 -0400 Subject: [PATCH] Invader can no longer shoot itself (hopefully) --- scenes/invader.tscn | 54 ++++++++++++++++++++++----------------------- scripts/invader.gd | 3 ++- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/scenes/invader.tscn b/scenes/invader.tscn index f8095d6..b57c565 100644 --- a/scenes/invader.tscn +++ b/scenes/invader.tscn @@ -35,6 +35,33 @@ shader_parameter/strength = 1.0 shader_parameter/noise_tex_normal = SubResource("NoiseTexture2D_vfidg") shader_parameter/noise_tex = SubResource("NoiseTexture2D_ca84o") +[sub_resource type="Animation" id="Animation_cojig"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("CrashSound:playing") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Sprite2D:material:shader_parameter/progress") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [null] +} + [sub_resource type="Animation" id="Animation_l62j8"] resource_name = "crash" length = 0.4 @@ -80,33 +107,6 @@ tracks/2/keys = { "values": [null, 0.33, 0.66, 1.0] } -[sub_resource type="Animation" id="Animation_cojig"] -length = 0.001 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("CrashSound:playing") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 1, -"values": [false] -} -tracks/1/type = "value" -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/path = NodePath("Sprite2D:material:shader_parameter/progress") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [null] -} - [sub_resource type="AnimationLibrary" id="AnimationLibrary_1dk2o"] _data = { "RESET": SubResource("Animation_cojig"), diff --git a/scripts/invader.gd b/scripts/invader.gd index e1472e6..8a05aa7 100644 --- a/scripts/invader.gd +++ b/scripts/invader.gd @@ -32,7 +32,7 @@ func _process(delta: float) -> void: if can_shoot: # FIXME: Proper shoot angle and not able to sudoku - shoot($GunMarker.global_position, randf_range(90.0, 100.0)) + shoot($GunMarker.global_position, randf_range(90.0, 92.0)) # "Die", if off screen if position.x > viewport_size.x or position.x < 0: @@ -54,6 +54,7 @@ func shoot(pos : Vector2, rot : float) -> void: var bullet := BULLET.instantiate() bullet.position = pos bullet.rotation = rot + bullet.life_span = 0.3 $Projectiles.add_child(bullet) $ShootSound.play() can_shoot = false