Skip to content

Commit

Permalink
Igniting by pressing 'I', not after 10 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
Janorico committed May 26, 2023
1 parent 0912e05 commit e6caf60
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 20 deletions.
5 changes: 5 additions & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ place_tnt_block={
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777240,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}
ignite_tnt={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":73,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}

[rendering]

Expand Down
82 changes: 69 additions & 13 deletions scenes/game/tnt_block.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=10 format=2]
[gd_scene load_steps=11 format=2]

[ext_resource path="res://assets/tnt.png" type="Texture" id=1]
[ext_resource path="res://assets/explosion.png" type="Texture" id=2]
Expand Down Expand Up @@ -26,6 +26,72 @@ albedo_texture = ExtResource( 2 )
[sub_resource type="QuadMesh" id=5]
material = SubResource( 4 )

[sub_resource type="Animation" id=6]
resource_name = "explode"
length = 3.0
tracks/0/type = "value"
tracks/0/path = NodePath("MeshInstance:visible")
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": 1,
"values": [ false ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("CollisionShape:disabled")
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": 1,
"values": [ true ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("Explosion:emitting")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ true ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("ExplosionSound:playing")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ true ]
}
tracks/4/type = "method"
tracks/4/path = NodePath(".")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/keys = {
"times": PoolRealArray( 3 ),
"transitions": PoolRealArray( 1 ),
"values": [ {
"args": [ ],
"method": "queue_free"
} ]
}

[node name="TNTBlock" type="StaticBody"]
script = ExtResource( 3 )

Expand All @@ -49,15 +115,5 @@ initial_velocity = 100.0
[node name="ExplosionSound" type="AudioStreamPlayer3D" parent="."]
stream = ExtResource( 4 )

[node name="Timer" type="Timer" parent="."]
wait_time = 10.0
one_shot = true
autostart = true

[node name="Timer2" type="Timer" parent="."]
wait_time = 12.0
one_shot = true
autostart = true

[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
[connection signal="timeout" from="Timer2" to="." method="queue_free"]
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/explode = SubResource( 6 )
12 changes: 5 additions & 7 deletions scripts/game/TNTBlock.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ extends StaticBody
const remove_radius = 5
var pw
var chunk_size
onready var mesh_instance: MeshInstance = $MeshInstance
onready var explosion: CPUParticles = $Explosion
onready var explosion_sound: AudioStreamPlayer3D = $ExplosionSound
onready var animation_player: AnimationPlayer = $AnimationPlayer


func _on_timer_timeout():
explosion.emitting = true
explosion_sound.play()
mesh_instance.hide()
func _physics_process(_delta):
if not Input.is_action_just_released("ignite_tnt"):
return
animation_player.play("explode")
var changed_chunks: Array = []
for x in range(translation.x - 5, translation.x + 5):
for y in range(translation.y - 5, translation.y + 5):
Expand Down

0 comments on commit e6caf60

Please sign in to comment.