From 3aced7fd195199f5e8a541ae5fa8414c0fe86b7b Mon Sep 17 00:00:00 2001 From: limuy Date: Sun, 25 Aug 2024 20:26:00 +0800 Subject: [PATCH] feat:implement of star wrath explosion --- gdrust/src/bullets/star_wrath_bullet.rs | 6 ++-- gdrust/src/weapons/star_wrath.rs | 3 +- scenes/bullets/star_wrath/little_star.gd | 24 +++++++++++++ scenes/bullets/star_wrath/little_star.tscn | 12 +++++++ scenes/bullets/star_wrath/littlestar.png | Bin 0 -> 351 bytes .../bullets/star_wrath/littlestar.png.import | 34 ++++++++++++++++++ scenes/bullets/star_wrath/littlestar.pxo | Bin 0 -> 751 bytes scenes/bullets/star_wrath/point.gd | 16 +++++++++ scenes/bullets/star_wrath/point.png | Bin 0 -> 230 bytes scenes/bullets/star_wrath/point.png.import | 34 ++++++++++++++++++ scenes/bullets/star_wrath/point.pxo | Bin 0 -> 689 bytes scenes/bullets/star_wrath/point.tscn | 3 ++ .../bullets/star_wrath/star_wrath_original.gd | 18 +++++++++- scenes/weapons/star_wrath/star_wrath.gd | 26 ++++++++++++-- 14 files changed, 169 insertions(+), 7 deletions(-) create mode 100644 scenes/bullets/star_wrath/little_star.gd create mode 100644 scenes/bullets/star_wrath/little_star.tscn create mode 100644 scenes/bullets/star_wrath/littlestar.png create mode 100644 scenes/bullets/star_wrath/littlestar.png.import create mode 100644 scenes/bullets/star_wrath/littlestar.pxo create mode 100644 scenes/bullets/star_wrath/point.gd create mode 100644 scenes/bullets/star_wrath/point.png create mode 100644 scenes/bullets/star_wrath/point.png.import create mode 100644 scenes/bullets/star_wrath/point.pxo create mode 100644 scenes/bullets/star_wrath/point.tscn diff --git a/gdrust/src/bullets/star_wrath_bullet.rs b/gdrust/src/bullets/star_wrath_bullet.rs index dc17704..9f1013b 100644 --- a/gdrust/src/bullets/star_wrath_bullet.rs +++ b/gdrust/src/bullets/star_wrath_bullet.rs @@ -7,9 +7,8 @@ use rand::{thread_rng, Rng}; use std::f32::consts::PI; use crate::player::Player; -use crate::utils::screen_effects::ScreenEffects; use crate::utils::split_to_vec; -use crate::{debug_check, get_global, godot_debug_assert}; +use crate::{debug_check, godot_debug_assert}; #[derive(GodotClass)] #[class(base=Area2D)] @@ -17,6 +16,8 @@ pub struct StarWrathBullet { base: Base, direct: Vector2, speed: i32, + #[var] + explode: bool, } const SPEED_MIN: i32 = 300; @@ -31,6 +32,7 @@ impl IArea2D for StarWrathBullet { base, direct: Vector2::ZERO, speed: 0, + explode: false, } } diff --git a/gdrust/src/weapons/star_wrath.rs b/gdrust/src/weapons/star_wrath.rs index a0f5027..7d63a26 100644 --- a/gdrust/src/weapons/star_wrath.rs +++ b/gdrust/src/weapons/star_wrath.rs @@ -83,9 +83,10 @@ impl StarWrath { #[func] /// 新建一个从天而降垂直下落的弹幕 - fn fall_star(&mut self) { + fn fall_star(&mut self, explode: bool) { let bullet = self.get_bullet_scene(); let mut star = bullet.instantiate_as::(); + star.bind_mut().set_explode(explode); const SZ_TO_SIDE: f32 = 200.0; let sz = self.base_mut().get_viewport_rect().size.x - SZ_TO_SIDE; let random_x = thread_rng().gen_range(SZ_TO_SIDE..sz); diff --git a/scenes/bullets/star_wrath/little_star.gd b/scenes/bullets/star_wrath/little_star.gd new file mode 100644 index 0000000..c728594 --- /dev/null +++ b/scenes/bullets/star_wrath/little_star.gd @@ -0,0 +1,24 @@ +extends Sprite2D + +const SPEED: float = 90 +var direct + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + set_process(false) + + +func shoot(direction: Vector2): + assert(direction.length() > 0) + self.direct = direction.normalized() + set_process(true) + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + self.position += delta * SPEED * direct + + +func _on_visible_on_screen_notifier_2d_screen_exited() -> void: + queue_free() diff --git a/scenes/bullets/star_wrath/little_star.tscn b/scenes/bullets/star_wrath/little_star.tscn new file mode 100644 index 0000000..c3896a1 --- /dev/null +++ b/scenes/bullets/star_wrath/little_star.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=3 format=3 uid="uid://dtboow2wo76hq"] + +[ext_resource type="Texture2D" uid="uid://dsq0jnh5u5avq" path="res://scenes/bullets/star_wrath/littlestar.png" id="1_hkmep"] +[ext_resource type="Script" path="res://scenes/bullets/star_wrath/little_star.gd" id="2_kxmji"] + +[node name="LittleStar" type="Sprite2D"] +texture = ExtResource("1_hkmep") +script = ExtResource("2_kxmji") + +[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="."] + +[connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"] diff --git a/scenes/bullets/star_wrath/littlestar.png b/scenes/bullets/star_wrath/littlestar.png new file mode 100644 index 0000000000000000000000000000000000000000..54632f37f7e89eef1654044d15dbec431b270b0f GIT binary patch literal 351 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D%zB|TjnLn`LH zo$1NfY{0`Xca{CK6El_b{ro*bL$@7?K61vkTfNV>g#)M$2z~@lU+K2)e^-o+RmDUH zM#&~|K~2H#f86`dWS@w0TJOMihc(6XFK;;G%_i}}HH_g+{VSNSG`!$-d90-H`0o9R z8n!*rY^in^cbkO9`ZHdetGKtpxQdlmKVfmG%jUg4LRFggdL5 zp?uC;v5u)m{G4HL14@Iq1vU3G_g$Fu;H!yQ^pfzF=?s&P2Q15PF_!x;6(VkM>18)d z+JT$0--TY@V*B27Px^TvN379;Guf70YOmH$=y;T@aryl^>lL{lq8+jy2nt=EdtrTx r;HDETyL?KwOj~vCF)PHM3=N#}g5Qf@1eO&p1&MgN`njxgN@xNArCf)N literal 0 HcmV?d00001 diff --git a/scenes/bullets/star_wrath/littlestar.png.import b/scenes/bullets/star_wrath/littlestar.png.import new file mode 100644 index 0000000..bbd3fdd --- /dev/null +++ b/scenes/bullets/star_wrath/littlestar.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dsq0jnh5u5avq" +path="res://.godot/imported/littlestar.png-3be6e558e4d3350cfb1e4879ffa30bd8.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scenes/bullets/star_wrath/littlestar.png" +dest_files=["res://.godot/imported/littlestar.png-3be6e558e4d3350cfb1e4879ffa30bd8.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 diff --git a/scenes/bullets/star_wrath/littlestar.pxo b/scenes/bullets/star_wrath/littlestar.pxo new file mode 100644 index 0000000000000000000000000000000000000000..a140c1694e246c0fe741df504d50d2cc15b50040 GIT binary patch literal 751 zcmWIWW@Zs#VBp|j(3vM0xz|kEDS(lIp^1rsfs=uOAtkXSQ7@}FKQDLU+1$ehJgwoH z6=h9JG;2O+xhfi%y%m_K>NqLZ+EFidad1gv-eg;^|E8R`CUe@^f2zGA`E4I3JJ*E0 z`&1p~Znj%B$#mtVUsB2`vyX2(I7^}Vm`mR*E{_EzkNlp#c9mkAtEg@(YU-+Epp^35 zo9SBOxsB~Pvk!P~)Lb$7r+8$HiJWq@vDf!yj%%d!rnN{_f4cl;uUhbmTVf_{XH2b+ zFAFklQ%+HR%sJsJHE(>A<*{{8Fg$C=s*ZTGG^EHas0ec!gt+23v5 zmPuCM^13b+C3vz&e&OY1>7OlAzGQ6-cc`|3ve}l~U(^2X;SywD{^!cg*}J?C1bc4M zQa@@McG{9@zQ;+y%hPwhd%kOZ>hkwfH|MzhDVe^+y3l1!TE5J@VvG5&uE;UBr(TF( zD8Di9@4vJk+wGTUFjblsHY;q+u#jm}|K?dOYO0Z{1hjXt41~-EP1A{b>%FInn zPmKo!zJ6L!Vs2`&zM+0jVr6Pkyy4p`fqbq860C{U+t^;K$;~op5_x+4TurCD`P|1w zJd;#BCoR!GbJ@auzT&A{esBHX9{IOt?heMC_3P(es=wm*!aiF)C&7OE{v~(+mHqOr zUKe*UcImxW`KgojfB)a%U-DVLtmEBRdx8JC3ftAMyp!2l-F<8B; void: + hide() + set_process(false) + + +func work(): + set_process(true) + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass diff --git a/scenes/bullets/star_wrath/point.png b/scenes/bullets/star_wrath/point.png new file mode 100644 index 0000000000000000000000000000000000000000..2bc0cdb72dd255cedd3fc5343c9d062356ea45a1 GIT binary patch literal 230 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D$|7I?ZihE&XX zd*dK)vjGolK*G#-_I}efZ6lpL)?R6nop67*lIpj9ewE8CK*bCfPS_+}zWyu5zBc-q zd#3Nw*|pg<>$N&IG1O(+g|q|+9k4&!{zl*uv&E&F6FiEh4aT$hBNcTdyYG44VwqF< zOEH=2mVX0-o4CO&5E1p8;SWcuPL=vQrbzDmt^0V}uDxem__h1OwW;@57(w>Ec*5J> VVj|~Kla~PEdb;|#taD0e0sxDkQe6N5 literal 0 HcmV?d00001 diff --git a/scenes/bullets/star_wrath/point.png.import b/scenes/bullets/star_wrath/point.png.import new file mode 100644 index 0000000..ed925c6 --- /dev/null +++ b/scenes/bullets/star_wrath/point.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cyrklccri8jt4" +path="res://.godot/imported/point.png-0d81272545105e3a341cfa9087101a89.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scenes/bullets/star_wrath/point.png" +dest_files=["res://.godot/imported/point.png-0d81272545105e3a341cfa9087101a89.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 diff --git a/scenes/bullets/star_wrath/point.pxo b/scenes/bullets/star_wrath/point.pxo new file mode 100644 index 0000000000000000000000000000000000000000..a32597d493545c9bbdbf0dbad711d7058f1ccf9a GIT binary patch literal 689 zcmWIWW@Zs#VBp|jP+BAzxz|kEDS(lIp^1rsfs=uOAtkXSQ7@}FKQDLU+1$ehJgwoH z6=h9JG;2O+xhfi%y%m_K>NqLZ+EFidad1gv-eg;^|E8R`CUe@^f2zGA`E4I3JJ*E0 z`&1p~Znj%B$#mtVUsB2`vyX2(I7^}Vm`mR*E{_EzkNlp#c9mkAtEg@(YU-+Epp^35 zo9SBOxsB~Pvk!P~)Lb$7r+8$HiJWq@vDf!yj%%d!rnN{_f4cl;uUhbmTVf_{XH2b+ zFAFklQ%+HR%sJsJHE(>A<*{{8Fg$C=s*ZTGG^EHas0ec!gt+23v5 zmPuCM^13b+C3vz&e&OY1>7OlAzGQ6-cc`|3ve}l~U(^2X;SywD{^!cg*}J?C1bc4M zQa@@McG{9@zQ;+y%hPwhd%kOZ>hkwfH|MzhDVe^+y3l1!TE5J@VvG5&uE;UBr(TF( zD8Di9@4vJk+wGTUFjblsHY;q+u#jm}|K?dOYO0Y}#IxuGggPXyDfk7HbW#%TP zr^bT$-^43qfz52;Ft(~>{TR|>hXn3C!;LQk32DlRkNEtA#Kmk0dpld_-983cP bLpe}49 void: hide() +func explode_effect(callback): + for i in range(3): + var direct = PI / 12 + for j in range(10): + var littlestar = littlestar_scene.instantiate() + littlestar.shoot(direct * j) + add_child(littlestar) + await get_tree().create_timer(0.1).timeout + callback.call() + + func _on_killer_screen_exited() -> void: await get_tree().create_timer(0.5).timeout - queue_free() + if self.explode: + # 爆炸 + self.explode_effect(queue_free) + else: + queue_free() diff --git a/scenes/weapons/star_wrath/star_wrath.gd b/scenes/weapons/star_wrath/star_wrath.gd index 31360f2..aa94ce9 100644 --- a/scenes/weapons/star_wrath/star_wrath.gd +++ b/scenes/weapons/star_wrath/star_wrath.gd @@ -2,11 +2,17 @@ extends StarWrath @export var star_wrath_origin: PackedScene var operation_idx = 0 -# func(): self.fall_star_process(), -var operations = [func(): self.beam_shoot1(), func(): self.leave()] +var operations = [ + func(): self.fall_star_process(), + func(): self.beam_shoot1(), + func(): self.fall_star_explode(), + func(): five_surrounding_points(), + func(): self.leave() +] @onready var animation_player = $AnimationPlayer @onready var star_wrath = $StarWrath var beam_scene: PackedScene = preload("res://scenes/bullets/star_wrath/laser_beam.tscn") +var point_scene: PackedScene = preload("res://scenes/bullets/star_wrath/point.tscn") func next_operation(): @@ -20,11 +26,25 @@ func next_operation(): func fall_star_process(): for i in range(10): - self.fall_star() + self.fall_star(false) await get_tree().create_timer(randf_range(1.0, 2.0)).timeout next_operation() +func fall_star_explode(): + for i in range(4): + self.fall_star(true) + await get_tree().create_timer(randf_range(5.0, 6.0)).timeout + next_operation() + + +func five_surrounding_points(): + var points = [] + for i in range(5): + var point = point_scene.instantiate() + points.push_back(point) + + func beam_shoot1(): var beam = beam_scene.instantiate() self.add_child(beam)