Compare commits
2 Commits
24d45d1e9c
...
85e0ca75ff
| Author | SHA1 | Date |
|---|---|---|
|
|
85e0ca75ff | |
|
|
89446660c0 |
Binary file not shown.
|
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://cn7yee27ivj7b"
|
||||
path="res://.godot/imported/laser.wav-ff32fed33cb3ccbcd074381583780fec.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/music&sfx/sfx/laser.wav"
|
||||
dest_files=["res://.godot/imported/laser.wav-ff32fed33cb3ccbcd074381583780fec.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=2
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
[gd_scene format=3 uid="uid://d2mpjsuueg0bn"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bdhx27edemfce" path="res://scripts/beam.gd" id="1_beam00"]
|
||||
[ext_resource type="Texture2D" uid="uid://dxox0vjihmukh" path="res://assets/Fire Pixel Bullet 16x16/All_Fire_Bullet_Pixel_16x16_05.png" id="2_hl8vi"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_daiji"]
|
||||
atlas = ExtResource("2_hl8vi")
|
||||
region = Rect2(96, 0, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_bawts"]
|
||||
atlas = ExtResource("2_hl8vi")
|
||||
region = Rect2(112, 0, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_8wlve"]
|
||||
atlas = ExtResource("2_hl8vi")
|
||||
region = Rect2(128, 0, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_bt3ye"]
|
||||
atlas = ExtResource("2_hl8vi")
|
||||
region = Rect2(144, 0, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_a06w7"]
|
||||
atlas = ExtResource("2_hl8vi")
|
||||
region = Rect2(96, 16, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_5fvdj"]
|
||||
atlas = ExtResource("2_hl8vi")
|
||||
region = Rect2(112, 16, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_djxf5"]
|
||||
atlas = ExtResource("2_hl8vi")
|
||||
region = Rect2(128, 16, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_eeead"]
|
||||
atlas = ExtResource("2_hl8vi")
|
||||
region = Rect2(144, 16, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qfoqh"]
|
||||
atlas = ExtResource("2_hl8vi")
|
||||
region = Rect2(96, 32, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tuykp"]
|
||||
atlas = ExtResource("2_hl8vi")
|
||||
region = Rect2(112, 32, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_2dcgn"]
|
||||
atlas = ExtResource("2_hl8vi")
|
||||
region = Rect2(128, 32, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_7703o"]
|
||||
atlas = ExtResource("2_hl8vi")
|
||||
region = Rect2(144, 32, 16, 16)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_beam0"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_daiji")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_bawts")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_8wlve")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_bt3ye")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"end",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_a06w7")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_5fvdj")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_djxf5")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_eeead")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"middle",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qfoqh")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_tuykp")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_2dcgn")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_7703o")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"start",
|
||||
"speed": 10.0
|
||||
}]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_beam0"]
|
||||
size = Vector2(16, 8)
|
||||
|
||||
[node name="Beam" type="Area2D" unique_id=968931754]
|
||||
script = ExtResource("1_beam00")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=100000001]
|
||||
texture_filter = 1
|
||||
sprite_frames = SubResource("SpriteFrames_beam0")
|
||||
animation = &"end"
|
||||
frame_progress = 0.02647079
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=100000002]
|
||||
shape = SubResource("RectangleShape2D_beam0")
|
||||
disabled = true
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
[gd_scene format=3 uid="uid://claser0spell1"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/laser.gd" id="1_laser0"]
|
||||
|
||||
[node name="Laser" type="Node2D"]
|
||||
script = ExtResource("1_laser0")
|
||||
|
|
@ -8,6 +8,7 @@ const SHURIKEN = "SHURIKEN"
|
|||
const FIREBALL = "FIREBALL"
|
||||
const FIRE_SWIRL = "FIRE_SWIRL"
|
||||
const TORNADO = "TORNADO"
|
||||
const LASER = "LASER"
|
||||
|
||||
# Each spell's display recipe: sorted apples-first, grapes-last
|
||||
var recipes: Dictionary = {
|
||||
|
|
@ -15,6 +16,7 @@ var recipes: Dictionary = {
|
|||
FIREBALL: [APPLE, APPLE, APPLE],
|
||||
FIRE_SWIRL: [APPLE, APPLE, GRAPE],
|
||||
TORNADO: [GRAPE, GRAPE, GRAPE],
|
||||
LASER: [],
|
||||
}
|
||||
|
||||
# Takes cauldron slot_states (uses texture indices: 2 = apple, 4 = grape)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
extends Area2D
|
||||
|
||||
@export var beam_type := "middle"
|
||||
|
||||
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
|
||||
@onready var shape: CollisionShape2D = $CollisionShape2D
|
||||
|
||||
func _ready() -> void:
|
||||
if sprite.sprite_frames.has_animation(beam_type):
|
||||
sprite.play(beam_type)
|
||||
shape.disabled = beam_type != "middle"
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bdhx27edemfce
|
||||
|
|
@ -14,6 +14,7 @@ func _ready() -> void:
|
|||
SpellLibrary.SHURIKEN: _witch.shoot_shuriken,
|
||||
SpellLibrary.FIRE_SWIRL: _witch.shoot_fire_swirl,
|
||||
SpellLibrary.TORNADO: _witch.shoot_tornado,
|
||||
SpellLibrary.LASER: _witch.shoot_laser,
|
||||
}
|
||||
_build_ui()
|
||||
hide()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,140 @@
|
|||
extends Node2D
|
||||
|
||||
const BEAM_DURATION := 3.0
|
||||
const PRIMARY_TICK_DMG := 40
|
||||
const SPLASH_TICK_DMG := 3
|
||||
const TICK_INTERVAL := 0.5
|
||||
const SWEEP_RATE := 22.0
|
||||
|
||||
@export var segment_size := 16.0
|
||||
@export var start_offset := 24.0
|
||||
|
||||
@onready var perk_effects = get_node("/root/Game/PerkEffects")
|
||||
|
||||
var beam_seg := preload("res://scenes/beam.tscn")
|
||||
var target: Node2D = null
|
||||
var all_segs: Array = []
|
||||
var mid_segs: Array = []
|
||||
var tick_timer := 0.0
|
||||
var elapsed := 0.0
|
||||
var done := false
|
||||
var current_angle := 0.0
|
||||
var sweep_to := 0.0
|
||||
var sweeping := false
|
||||
|
||||
func _ready() -> void:
|
||||
target = get_highest_hp_enemy()
|
||||
if target == null:
|
||||
queue_free()
|
||||
return
|
||||
current_angle = global_position.direction_to(target.global_position).angle()
|
||||
rebuild_segments()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if done:
|
||||
return
|
||||
elapsed += delta
|
||||
tick_timer += delta
|
||||
|
||||
if sweeping:
|
||||
current_angle = lerp_angle(current_angle, sweep_to, 1.0 - exp(-SWEEP_RATE * delta))
|
||||
if abs(angle_difference(current_angle, sweep_to)) < 0.005:
|
||||
current_angle = sweep_to
|
||||
sweeping = false
|
||||
rebuild_segments()
|
||||
|
||||
if tick_timer >= TICK_INTERVAL:
|
||||
tick_timer -= TICK_INTERVAL
|
||||
do_damage_tick()
|
||||
if elapsed >= BEAM_DURATION:
|
||||
done = true
|
||||
cleanup()
|
||||
|
||||
func rebuild_segments() -> void:
|
||||
var dir := Vector2.from_angle(current_angle)
|
||||
var beam_start := global_position + dir * start_offset
|
||||
var dest_dist := global_position.distance_to(target.global_position)
|
||||
var beam_dist := dest_dist - start_offset
|
||||
var n_mid := int(max(0.0, beam_dist - segment_size) / segment_size)
|
||||
|
||||
var positions: Array = [beam_start]
|
||||
var types: Array = ["start"]
|
||||
for i in range(n_mid):
|
||||
positions.append(beam_start + dir * (segment_size * float(i + 1)))
|
||||
types.append("middle")
|
||||
positions.append(beam_start + dir * (segment_size * float(n_mid + 1)))
|
||||
types.append("end")
|
||||
|
||||
while all_segs.size() < positions.size():
|
||||
var seg = beam_seg.instantiate()
|
||||
get_parent().add_child(seg)
|
||||
all_segs.append(seg)
|
||||
while all_segs.size() > positions.size():
|
||||
var seg = all_segs.pop_back()
|
||||
if is_instance_valid(seg):
|
||||
seg.queue_free()
|
||||
|
||||
mid_segs.clear()
|
||||
for i in range(all_segs.size()):
|
||||
var seg = all_segs[i]
|
||||
if not is_instance_valid(seg):
|
||||
continue
|
||||
seg.global_position = positions[i]
|
||||
seg.rotation = current_angle
|
||||
if seg.beam_type != types[i]:
|
||||
seg.beam_type = types[i]
|
||||
seg.shape.disabled = types[i] != "middle"
|
||||
if seg.sprite.sprite_frames.has_animation(types[i]):
|
||||
seg.sprite.play(types[i])
|
||||
if types[i] == "middle":
|
||||
mid_segs.append(seg)
|
||||
|
||||
if all_segs.size() > 1 and is_instance_valid(all_segs[0]):
|
||||
var ref_frame: int = all_segs[0].sprite.frame
|
||||
var ref_progress: float = all_segs[0].sprite.frame_progress
|
||||
for i in range(1, all_segs.size()):
|
||||
var seg = all_segs[i]
|
||||
if is_instance_valid(seg):
|
||||
seg.sprite.frame = ref_frame
|
||||
seg.sprite.frame_progress = ref_progress
|
||||
|
||||
func retarget(new_target: Node2D) -> void:
|
||||
target = new_target
|
||||
sweep_to = global_position.direction_to(new_target.global_position).angle()
|
||||
sweeping = true
|
||||
|
||||
func do_damage_tick() -> void:
|
||||
if (not is_instance_valid(target) or target.is_dying) and perk_effects.laser_retarget_enabled:
|
||||
var new_target = get_highest_hp_enemy()
|
||||
if new_target != null:
|
||||
retarget(new_target)
|
||||
|
||||
if is_instance_valid(target) and not target.is_dying:
|
||||
target.take_damage(PRIMARY_TICK_DMG)
|
||||
|
||||
var hit: Array = []
|
||||
for seg in mid_segs:
|
||||
if not is_instance_valid(seg):
|
||||
continue
|
||||
for body in seg.get_overlapping_bodies():
|
||||
if body.is_in_group("enemies") and not body.is_dying \
|
||||
and body != target and not hit.has(body):
|
||||
body.take_damage(SPLASH_TICK_DMG)
|
||||
hit.append(body)
|
||||
|
||||
func cleanup() -> void:
|
||||
for seg in all_segs:
|
||||
if is_instance_valid(seg):
|
||||
seg.queue_free()
|
||||
queue_free()
|
||||
|
||||
func get_highest_hp_enemy() -> Node2D:
|
||||
var best: Node2D = null
|
||||
var best_hp: int = -1
|
||||
for enemy in get_tree().get_nodes_in_group("enemies"):
|
||||
if not is_instance_valid(enemy) or enemy.is_dying:
|
||||
continue
|
||||
if enemy.hp > best_hp:
|
||||
best_hp = enemy.hp
|
||||
best = enemy
|
||||
return best
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://dp6b3imslv10d
|
||||
|
|
@ -7,6 +7,7 @@ var throwing_knife = preload("res://scenes/throwing_knive.tscn")
|
|||
var cauldron
|
||||
var available_perks: Array[Perk] = []
|
||||
var fireball_aoe_enabled = false
|
||||
var laser_retarget_enabled = false
|
||||
var throwing_knife_enabled = false
|
||||
var throwing_knife_cooldown: float = 2.0
|
||||
var throwing_knife_count: int = 1
|
||||
|
|
@ -21,6 +22,7 @@ var _spellbook_angle: float = 0.0
|
|||
var _spellbooks: Array = []
|
||||
|
||||
var _icon_knife = preload("res://assets/weapons/knvie.png")
|
||||
var _icon_laser: AtlasTexture
|
||||
var _icon_book = preload("res://assets/books_set_2/books_pentagram.png")
|
||||
var _icon_brew = preload("res://assets/books_set_2/books_health_potion.png")
|
||||
var _icon_shuriken: AtlasTexture
|
||||
|
|
@ -51,6 +53,19 @@ func _ready() -> void:
|
|||
_icon_player.atlas = preload("res://assets/Swordsman_lvl1/Without_shadow/Swordsman_lvl1_Idle_without_shadow.png")
|
||||
_icon_player.region = Rect2(0, 0, 64, 64)
|
||||
|
||||
_icon_laser = AtlasTexture.new()
|
||||
_icon_laser.atlas = preload("res://assets/Fire Pixel Bullet 16x16/All_Fire_Bullet_Pixel_16x16_05.png")
|
||||
_icon_laser.region = Rect2(96, 16, 16, 16)
|
||||
|
||||
var lrt = Perk.new()
|
||||
lrt.name = "Laser Lock-On"
|
||||
lrt.description = "Laser retargets to the next highest health enemy on kill"
|
||||
lrt.stats = _stat_toggle("Retarget")
|
||||
lrt.spell = SpellLibrary.LASER
|
||||
lrt.icon = _icon_laser
|
||||
lrt.effect = laser_retarget
|
||||
available_perks.append(lrt)
|
||||
|
||||
var dsh = Perk.new()
|
||||
dsh.name = "Double Shuriken"
|
||||
dsh.description = "Fire two shurikens at once"
|
||||
|
|
@ -135,6 +150,9 @@ func _process(delta: float) -> void:
|
|||
var offset = (TAU / _spellbooks.size()) * i
|
||||
_spellbooks[i].global_position = witch.global_position + Vector2(cos(_spellbook_angle + offset), sin(_spellbook_angle + offset)) * SPELLBOOK_RADIUS
|
||||
|
||||
func laser_retarget():
|
||||
laser_retarget_enabled = true
|
||||
|
||||
func double_shuriken():
|
||||
witch.shuriken_count = 2
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,10 @@ var fireball = preload("res://scenes/fireball.tscn")
|
|||
var shuriken = preload("res://scenes/shuriken.tscn")
|
||||
var fire_swirl = preload("res://scenes/fire_swirl.tscn")
|
||||
var tornado = preload("res://scenes/tornado.tscn")
|
||||
var laser = preload("res://scenes/laser.tscn")
|
||||
var shuriken_count = 1
|
||||
var _fire_sfx = preload("res://assets/music&sfx/sfx/fire.wav")
|
||||
var _fire_sfx = preload("res://assets/music&sfx/sfx/fire.wav")
|
||||
var _laser_sfx = preload("res://assets/music&sfx/sfx/laser.wav")
|
||||
|
||||
var max_hp: int = 100
|
||||
var current_hp: int = 100
|
||||
|
|
@ -100,6 +102,19 @@ func shoot_tornado():
|
|||
get_parent().add_child(tw)
|
||||
camera.shake(0.3, 0.8)
|
||||
|
||||
func shoot_laser():
|
||||
var ls = laser.instantiate()
|
||||
ls.global_position = global_position
|
||||
get_parent().add_child(ls)
|
||||
camera.shake(0.4, 1.2)
|
||||
var asp = AudioStreamPlayer.new()
|
||||
asp.stream = _laser_sfx
|
||||
asp.volume_db = 6
|
||||
asp.bus = "SFX"
|
||||
get_parent().add_child(asp)
|
||||
asp.play()
|
||||
asp.finished.connect(asp.queue_free)
|
||||
|
||||
func take_damage(amount: int) -> void:
|
||||
if is_invincible:
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in New Issue