Skip to content

Commit

Permalink
feat:star wrath laser
Browse files Browse the repository at this point in the history
  • Loading branch information
limuy2022 committed Jul 12, 2024
1 parent 94ecf9a commit 1d6d216
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 6 deletions.
Binary file added scenes/bullets/star_wrath/glowing_circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions scenes/bullets/star_wrath/glowing_circle.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://ddf8ome85torc"
path="res://.godot/imported/glowing_circle.png-4c026c6aea7f4278a8e69a98fe54edcb.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://scenes/bullets/star_wrath/glowing_circle.png"
dest_files=["res://.godot/imported/glowing_circle.png-4c026c6aea7f4278a8e69a98fe54edcb.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
68 changes: 68 additions & 0 deletions scenes/bullets/star_wrath/laser_beam.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
extends RayCast2D

@export var cast_speed = 7000.0
@export var max_length = 1400.0
@export var growth_time = 0.5

var is_casting = false
var tween
@onready var fill = $Line2D
@onready var casting_particles = $CastingParticles
@onready var collision_particles = $CollisionParticles
@onready var beam_particles = $BeamParticles
@onready var line_width = fill.width


# Called when the node enters the scene tree for the first time.
func _ready() -> void:
set_physics_process(false)
fill.points[1] = Vector2.ZERO
tween = create_tween()


func _physics_process(delta: float) -> void:
target_position = (target_position + Vector2.RIGHT * cast_speed * delta).limit_length(
max_length
)
cast_beam()


func cast_beam():
var cast_point = target_position
force_raycast_update()
var status = is_colliding()
collision_particles.emitting = status
if status:
cast_point = to_local(get_collision_point())
collision_particles.global_rotation = get_collision_normal().angle()
collision_particles.global_position = get_collision_point()
fill.points[1] = cast_point
beam_particles.position = cast_point * 0.5
beam_particles.process_material.emission_box_extents.x = cast_point.length() * 0.5


func set_is_casting(cast: bool) -> void:
is_casting = cast
if is_casting:
target_position = Vector2.ZERO
fill.points[1] = target_position
appear()
else:
fill.points[1] = Vector2.ZERO
collision_particles.emitting = false
disappear()
set_physics_process(is_casting)
beam_particles.emitting = is_casting
casting_particles.emitting = is_casting


func appear():
tween.kill()
tween = create_tween()
tween.tween_property(fill, "width", line_width, growth_time * 2).from(0)


func disappear():
tween.kill()
tween = create_tween()
tween.tween_property(fill, "width", 0, growth_time).from(line_width)
31 changes: 31 additions & 0 deletions scenes/bullets/star_wrath/laser_beam.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[gd_scene load_steps=5 format=3 uid="uid://cx8edyix2wwjs"]

[ext_resource type="Script" path="res://scenes/bullets/star_wrath/laser_beam.gd" id="1_pxjff"]

[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_ksbrs"]
particle_flag_disable_z = true
gravity = Vector3(0, 98, 0)

[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_nsxxn"]
particle_flag_disable_z = true
gravity = Vector3(0, 98, 0)

[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_025qw"]
particle_flag_disable_z = true
gravity = Vector3(0, 98, 0)

[node name="LaserBeam" type="RayCast2D"]
script = ExtResource("1_pxjff")

[node name="Line2D" type="Line2D" parent="."]
points = PackedVector2Array(0, 0, 100, 0)
closed = true

[node name="CastingParticles" type="GPUParticles2D" parent="."]
process_material = SubResource("ParticleProcessMaterial_ksbrs")

[node name="BeamParticles" type="GPUParticles2D" parent="."]
process_material = SubResource("ParticleProcessMaterial_nsxxn")

[node name="CollisionParticles" type="GPUParticles2D" parent="."]
process_material = SubResource("ParticleProcessMaterial_025qw")
7 changes: 6 additions & 1 deletion scenes/weapons/star_wrath/star_wrath.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ func next_operation():
operations[operation_idx].call()
operation_idx += 1


func fall_star_process():
for i in range(10):
self.fall_star()
await get_tree().create_timer(randf_range(1.0,2.0)).timeout
await get_tree().create_timer(randf_range(1.0, 2.0)).timeout


func laser():
pass
16 changes: 11 additions & 5 deletions scenes/weapons/star_wrath/star_wrath_root.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
extends Node

signal attack_finished
@onready var star_wrath = $StarWrath
@onready var bg = $Bg


# Called when the node enters the scene tree for the first time.
func _ready() -> void:
Expand All @@ -9,14 +12,17 @@ func _ready() -> void:
else:
hide()


func hide():
$StarWrath.hide()
$Bg.hide()
star_wrath.hide()
bg.hide()


func show():
$StarWrath.show()
$Bg.show()
star_wrath.show()
bg.show()


func start():
show()
$StarWrath.start()
star_wrath.start()

0 comments on commit 1d6d216

Please sign in to comment.