Merge branch 'main' of https://github.com/MarcEricMartel/Game-Jam-A23
This commit is contained in:
commit
2a333b24c2
20
Scenes/Levels/level_test.tscn
Normal file
20
Scenes/Levels/level_test.tscn
Normal file
@ -0,0 +1,20 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://vd3ffjat2jln"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://b8s2seg2lf7wo" path="res://Scenes/Tilemaps/tileset_1.tscn" id="1_287nl"]
|
||||
[ext_resource type="PackedScene" uid="uid://b5lnjonlf4i1b" path="res://Scenes/enemy.tscn" id="2_ftshv"]
|
||||
[ext_resource type="PackedScene" uid="uid://brnx3xyyd0e71" path="res://Scenes/Spawnables/bat_spawnable.tscn" id="3_a1ucf"]
|
||||
|
||||
[node name="Level1" type="Node2D"]
|
||||
|
||||
[node name="TileSet1" parent="." instance=ExtResource("1_287nl")]
|
||||
|
||||
[node name="Decor" type="Node2D" parent="."]
|
||||
|
||||
[node name="Enemy" parent="." instance=ExtResource("2_ftshv")]
|
||||
position = Vector2(441, 312)
|
||||
|
||||
[node name="BatSpawnable" parent="." instance=ExtResource("3_a1ucf")]
|
||||
position = Vector2(248, 225)
|
||||
|
||||
[node name="BatSpawnable2" parent="." instance=ExtResource("3_a1ucf")]
|
||||
position = Vector2(644, 251)
|
@ -1,4 +1,4 @@
|
||||
extends AITemplate
|
||||
|
||||
func getDirection(position, enemyPosition) -> Vector2:
|
||||
return Vector2.ZERO
|
||||
return Vector2(enemyPosition - position).normalized()
|
||||
|
@ -1,5 +1,5 @@
|
||||
class_name AITemplate
|
||||
extends Node
|
||||
|
||||
func run(position, enemyPosition) -> Vector2:
|
||||
func getDirection(position, enemyPosition) -> Vector2:
|
||||
return Vector2.ZERO
|
||||
|
@ -6,9 +6,18 @@
|
||||
[node name="BatSpawnable" instance=ExtResource("1_verf7")]
|
||||
maxHp = 10
|
||||
attackSpeed = 10.0
|
||||
speed = 100.0
|
||||
speed = 2000.0
|
||||
damage = 1
|
||||
priority = 1
|
||||
|
||||
[node name="AnimatedSprite2D" parent="." index="0"]
|
||||
frame_progress = 0.482614
|
||||
|
||||
[node name="AttackCollision" parent="Attack" index="0"]
|
||||
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")
|
||||
|
@ -6,11 +6,15 @@ extends CharacterBody2D
|
||||
@export var speed : float = 0
|
||||
@export var damage : int = 0
|
||||
@export var priority : int = 0
|
||||
@export var canAttack : bool = true
|
||||
|
||||
@onready var ai : Node = $AI
|
||||
@onready var animatedSprite : AnimatedSprite2D = $AnimatedSprite2D
|
||||
@onready var attackCollision : CollisionShape2D = $Attack/AttackCollision
|
||||
@onready var damageCollision : CollisionShape2D = $Attack/DamageCollision
|
||||
|
||||
var isAlive : bool = true
|
||||
var isFacingLeft : bool = false
|
||||
var direction : Vector2 = Vector2.ZERO
|
||||
var enemy : CharacterBody2D = null
|
||||
|
||||
@ -20,25 +24,35 @@ var cooldown : float = 0
|
||||
func _ready():
|
||||
enemy = get_node("../Enemy")
|
||||
currentHp = maxHp
|
||||
animatedSprite.play("default")
|
||||
|
||||
func _process(delta):
|
||||
if !isAlive:
|
||||
return
|
||||
|
||||
if enemy != null:
|
||||
direction = ai.getDirection(position, enemy.position)
|
||||
direction = ai.getDirection(global_position, enemy.global_position)
|
||||
else:
|
||||
direction = Vector2.ZERO
|
||||
|
||||
if !isFacingLeft && velocity.x >= 0:
|
||||
isFacingLeft = true
|
||||
scale = Vector2(1, 1)
|
||||
elif isFacingLeft && velocity.x < 0:
|
||||
isFacingLeft = false
|
||||
scale = Vector2(-1, 1)
|
||||
|
||||
velocity = direction * speed * delta
|
||||
move_and_slide()
|
||||
|
||||
func attack(target):
|
||||
func attack():
|
||||
if !canAttack || !isAlive:
|
||||
return
|
||||
animatedSprite.play("attack")
|
||||
animatedSprite.connect("animation_finished", endAttack(target))
|
||||
animatedSprite.connect("animation_finished", endAttack)
|
||||
|
||||
func endAttack(target):
|
||||
target.receive_damage(damage)
|
||||
func endAttack():
|
||||
|
||||
animatedSprite.play("default")
|
||||
|
||||
func receive_damage(dmg):
|
||||
@ -54,13 +68,13 @@ func receive_damage(dmg):
|
||||
func die():
|
||||
isAlive = false
|
||||
animatedSprite.play("death")
|
||||
animatedSprite.connect("animation_finished", self.fadeOut())
|
||||
animatedSprite.connect("animation_finished", fadeOut)
|
||||
|
||||
func fadeOut():
|
||||
var tween = Tween.new()
|
||||
add_child(tween)
|
||||
var tween = get_tree().create_tween()
|
||||
tween.tween_property(animatedSprite, "modulate", Color(0,0,0,0), 1)
|
||||
tween.tween_callback(clean())
|
||||
tween.tween_callback(clean)
|
||||
|
||||
|
||||
func clean():
|
||||
queue_free()
|
||||
|
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=36 format=3 uid="uid://kkfxguj0lr5a"]
|
||||
[gd_scene load_steps=37 format=3 uid="uid://kkfxguj0lr5a"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scenes/Spawnables/template_spawnable.gd" id="1_rkej7"]
|
||||
[ext_resource type="Texture2D" uid="uid://f60ndepwmpj2" path="res://Assets/Bat/noBKG_BatAttack_strip.png" id="2_7ayi7"]
|
||||
@ -225,7 +225,10 @@ height = 14.0
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_2l8j3"]
|
||||
radius = 7.0
|
||||
height = 22.0
|
||||
height = 24.0
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_o2kl1"]
|
||||
radius = 8.0
|
||||
|
||||
[node name="TemplateSpawnable" type="CharacterBody2D"]
|
||||
collision_layer = 6
|
||||
@ -234,6 +237,9 @@ script = ExtResource("1_rkej7")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
sprite_frames = SubResource("SpriteFrames_k6v1d")
|
||||
animation = &"attack"
|
||||
frame = 7
|
||||
frame_progress = 0.387978
|
||||
|
||||
[node name="BodyCollision" type="CollisionShape2D" parent="."]
|
||||
rotation = 1.5708
|
||||
@ -242,8 +248,16 @@ shape = SubResource("CapsuleShape2D_5aviq")
|
||||
[node name="Attack" type="Area2D" parent="."]
|
||||
|
||||
[node name="AttackCollision" type="CollisionShape2D" parent="Attack"]
|
||||
position = Vector2(1, 1)
|
||||
rotation = 1.5708
|
||||
shape = SubResource("CapsuleShape2D_2l8j3")
|
||||
debug_color = Color(0.803922, 0, 0.180392, 0.419608)
|
||||
debug_color = Color(0.678431, 0.556863, 0.137255, 0.419608)
|
||||
|
||||
[node name="DamageCollision" type="CollisionShape2D" parent="Attack"]
|
||||
position = Vector2(2, 2)
|
||||
rotation = 1.5708
|
||||
shape = SubResource("CapsuleShape2D_o2kl1")
|
||||
disabled = true
|
||||
debug_color = Color(0.639216, 0, 0.156863, 0.419608)
|
||||
|
||||
[node name="AI" type="Node" parent="."]
|
||||
|
@ -445,3 +445,4 @@ debug_color = Color(0.956863, 0.203922, 0, 0.419608)
|
||||
|
||||
[connection signal="animation_looped" from="Sprite" to="." method="_on_sprite_animation_looped"]
|
||||
[connection signal="timeout" from="Atk_cooldown" to="." method="_on_atk_cooldown_timeout"]
|
||||
[connection signal="body_entered" from="AttackArea" to="." method="_on_attack_area_body_entered"]
|
||||
|
@ -12,11 +12,17 @@ extends CharacterBody2D
|
||||
@export var maxvel: float = 2
|
||||
@export var experience: int = 0
|
||||
@export var state: String = "Idle"
|
||||
@export var damage: int = 5
|
||||
|
||||
@onready var anim: Node = get_node("Sprite")
|
||||
@onready var cooldown: Node = get_node("Atk_cooldown")
|
||||
@onready var lvlanim: Node = get_node("LvlUp")
|
||||
@onready var lvlsnd: Node = get_node("LvlUpSnd")
|
||||
@onready var hitanim: Node = get_node("Hit")
|
||||
@onready var atk1l: Node = get_node("AttackArea/Attack1CollisionL")
|
||||
@onready var atk1r: Node = get_node("AttackArea/Attack1CollisionR")
|
||||
@onready var atk2l: Node = get_node("AttackArea/Attack2CollisionL")
|
||||
@onready var atk2r: Node = get_node("AttackArea/Attack2CollisionR")
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
@ -35,14 +41,8 @@ func _process(delta):
|
||||
# AI STUFF
|
||||
#velocity = processAI(objects,velocity,delta)
|
||||
|
||||
velocity.x += delta
|
||||
velocity.y += delta
|
||||
|
||||
if abs(velocity.x + velocity.y) > maxvel:
|
||||
velocity.x *= maxvel / velocity.x
|
||||
velocity.y *= maxvel / velocity.y
|
||||
|
||||
position += velocity
|
||||
move_and_slide()
|
||||
|
||||
|
||||
func processAI(objs, delta):
|
||||
@ -57,23 +57,23 @@ func attack():
|
||||
if (level > 1):
|
||||
setAnimState("Attack2")
|
||||
if is_facing_left:
|
||||
get_node("AttackArea/Attack2CollisionL").set_disabled(false)
|
||||
atk2r.set_disabled(false)
|
||||
else:
|
||||
get_node("AttackArea/Attack2CollisionR").set_disabled(false)
|
||||
atk2l.set_disabled(false)
|
||||
else:
|
||||
setAnimState("Attack")
|
||||
if is_facing_left:
|
||||
get_node("AttackArea/Attack1CollisionL").set_disabled(false)
|
||||
atk1r.set_disabled(false)
|
||||
else:
|
||||
get_node("AttackArea/Attack1CollisionR").set_disabled(false)
|
||||
atk1l.set_disabled(false)
|
||||
|
||||
|
||||
func stop_attack():
|
||||
is_attacking = false
|
||||
get_node("AttackArea/Attack1CollisionL").set_disabled(true)
|
||||
get_node("AttackArea/Attack1CollisionR").set_disabled(true)
|
||||
get_node("AttackArea/Attack2CollisionL").set_disabled(true)
|
||||
get_node("AttackArea/Attack2CollisionR").set_disabled(true)
|
||||
atk1l.set_disabled(true)
|
||||
atk1r.set_disabled(true)
|
||||
atk2l.set_disabled(true)
|
||||
atk2r.set_disabled(true)
|
||||
|
||||
|
||||
func setAnimState(newstate):
|
||||
@ -84,7 +84,10 @@ func setAnimState(newstate):
|
||||
|
||||
|
||||
func receive_damage(dmg):
|
||||
if hitanim.is_emitting():
|
||||
pass
|
||||
hp -= dmg
|
||||
hitanim.restart()
|
||||
if hp < 0:
|
||||
velocity = Vector2(0,0)
|
||||
setAnimState("Die")
|
||||
@ -98,6 +101,7 @@ func receive_exp(x):
|
||||
setLevel(level + 1)
|
||||
|
||||
|
||||
|
||||
func setLevel(lvl):
|
||||
level = lvl
|
||||
lvlanim.restart()
|
||||
@ -116,3 +120,8 @@ func _on_sprite_animation_looped():
|
||||
stop_attack()
|
||||
is_dying = false
|
||||
|
||||
|
||||
|
||||
func _on_attack_area_body_entered(body):
|
||||
if typeof(body) == typeof(TemplateSpawnable):
|
||||
body.receive_damage(damage)
|
||||
|
@ -12,7 +12,7 @@ func _process(delta):
|
||||
|
||||
|
||||
func _on_start_button_pressed():
|
||||
get_tree().change_scene_to_file("res://Scenes/Levels/level1.tscn")
|
||||
get_tree().change_scene_to_file("res://Scenes/Levels/level_1.tscn")
|
||||
|
||||
|
||||
func _on_quit_button_pressed():
|
||||
|
@ -17,9 +17,11 @@ config/icon="res://icon.svg"
|
||||
|
||||
[display]
|
||||
|
||||
window/size/viewport_width=1920
|
||||
window/size/viewport_height=1080
|
||||
window/size/viewport_width=960
|
||||
window/size/viewport_height=540
|
||||
window/size/mode=3
|
||||
window/size/resizable=false
|
||||
window/stretch/mode="viewport"
|
||||
|
||||
[rendering]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user