Added explosion on laser destroy
This commit is contained in:
@@ -60,7 +60,7 @@ func _on_body_exited(body: Node) -> void:
|
||||
if not body.visible:
|
||||
return
|
||||
$BrickSound.play()
|
||||
body.hit(1)
|
||||
body.hit(1, false)
|
||||
hit_brick.emit(self, body, 1)
|
||||
speed += 1
|
||||
return
|
||||
|
||||
@@ -8,7 +8,7 @@ enum {
|
||||
INVULNERABLE
|
||||
}
|
||||
|
||||
signal brick_destroyed(brick : StaticBody2D)
|
||||
signal brick_destroyed(brick : StaticBody2D, is_laser : bool )
|
||||
|
||||
var hits : int = 1
|
||||
var value : int = 100
|
||||
@@ -22,7 +22,7 @@ func _ready() -> void:
|
||||
func _process(_delta) -> void:
|
||||
pass
|
||||
|
||||
func hit(power : int) -> void:
|
||||
func hit(power : int, is_laser : bool = false) -> void:
|
||||
if hits <= 0:
|
||||
return
|
||||
hits -= power
|
||||
@@ -33,7 +33,7 @@ func hit(power : int) -> void:
|
||||
visible = false
|
||||
get_tree().create_timer(5).timeout.connect(_show_block)
|
||||
return
|
||||
brick_destroyed.emit(self)
|
||||
brick_destroyed.emit(self, is_laser)
|
||||
get_parent().call_deferred("remove_child", self)
|
||||
call_deferred("queue_free")
|
||||
else:
|
||||
|
||||
13
Dunkanoid.gd
13
Dunkanoid.gd
@@ -6,6 +6,7 @@ var _Upgrade = preload("res://Upgrade/Upgrade.tscn")
|
||||
var _Alien = preload("res://Alien.tscn")
|
||||
var _Bullet = preload("res://Bullet.tscn")
|
||||
var _Coin = preload("res://Coin/Coin.tscn")
|
||||
var _Explosion = preload("res://Explosion.tscn")
|
||||
|
||||
@onready var ScoreNode = $ScoreCard/Score/ScoreBox
|
||||
@onready var LivesNode = $ScoreCard/Lives/LivesBox
|
||||
@@ -172,11 +173,18 @@ func new_level() -> void:
|
||||
add_child(ball)
|
||||
balls.push_back(ball)
|
||||
|
||||
get_tree().create_timer(2).timeout.connect(show_start)
|
||||
|
||||
func show_start() -> void:
|
||||
StartNode.visible = true
|
||||
Music.jingle_finished.connect(_on_start_round_finished)
|
||||
Music.jingle(Music.JINGLE_LEVEL_START)
|
||||
|
||||
func _brick_destroyed(brick) -> void:
|
||||
func _brick_destroyed(brick, is_laser) -> void:
|
||||
if is_laser:
|
||||
var exp = _Explosion.instantiate()
|
||||
exp.global_position = brick.global_position
|
||||
add_child(exp)
|
||||
Global.score += brick.value
|
||||
if randf() >= Global.get_powerup_percent():
|
||||
var upgrade = _Upgrade.instantiate()
|
||||
@@ -288,6 +296,7 @@ func _on_hit_floor(ball, _power) -> void:
|
||||
var tween = get_tree().create_tween()
|
||||
tween.tween_property($ColorRect, "color", Color(0, 0, 0, 1), 2)
|
||||
tween.finished.connect(_go_to_game_over)
|
||||
mode = MODE_WAIT
|
||||
else:
|
||||
PaddleNode.normal()
|
||||
ball = _Ball.instantiate()
|
||||
@@ -478,7 +487,7 @@ func fire_bullet() -> void:
|
||||
bullet.linear_velocity = Vector2(0, -500)
|
||||
|
||||
func _on_bullet_hit_brick(node, power) -> void:
|
||||
node.hit(power)
|
||||
node.hit(power, true)
|
||||
|
||||
func _on_bullet_hit_alien(node, power) -> void:
|
||||
node.hit(power)
|
||||
|
||||
@@ -45,8 +45,8 @@ distance = -360.0
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_kyxd5"]
|
||||
shader = ExtResource("12_ljnes")
|
||||
shader_parameter/rect_global_position = Vector2(0, 0)
|
||||
shader_parameter/rect_size = Vector2(150, 25)
|
||||
shader_parameter/rect_global_position = Vector2(0, 0.233687)
|
||||
shader_parameter/rect_size = Vector2(448, 25)
|
||||
shader_parameter/ColourTexture = ExtResource("13_u52d1")
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_48a5y"]
|
||||
@@ -304,6 +304,7 @@ size_flags_horizontal = 3
|
||||
theme = ExtResource("8_wcf7g")
|
||||
|
||||
[node name="Start" type="Node2D" parent="."]
|
||||
visible = false
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Start"]
|
||||
offset_right = 448.0
|
||||
|
||||
8
Explosion.gd
Normal file
8
Explosion.gd
Normal file
@@ -0,0 +1,8 @@
|
||||
extends AnimatedSprite2D
|
||||
|
||||
func _ready() -> void:
|
||||
play()
|
||||
|
||||
func _on_animation_finished() -> void:
|
||||
get_parent().remove_child(self)
|
||||
queue_free()
|
||||
132
Explosion.tscn
Normal file
132
Explosion.tscn
Normal file
@@ -0,0 +1,132 @@
|
||||
[gd_scene load_steps=20 format=3 uid="uid://cbbviq2amktyg"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://ujw718ywd8u0" path="res://Sprites/exp2_0.png" id="1_cyvtr"]
|
||||
[ext_resource type="Script" path="res://Explosion.gd" id="2_8h5ot"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_s33bc"]
|
||||
atlas = ExtResource("1_cyvtr")
|
||||
region = Rect2(0, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3xd2h"]
|
||||
atlas = ExtResource("1_cyvtr")
|
||||
region = Rect2(64, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_uwrba"]
|
||||
atlas = ExtResource("1_cyvtr")
|
||||
region = Rect2(128, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_88v8p"]
|
||||
atlas = ExtResource("1_cyvtr")
|
||||
region = Rect2(192, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_yyvey"]
|
||||
atlas = ExtResource("1_cyvtr")
|
||||
region = Rect2(0, 64, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_j5vsi"]
|
||||
atlas = ExtResource("1_cyvtr")
|
||||
region = Rect2(64, 64, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_dsnkr"]
|
||||
atlas = ExtResource("1_cyvtr")
|
||||
region = Rect2(128, 64, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_admx1"]
|
||||
atlas = ExtResource("1_cyvtr")
|
||||
region = Rect2(192, 64, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3wnhv"]
|
||||
atlas = ExtResource("1_cyvtr")
|
||||
region = Rect2(0, 128, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_y72wd"]
|
||||
atlas = ExtResource("1_cyvtr")
|
||||
region = Rect2(64, 128, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3gddx"]
|
||||
atlas = ExtResource("1_cyvtr")
|
||||
region = Rect2(128, 128, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3hlpl"]
|
||||
atlas = ExtResource("1_cyvtr")
|
||||
region = Rect2(192, 128, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_7ln8e"]
|
||||
atlas = ExtResource("1_cyvtr")
|
||||
region = Rect2(0, 192, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_8gc3j"]
|
||||
atlas = ExtResource("1_cyvtr")
|
||||
region = Rect2(64, 192, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wu4v4"]
|
||||
atlas = ExtResource("1_cyvtr")
|
||||
region = Rect2(128, 192, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_0r171"]
|
||||
atlas = ExtResource("1_cyvtr")
|
||||
region = Rect2(192, 192, 64, 64)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_hqhkv"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_s33bc")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_3xd2h")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_uwrba")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_88v8p")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_yyvey")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_j5vsi")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_dsnkr")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_admx1")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_3wnhv")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_y72wd")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_3gddx")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_3hlpl")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_7ln8e")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_8gc3j")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_wu4v4")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_0r171")
|
||||
}],
|
||||
"loop": false,
|
||||
"name": &"default",
|
||||
"speed": 12.0
|
||||
}]
|
||||
|
||||
[node name="Explosion" type="AnimatedSprite2D"]
|
||||
sprite_frames = SubResource("SpriteFrames_hqhkv")
|
||||
frame = 15
|
||||
frame_progress = 1.0
|
||||
script = ExtResource("2_8h5ot")
|
||||
|
||||
[connection signal="animation_finished" from="." to="." method="_on_animation_finished"]
|
||||
44
Music.gd
44
Music.gd
@@ -1,6 +1,7 @@
|
||||
extends Node
|
||||
|
||||
var MusicPlayer : AudioStreamPlayer
|
||||
var JinglePlayer : AudioStreamPlayer
|
||||
|
||||
enum {
|
||||
MUSIC_INTRO,
|
||||
@@ -44,6 +45,13 @@ func _ready() -> void:
|
||||
MusicPlayer.play()
|
||||
music = MUSIC_INTRO
|
||||
|
||||
JinglePlayer = AudioStreamPlayer.new();
|
||||
JinglePlayer.bus = "Music"
|
||||
JinglePlayer.process_mode = Node.PROCESS_MODE_ALWAYS
|
||||
JinglePlayer.finished.connect(_jingle_done)
|
||||
add_child(JinglePlayer)
|
||||
|
||||
|
||||
func fade_up(time : int = 1) -> void:
|
||||
if MusicPlayer.volume_db < 0:
|
||||
if tween != null:
|
||||
@@ -99,32 +107,32 @@ func resume() -> void:
|
||||
MusicPlayer.play(pausepos)
|
||||
|
||||
func jingle(item : int) -> void:
|
||||
MusicPlayer.volume_db = 0
|
||||
fade_down()
|
||||
# MusicPlayer.volume_db = 0
|
||||
jingle_number = item
|
||||
MusicPlayer.finished.connect(_jingle_done)
|
||||
pause()
|
||||
# pause()
|
||||
match item:
|
||||
JINGLE_LEVEL_START:
|
||||
MusicPlayer.stream = JingleFileStart
|
||||
MusicPlayer.play()
|
||||
JinglePlayer.stream = JingleFileStart
|
||||
JinglePlayer.play()
|
||||
JINGLE_LEVEL_WON:
|
||||
MusicPlayer.stream = JingleFileWin
|
||||
MusicPlayer.play()
|
||||
JinglePlayer.stream = JingleFileWin
|
||||
JinglePlayer.play()
|
||||
JINGLE_GAME_OVER:
|
||||
MusicPlayer.stream = JingleFileGameOver
|
||||
MusicPlayer.play()
|
||||
JinglePlayer.stream = JingleFileGameOver
|
||||
JinglePlayer.play()
|
||||
jingle_playing = true
|
||||
pass
|
||||
|
||||
func _jingle_done() -> void:
|
||||
MusicPlayer.finished.disconnect(_jingle_done)
|
||||
match music:
|
||||
MUSIC_INTRO:
|
||||
MusicPlayer.stream = MP3["Through The Crystal"]
|
||||
MUSIC_GAME:
|
||||
MusicPlayer.stream = MP3["Powerup"]
|
||||
MUSIC_GAME_OVER:
|
||||
MusicPlayer.stream = MP3["I'll Remember You"]
|
||||
resume()
|
||||
fade_up()
|
||||
#match music:
|
||||
#MUSIC_INTRO:
|
||||
#MusicPlayer.stream = MP3["Through The Crystal"]
|
||||
#MUSIC_GAME:
|
||||
#MusicPlayer.stream = MP3["Powerup"]
|
||||
#MUSIC_GAME_OVER:
|
||||
#MusicPlayer.stream = MP3["I'll Remember You"]
|
||||
#resume()
|
||||
jingle_playing = false
|
||||
jingle_finished.emit(jingle_number)
|
||||
|
||||
BIN
Sprites/exp2_0.png
Normal file
BIN
Sprites/exp2_0.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 46 KiB |
34
Sprites/exp2_0.png.import
Normal file
34
Sprites/exp2_0.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://ujw718ywd8u0"
|
||||
path="res://.godot/imported/exp2_0.png-44152cc6931a7ec14bd09dd90235659d.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Sprites/exp2_0.png"
|
||||
dest_files=["res://.godot/imported/exp2_0.png-44152cc6931a7ec14bd09dd90235659d.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
@@ -11,7 +11,7 @@ config_version=5
|
||||
[application]
|
||||
|
||||
config/name="Dunkanoid"
|
||||
config/version="1.0.1"
|
||||
config/version="1.0.2"
|
||||
run/main_scene="res://Intro.tscn"
|
||||
config/features=PackedStringArray("4.2", "Forward Plus")
|
||||
run/max_fps=30
|
||||
|
||||
Reference in New Issue
Block a user