Merge branch 'main' of https://github.com/MarcEricMartel/Game-Jam-A23
This commit is contained in:
commit
58bdfcfd73
@ -5,19 +5,13 @@
|
|||||||
|
|
||||||
[node name="BatSpawnable" instance=ExtResource("1_verf7")]
|
[node name="BatSpawnable" instance=ExtResource("1_verf7")]
|
||||||
maxHp = 10
|
maxHp = 10
|
||||||
attackSpeed = 10.0
|
attackSpeed = 50.0
|
||||||
speed = 2000.0
|
speed = 4000.0
|
||||||
damage = 1
|
damage = 1
|
||||||
priority = 1
|
priority = 1
|
||||||
|
|
||||||
[node name="AnimatedSprite2D" parent="." index="0"]
|
[node name="AnimatedSprite2D" parent="." index="0"]
|
||||||
frame_progress = 0.482614
|
frame_progress = 0.482614
|
||||||
|
|
||||||
[node name="AttackCollision" parent="Attack" index="0"]
|
[node name="AI" parent="." index="4"]
|
||||||
position = Vector2(8, 1)
|
|
||||||
|
|
||||||
[node name="DamageCollision" parent="Attack" index="1"]
|
|
||||||
position = Vector2(10, 1)
|
|
||||||
|
|
||||||
[node name="AI" parent="." index="3"]
|
|
||||||
script = ExtResource("2_x3ldf")
|
script = ExtResource("2_x3ldf")
|
||||||
|
@ -1,17 +1,21 @@
|
|||||||
class_name TemplateSpawnable
|
class_name TemplateSpawnable
|
||||||
extends CharacterBody2D
|
extends CharacterBody2D
|
||||||
|
|
||||||
|
const ATTACK_COOLDOWN : float = 100
|
||||||
|
|
||||||
@export var maxHp : int = 0
|
@export var maxHp : int = 0
|
||||||
@export var attackSpeed : float = 0
|
@export var attackSpeed : float = 0
|
||||||
@export var speed : float = 0
|
@export var speed : float = 0
|
||||||
@export var damage : int = 0
|
@export var damage : int = 0
|
||||||
@export var priority : int = 0
|
@export var priority : int = 0
|
||||||
|
@export var cost : int = 0
|
||||||
|
@export var minSpawnRange : float = 0
|
||||||
@export var canAttack : bool = true
|
@export var canAttack : bool = true
|
||||||
|
|
||||||
@onready var ai : Node = $AI
|
@onready var ai : Node = $AI
|
||||||
@onready var animatedSprite : AnimatedSprite2D = $AnimatedSprite2D
|
@onready var animatedSprite : AnimatedSprite2D = $AnimatedSprite2D
|
||||||
@onready var attackCollision : CollisionShape2D = $Attack/AttackCollision
|
@onready var attackArea : Area2D = $AttackArea
|
||||||
@onready var damageCollision : CollisionShape2D = $Attack/DamageCollision
|
@onready var damageCollision : CollisionShape2D = $DamageArea/DamageCollision
|
||||||
|
|
||||||
var isAlive : bool = true
|
var isAlive : bool = true
|
||||||
var isFacingLeft : bool = false
|
var isFacingLeft : bool = false
|
||||||
@ -29,30 +33,44 @@ func _ready():
|
|||||||
func _process(delta):
|
func _process(delta):
|
||||||
if !isAlive:
|
if !isAlive:
|
||||||
return
|
return
|
||||||
|
|
||||||
if enemy != null:
|
if enemy != null:
|
||||||
direction = ai.getDirection(global_position, enemy.global_position)
|
direction = ai.getDirection(global_position, enemy.global_position)
|
||||||
else:
|
else:
|
||||||
direction = Vector2.ZERO
|
direction = Vector2.ZERO
|
||||||
|
|
||||||
if !isFacingLeft && velocity.x >= 0:
|
if !isFacingLeft && direction.x < 0:
|
||||||
isFacingLeft = true
|
isFacingLeft = true
|
||||||
scale = Vector2(1, 1)
|
|
||||||
elif isFacingLeft && velocity.x < 0:
|
|
||||||
isFacingLeft = false
|
|
||||||
scale = Vector2(-1, 1)
|
scale = Vector2(-1, 1)
|
||||||
|
elif isFacingLeft && direction.x > 0:
|
||||||
|
isFacingLeft = false
|
||||||
|
scale = Vector2(1, 1)
|
||||||
|
|
||||||
velocity = direction * speed * delta
|
velocity = direction * speed * delta
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
|
if cooldown > 0:
|
||||||
|
if cooldown - attackSpeed * delta <= 0:
|
||||||
|
cooldown = 0
|
||||||
|
else:
|
||||||
|
cooldown -= attackSpeed * delta
|
||||||
|
|
||||||
|
attemptAttack()
|
||||||
|
|
||||||
|
func attemptAttack():
|
||||||
|
if !canAttack || !isAlive || cooldown > 0:
|
||||||
|
return
|
||||||
|
if attackArea.overlaps_body(enemy):
|
||||||
|
attack()
|
||||||
|
|
||||||
func attack():
|
func attack():
|
||||||
if !canAttack || !isAlive:
|
cooldown = ATTACK_COOLDOWN
|
||||||
return
|
|
||||||
animatedSprite.play("attack")
|
animatedSprite.play("attack")
|
||||||
|
damageCollision.disabled = false
|
||||||
animatedSprite.connect("animation_finished", endAttack)
|
animatedSprite.connect("animation_finished", endAttack)
|
||||||
|
|
||||||
func endAttack():
|
func endAttack():
|
||||||
|
damageCollision.disabled = true
|
||||||
animatedSprite.play("default")
|
animatedSprite.play("default")
|
||||||
|
|
||||||
func receive_damage(dmg):
|
func receive_damage(dmg):
|
||||||
@ -67,7 +85,10 @@ func receive_damage(dmg):
|
|||||||
|
|
||||||
func die():
|
func die():
|
||||||
isAlive = false
|
isAlive = false
|
||||||
|
damageCollision.disabled = true
|
||||||
|
animatedSprite.stop()
|
||||||
animatedSprite.play("death")
|
animatedSprite.play("death")
|
||||||
|
animatedSprite.disconnect("animation_finished", endAttack)
|
||||||
animatedSprite.connect("animation_finished", fadeOut)
|
animatedSprite.connect("animation_finished", fadeOut)
|
||||||
|
|
||||||
func fadeOut():
|
func fadeOut():
|
||||||
@ -78,3 +99,8 @@ func fadeOut():
|
|||||||
|
|
||||||
func clean():
|
func clean():
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_damage_area_body_entered(body):
|
||||||
|
if body == enemy:
|
||||||
|
enemy.receive_damage(damage)
|
||||||
|
@ -245,15 +245,17 @@ frame_progress = 0.387978
|
|||||||
rotation = 1.5708
|
rotation = 1.5708
|
||||||
shape = SubResource("CapsuleShape2D_5aviq")
|
shape = SubResource("CapsuleShape2D_5aviq")
|
||||||
|
|
||||||
[node name="Attack" type="Area2D" parent="."]
|
[node name="AttackArea" type="Area2D" parent="."]
|
||||||
|
|
||||||
[node name="AttackCollision" type="CollisionShape2D" parent="Attack"]
|
[node name="AttackCollision" type="CollisionShape2D" parent="AttackArea"]
|
||||||
position = Vector2(1, 1)
|
position = Vector2(1, 1)
|
||||||
rotation = 1.5708
|
rotation = 1.5708
|
||||||
shape = SubResource("CapsuleShape2D_2l8j3")
|
shape = SubResource("CapsuleShape2D_2l8j3")
|
||||||
debug_color = Color(0.678431, 0.556863, 0.137255, 0.419608)
|
debug_color = Color(0.678431, 0.556863, 0.137255, 0.419608)
|
||||||
|
|
||||||
[node name="DamageCollision" type="CollisionShape2D" parent="Attack"]
|
[node name="DamageArea" type="Area2D" parent="."]
|
||||||
|
|
||||||
|
[node name="DamageCollision" type="CollisionShape2D" parent="DamageArea"]
|
||||||
position = Vector2(2, 2)
|
position = Vector2(2, 2)
|
||||||
rotation = 1.5708
|
rotation = 1.5708
|
||||||
shape = SubResource("CapsuleShape2D_o2kl1")
|
shape = SubResource("CapsuleShape2D_o2kl1")
|
||||||
@ -261,3 +263,5 @@ disabled = true
|
|||||||
debug_color = Color(0.639216, 0, 0.156863, 0.419608)
|
debug_color = Color(0.639216, 0, 0.156863, 0.419608)
|
||||||
|
|
||||||
[node name="AI" type="Node" parent="."]
|
[node name="AI" type="Node" parent="."]
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="DamageArea" to="." method="_on_damage_area_body_entered"]
|
||||||
|
@ -399,6 +399,7 @@ angular_velocity_max = 50.0
|
|||||||
color = Color(0.623529, 0, 0, 0.729412)
|
color = Color(0.623529, 0, 0, 0.729412)
|
||||||
|
|
||||||
[node name="Atk_cooldown" type="Timer" parent="."]
|
[node name="Atk_cooldown" type="Timer" parent="."]
|
||||||
|
wait_time = 2.0
|
||||||
autostart = true
|
autostart = true
|
||||||
|
|
||||||
[node name="LvlUp" type="CPUParticles2D" parent="."]
|
[node name="LvlUp" type="CPUParticles2D" parent="."]
|
||||||
@ -431,7 +432,6 @@ collision_layer = 2
|
|||||||
collision_mask = 2
|
collision_mask = 2
|
||||||
|
|
||||||
[node name="Attack1CollisionR" type="CollisionShape2D" parent="AttackArea"]
|
[node name="Attack1CollisionR" type="CollisionShape2D" parent="AttackArea"]
|
||||||
visible = false
|
|
||||||
position = Vector2(3, -7)
|
position = Vector2(3, -7)
|
||||||
rotation = 1.5708
|
rotation = 1.5708
|
||||||
skew = 0.223402
|
skew = 0.223402
|
||||||
@ -439,7 +439,6 @@ shape = SubResource("CapsuleShape2D_qykhm")
|
|||||||
debug_color = Color(0.956863, 0.203922, 0, 0.419608)
|
debug_color = Color(0.956863, 0.203922, 0, 0.419608)
|
||||||
|
|
||||||
[node name="Attack1CollisionL" type="CollisionShape2D" parent="AttackArea"]
|
[node name="Attack1CollisionL" type="CollisionShape2D" parent="AttackArea"]
|
||||||
visible = false
|
|
||||||
position = Vector2(-3, -7)
|
position = Vector2(-3, -7)
|
||||||
rotation = 1.5708
|
rotation = 1.5708
|
||||||
skew = -0.169297
|
skew = -0.169297
|
||||||
@ -447,7 +446,6 @@ shape = SubResource("CapsuleShape2D_qykhm")
|
|||||||
debug_color = Color(0.956863, 0.203922, 0, 0.419608)
|
debug_color = Color(0.956863, 0.203922, 0, 0.419608)
|
||||||
|
|
||||||
[node name="Attack2CollisionR" type="CollisionShape2D" parent="AttackArea"]
|
[node name="Attack2CollisionR" type="CollisionShape2D" parent="AttackArea"]
|
||||||
visible = false
|
|
||||||
position = Vector2(25, -7)
|
position = Vector2(25, -7)
|
||||||
rotation = 1.5708
|
rotation = 1.5708
|
||||||
skew = 0.0837758
|
skew = 0.0837758
|
||||||
@ -455,7 +453,6 @@ shape = SubResource("CapsuleShape2D_qykhm")
|
|||||||
debug_color = Color(0.956863, 0.203922, 0, 0.419608)
|
debug_color = Color(0.956863, 0.203922, 0, 0.419608)
|
||||||
|
|
||||||
[node name="Attack2CollisionL" type="CollisionShape2D" parent="AttackArea"]
|
[node name="Attack2CollisionL" type="CollisionShape2D" parent="AttackArea"]
|
||||||
visible = false
|
|
||||||
position = Vector2(-25, -7)
|
position = Vector2(-25, -7)
|
||||||
rotation = 1.5708
|
rotation = 1.5708
|
||||||
skew = -0.0837758
|
skew = -0.0837758
|
||||||
|
@ -13,7 +13,9 @@ extends CharacterBody2D
|
|||||||
@export var experience: int = 0
|
@export var experience: int = 0
|
||||||
@export var state: String = "Idle"
|
@export var state: String = "Idle"
|
||||||
@export var damage: int = 5
|
@export var damage: int = 5
|
||||||
|
@export var maxAtks: int = 1
|
||||||
|
|
||||||
|
@onready var currAtks: int = 0
|
||||||
@onready var anim: Node = get_node("Sprite")
|
@onready var anim: Node = get_node("Sprite")
|
||||||
@onready var cooldown: Node = get_node("Atk_cooldown")
|
@onready var cooldown: Node = get_node("Atk_cooldown")
|
||||||
@onready var lvlanim: Node = get_node("LvlUp")
|
@onready var lvlanim: Node = get_node("LvlUp")
|
||||||
@ -24,9 +26,24 @@ extends CharacterBody2D
|
|||||||
@onready var atk2l: Node = get_node("AttackArea/Attack2CollisionL")
|
@onready var atk2l: Node = get_node("AttackArea/Attack2CollisionL")
|
||||||
@onready var atk2r: Node = get_node("AttackArea/Attack2CollisionR")
|
@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.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
pass # Replace with function body.
|
atk1l.set_disabled(true)
|
||||||
|
atk1r.set_disabled(true)
|
||||||
|
atk2l.set_disabled(true)
|
||||||
|
atk2r.set_disabled(true)
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
@ -36,13 +53,17 @@ func _process(delta):
|
|||||||
elif !is_attacking:
|
elif !is_attacking:
|
||||||
setAnimState("Run")
|
setAnimState("Run")
|
||||||
|
|
||||||
is_facing_left = velocity.x >= 0
|
if state != "Attack" && state != "Attack2":
|
||||||
|
is_facing_left = velocity.x > 0 && !(velocity.x < 0)
|
||||||
|
|
||||||
# AI STUFF
|
# AI STUFF
|
||||||
#velocity = processAI(objects,velocity,delta)
|
#velocity += processAI(list,delta)
|
||||||
|
|
||||||
|
velocity.x += delta * 4
|
||||||
|
velocity.y += delta * 4
|
||||||
|
|
||||||
if !hitanim.is_emitting():
|
if !hitanim.is_emitting():
|
||||||
anim.modulate(Color(0,0,0,1))
|
anim.modulate.a = 1
|
||||||
|
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
@ -56,26 +77,18 @@ func processAI(objs, delta):
|
|||||||
|
|
||||||
func attack():
|
func attack():
|
||||||
is_attacking = true
|
is_attacking = true
|
||||||
if (level > 1):
|
|
||||||
setAnimState("Attack2")
|
setAnimState(atk)
|
||||||
if is_facing_left:
|
if is_facing_left:
|
||||||
atk2r.set_disabled(false)
|
atkL.set_disabled(false)
|
||||||
else:
|
|
||||||
atk2l.set_disabled(false)
|
|
||||||
else:
|
else:
|
||||||
setAnimState("Attack")
|
atkR.set_disabled(false)
|
||||||
if is_facing_left:
|
|
||||||
atk1r.set_disabled(false)
|
|
||||||
else:
|
|
||||||
atk1l.set_disabled(false)
|
|
||||||
|
|
||||||
|
|
||||||
func stop_attack():
|
func stop_attack():
|
||||||
is_attacking = false
|
is_attacking = false
|
||||||
atk1l.set_disabled(true)
|
atkL.set_disabled(true)
|
||||||
atk1r.set_disabled(true)
|
atkR.set_disabled(true)
|
||||||
atk2l.set_disabled(true)
|
|
||||||
atk2r.set_disabled(true)
|
|
||||||
|
|
||||||
|
|
||||||
func setAnimState(newstate):
|
func setAnimState(newstate):
|
||||||
@ -90,7 +103,7 @@ func receive_damage(dmg):
|
|||||||
pass
|
pass
|
||||||
hp -= dmg
|
hp -= dmg
|
||||||
hitanim.restart()
|
hitanim.restart()
|
||||||
anim.modulate(Color(0,0,0,.5))
|
anim.modulate.a = 0.5
|
||||||
if hp < 0:
|
if hp < 0:
|
||||||
velocity = Vector2(0,0)
|
velocity = Vector2(0,0)
|
||||||
setAnimState("Die")
|
setAnimState("Die")
|
||||||
@ -104,27 +117,50 @@ func receive_exp(x):
|
|||||||
setLevel(level + 1)
|
setLevel(level + 1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func setLevel(lvl):
|
func setLevel(lvl):
|
||||||
level = lvl
|
level = lvl
|
||||||
lvlanim.restart()
|
lvlanim.restart()
|
||||||
lvlsnd.play()
|
lvlsnd.play()
|
||||||
|
|
||||||
if level > 2:
|
if level > 3:
|
||||||
cooldown.wait_time = 0.5
|
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():
|
func _on_atk_cooldown_timeout():
|
||||||
|
currAtks = maxAtks
|
||||||
attack()
|
attack()
|
||||||
|
|
||||||
|
|
||||||
func _on_sprite_animation_looped():
|
func _on_sprite_animation_looped():
|
||||||
if is_attacking:
|
if is_attacking:
|
||||||
|
currAtks -= 1
|
||||||
stop_attack()
|
stop_attack()
|
||||||
|
if currAtks > 0:
|
||||||
|
is_facing_left = !is_facing_left
|
||||||
|
attack()
|
||||||
|
else:
|
||||||
|
currAtks = maxAtks
|
||||||
is_dying = false
|
is_dying = false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _on_attack_area_body_entered(body):
|
func _on_attack_area_body_entered(body):
|
||||||
if typeof(body) == typeof(TemplateSpawnable):
|
if typeof(body) == typeof(TemplateSpawnable):
|
||||||
body.receive_damage(damage)
|
body.receive_damage(damage)
|
||||||
|
@ -19,7 +19,6 @@ config/icon="res://icon.svg"
|
|||||||
|
|
||||||
window/size/viewport_width=960
|
window/size/viewport_width=960
|
||||||
window/size/viewport_height=540
|
window/size/viewport_height=540
|
||||||
window/size/mode=3
|
|
||||||
window/size/resizable=false
|
window/size/resizable=false
|
||||||
window/stretch/mode="viewport"
|
window/stretch/mode="viewport"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user