Skip to content

Commit

Permalink
feat:develop bullets of seedler
Browse files Browse the repository at this point in the history
  • Loading branch information
limuy2022 committed Jul 8, 2024
1 parent 71a0c76 commit 83d75e1
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 16 deletions.
34 changes: 33 additions & 1 deletion scenes/bullets/seedler/seedler_nut.gd
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,45 @@ func burstShotBeam():
beams[i].is_fall = false
beams[i].position = position
var rad = TAU / times * i + (TAU / 12 if i % 2 == 0 else -TAU / 12)
beams[i].rotation = rad
beams[i].velocity = Vector2(sin(rad), cos(rad)) * 800
for beam in beams:
get_parent().add_child(beam)

# 启动超级爆炸
# 最大, 原地旋转
func superBurst(pos : Vector2):
const time = 0.8
const wait_time = 0.65
# TAU / s
const speed = 1.5 * TAU
position = pos
scale = Vector2(2, 2)
var tween = create_tween()
tween.tween_property(self, "rotation", rotation + speed * time, time)
tween.tween_callback(superBurstShotBeam.bind())
tween.tween_interval(wait_time)
tween.tween_callback(queue_free)

func superBurstShotBeam():
const times = 12
const num = 6
for j in range(num):
print("aaa")
var beams: Array[Area2D] = []
for i in range(times):
beams.push_back(thorns.instantiate())
beams[i].is_fall = false
beams[i].position = position
var rad = TAU / times * i + (TAU / 12 if i % 2 == 0 else -TAU / 12)
beams[i].velocity = Vector2(sin(rad), cos(rad)) * 800
for beam in beams:
get_parent().add_child(beam)
await get_tree().create_timer(0.1).timeout

func _ready():
$OutScreen.screen_exited.connect(queue_free)
throw()
superBurst(Vector2(300, 300))


func _process(delta):
Expand All @@ -81,3 +112,4 @@ func _on_area_entered(area):
if area.name == "Player":
area.get_node("..").hit(10)
$CollisionShape2D.set_deferred("disabled", true)

29 changes: 14 additions & 15 deletions scenes/weapons/seedler/seedler.gd
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
extends Sprite2D

const TIMES = 5
@onready var path = $"../Path2D"
@onready var follow = $"../Path2D/PathFollow2D"


func move(length: float) -> void:
func move(length : float) -> void:
follow.progress = length
position = follow.global_position


func _ready() -> void:
if get_tree().current_scene != $"..":
hide()
return

func start() -> void:
rotation = 0
follow.loop = 1
var start = 0
var end = path.curve.get_baked_length()
var mid = end / 2
var movement = create_tween().set_loops(TIMES).set_ease(Tween.EASE_IN).set_trans(
Tween.TRANS_SINE
)
var movement = create_tween().set_loops(times).set_ease(Tween.EASE_IN).set_trans(Tween.TRANS_SINE)
movement.tween_method(move, start, mid, 1)
movement.tween_method(move, mid, end, 1)
var rotate_animation = create_tween().set_loops(TIMES)
rotate_animation.tween_property(self, "rotation", TAU * 5, 2)
rotate_animation.tween_callback(func(): rotation = 0)
var rotate = create_tween().set_loops(times)
rotate.tween_property(self, "rotation", TAU * 5, 2)
rotate.tween_callback(func():rotation = 0)

const times = 5

func _ready() -> void:
if get_tree().current_scene == self:
start()

0 comments on commit 83d75e1

Please sign in to comment.