This commit is contained in:
Victor Turgeon 2023-10-10 17:21:41 -04:00
commit 90e33b6728
6 changed files with 158 additions and 24 deletions

51
Scenes/Props/candle.tscn Normal file
View File

@ -0,0 +1,51 @@
[gd_scene load_steps=9 format=3 uid="uid://dgtscjxcqoxls"]
[ext_resource type="Texture2D" uid="uid://dvtntmnfw83ms" path="res://Assets/RF_Catacombs_v1.0/candleA_02.png" id="1_24qhp"]
[ext_resource type="Texture2D" uid="uid://biomqy201h4yk" path="res://Assets/RF_Catacombs_v1.0/candleA_03.png" id="2_ntbip"]
[ext_resource type="Texture2D" uid="uid://dri12hbajn7f7" path="res://Assets/RF_Catacombs_v1.0/candleA_04.png" id="3_hqrx1"]
[ext_resource type="Texture2D" uid="uid://c0wvpyvnm1xyq" path="res://Assets/RF_Catacombs_v1.0/candleA_01.png" id="4_6sycj"]
[ext_resource type="Material" uid="uid://id4bl5ph4sbj" path="res://candle_part_material.tres" id="5_g2xr2"]
[sub_resource type="SpriteFrames" id="SpriteFrames_mdrfm"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("1_24qhp")
}, {
"duration": 1.0,
"texture": ExtResource("2_ntbip")
}, {
"duration": 1.0,
"texture": ExtResource("3_hqrx1")
}, {
"duration": 1.0,
"texture": ExtResource("4_6sycj")
}],
"loop": true,
"name": &"default",
"speed": 8.0
}]
[sub_resource type="Gradient" id="Gradient_0u7ax"]
[sub_resource type="GradientTexture2D" id="GradientTexture2D_pb6np"]
gradient = SubResource("Gradient_0u7ax")
[node name="Candle" type="Node2D"]
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
position = Vector2(-1.05837e-13, 4.76837e-07)
rotation = -3.14159
scale = Vector2(1.14286, 1.10476)
sprite_frames = SubResource("SpriteFrames_mdrfm")
frame_progress = 0.87695
centered = false
offset = Vector2(-3.5, -7)
flip_v = true
[node name="PointLight2D" type="PointLight2D" parent="."]
texture = SubResource("GradientTexture2D_pb6np")
[node name="Particles2D" type="GPUParticles2D" parent="."]
amount = 16
process_material = ExtResource("5_g2xr2")

File diff suppressed because one or more lines are too long

View File

@ -383,7 +383,23 @@ autoplay = "Idle"
frame_progress = 0.487368
flip_h = true
[node name="Hit" type="CPUParticles2D" parent="."]
emitting = false
amount = 12
lifetime = 0.2
one_shot = true
explosiveness = 0.75
randomness = 0.72
emission_shape = 1
emission_sphere_radius = 5.53
initial_velocity_min = 12.0
initial_velocity_max = 12.0
angular_velocity_min = 50.0
angular_velocity_max = 50.0
color = Color(0.623529, 0, 0, 0.729412)
[node name="Atk_cooldown" type="Timer" parent="."]
wait_time = 2.0
autostart = true
[node name="LvlUp" type="CPUParticles2D" parent="."]
@ -416,6 +432,7 @@ collision_layer = 2
collision_mask = 2
[node name="Attack1CollisionR" type="CollisionShape2D" parent="AttackArea"]
visible = false
position = Vector2(3, -7)
rotation = 1.5708
skew = 0.223402
@ -423,6 +440,7 @@ shape = SubResource("CapsuleShape2D_qykhm")
debug_color = Color(0.956863, 0.203922, 0, 0.419608)
[node name="Attack1CollisionL" type="CollisionShape2D" parent="AttackArea"]
visible = false
position = Vector2(-3, -7)
rotation = 1.5708
skew = -0.169297
@ -430,6 +448,7 @@ shape = SubResource("CapsuleShape2D_qykhm")
debug_color = Color(0.956863, 0.203922, 0, 0.419608)
[node name="Attack2CollisionR" type="CollisionShape2D" parent="AttackArea"]
visible = false
position = Vector2(25, -7)
rotation = 1.5708
skew = 0.0837758
@ -437,6 +456,7 @@ shape = SubResource("CapsuleShape2D_qykhm")
debug_color = Color(0.956863, 0.203922, 0, 0.419608)
[node name="Attack2CollisionL" type="CollisionShape2D" parent="AttackArea"]
visible = false
position = Vector2(-25, -7)
rotation = 1.5708
skew = -0.0837758

View File

@ -13,7 +13,9 @@ extends CharacterBody2D
@export var experience: int = 0
@export var state: String = "Idle"
@export var damage: int = 5
@export var maxAtks: int = 1
@onready var currAtks: int = 0
@onready var anim: Node = get_node("Sprite")
@onready var cooldown: Node = get_node("Atk_cooldown")
@onready var lvlanim: Node = get_node("LvlUp")
@ -24,6 +26,18 @@ extends CharacterBody2D
@onready var atk2l: Node = get_node("AttackArea/Attack2CollisionL")
@onready var atk2r: Node = get_node("AttackArea/Attack2CollisionR")
@onready var atkL: Node = atk1l
@onready var atkR: Node = atk1r
@onready var atk: String = "Attack"
@onready var list: Array = []
func add_foe(foe):
list.append(foe)
func remove_foe(foe):
list.erase(foe)
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
@ -36,11 +50,17 @@ func _process(delta):
elif !is_attacking:
setAnimState("Run")
is_facing_left = velocity.x >= 0
if state != "Attack" && state != "Attack2":
is_facing_left = velocity.x >= 0
# AI STUFF
#velocity = processAI(objects,velocity,delta)
#velocity += processAI(list,delta)
velocity.x += delta * 4
velocity.y += delta * 4
if !hitanim.is_emitting():
anim.modulate.a = 1
move_and_slide()
@ -54,26 +74,33 @@ func processAI(objs, delta):
func attack():
is_attacking = true
if (level > 1):
setAnimState("Attack2")
if is_facing_left:
atk2r.set_disabled(false)
else:
atk2l.set_disabled(false)
setAnimState(atk)
if is_facing_left:
atkL.set_disabled(false)
else:
setAnimState("Attack")
if is_facing_left:
atk1r.set_disabled(false)
else:
atk1l.set_disabled(false)
atkR.set_disabled(false)
#if (level > 3):
# setAnimState("Attack2")
# if is_facing_left:
# atk2r.set_disabled(false)
# else:
# atk2l.set_disabled(false)
# else:
# setAnimState("Attack")
# if is_facing_left:
# atk1r.set_disabled(false)
# else:
# atk1l.set_disabled(false)
func stop_attack():
is_attacking = false
atk1l.set_disabled(true)
atk1r.set_disabled(true)
atk2l.set_disabled(true)
atk2r.set_disabled(true)
atkL.set_disabled(true)
atkR.set_disabled(true)
#atk2l.set_disabled(true)
#atk2r.set_disabled(true)
func setAnimState(newstate):
@ -88,6 +115,7 @@ func receive_damage(dmg):
pass
hp -= dmg
hitanim.restart()
anim.modulate.a = 0.5
if hp < 0:
velocity = Vector2(0,0)
setAnimState("Die")
@ -101,27 +129,50 @@ func receive_exp(x):
setLevel(level + 1)
func setLevel(lvl):
level = lvl
lvlanim.restart()
lvlsnd.play()
if level > 2:
cooldown.wait_time = 0.5
if level > 3:
atk = "Attack2"
atkL = atk2l
atkR = atk2r
damage = 7
if level > 4:
cooldown.wait_time = 1
if level > 5:
damage = 12
if level > 7:
maxAtks = 2
maxhp += 5
hp += maxhp / 2
if hp > maxhp:
hp = maxhp
func _on_atk_cooldown_timeout():
currAtks = maxAtks
attack()
func _on_sprite_animation_looped():
if is_attacking:
currAtks -= 1
stop_attack()
if currAtks > 0:
is_facing_left = !is_facing_left
attack()
else:
currAtks = maxAtks
is_dying = false
func _on_attack_area_body_entered(body):
if typeof(body) == typeof(TemplateSpawnable):
body.receive_damage(damage)

13
candle_part_material.tres Normal file
View File

@ -0,0 +1,13 @@
[gd_resource type="ParticleProcessMaterial" format=3 uid="uid://id4bl5ph4sbj"]
[resource]
particle_flag_disable_z = true
direction = Vector3(0, -1, 0)
spread = 12.0
gravity = Vector3(0, 0, 0)
initial_velocity_min = 25.0
initial_velocity_max = 25.0
orbit_velocity_min = 0.0
orbit_velocity_max = 0.0
damping_min = 4.0
damping_max = 10.0

View File

@ -19,7 +19,6 @@ config/icon="res://icon.svg"
window/size/viewport_width=960
window/size/viewport_height=540
window/size/mode=3
window/size/resizable=false
window/stretch/mode="viewport"