Merge branch 'main' of https://github.com/MarcEricMartel/Game-Jam-A23
This commit is contained in:
commit
6fa45e2c50
@ -11,10 +11,12 @@
|
||||
[node name="Decor" type="Node2D" parent="."]
|
||||
|
||||
[node name="Enemy" parent="." instance=ExtResource("2_ftshv")]
|
||||
position = Vector2(441, 312)
|
||||
position = Vector2(497, 324)
|
||||
|
||||
[node name="BatSpawnable" parent="." instance=ExtResource("3_a1ucf")]
|
||||
position = Vector2(248, 225)
|
||||
motion_mode = 0
|
||||
|
||||
[node name="BatSpawnable2" parent="." instance=ExtResource("3_a1ucf")]
|
||||
position = Vector2(644, 251)
|
||||
motion_mode = 0
|
||||
|
@ -1,4 +1,4 @@
|
||||
extends AITemplate
|
||||
|
||||
func getDirection(position, enemyPosition) -> Vector2:
|
||||
return Vector2(enemyPosition - position).normalized()
|
||||
func getDirection(_position, _enemyPosition) -> Vector2:
|
||||
return Vector2(_enemyPosition - _position).normalized()
|
||||
|
@ -1,5 +1,5 @@
|
||||
class_name AITemplate
|
||||
extends Node
|
||||
|
||||
func getDirection(position, enemyPosition) -> Vector2:
|
||||
func getDirection(_position, _enemyPosition) -> Vector2:
|
||||
return Vector2.ZERO
|
||||
|
@ -8,10 +8,12 @@ const ATTACK_COOLDOWN : float = 100
|
||||
@export var speed : float = 0
|
||||
@export var damage : int = 0
|
||||
@export var priority : int = 0
|
||||
@export var expReward : int = 0
|
||||
@export var cost : int = 0
|
||||
@export var minSpawnRange : float = 0
|
||||
@export var canAttack : bool = true
|
||||
|
||||
|
||||
@onready var ai : Node = $AI
|
||||
@onready var animatedSprite : AnimatedSprite2D = $AnimatedSprite2D
|
||||
@onready var attackArea : Area2D = $AttackArea
|
||||
@ -41,20 +43,21 @@ func _process(delta):
|
||||
|
||||
if !isFacingLeft && direction.x < 0:
|
||||
isFacingLeft = true
|
||||
scale = Vector2(-1, 1)
|
||||
scale.x = -1
|
||||
scale.y = 1
|
||||
elif isFacingLeft && direction.x > 0:
|
||||
isFacingLeft = false
|
||||
scale = Vector2(1, 1)
|
||||
scale.x = -1
|
||||
scale.y = -1
|
||||
|
||||
velocity = direction * speed * delta
|
||||
move_and_slide()
|
||||
|
||||
if cooldown > 0:
|
||||
if cooldown - attackSpeed * delta <= 0:
|
||||
cooldown = 0
|
||||
cooldown = 0
|
||||
else:
|
||||
cooldown -= attackSpeed * delta
|
||||
|
||||
attemptAttack()
|
||||
|
||||
func attemptAttack():
|
||||
@ -71,6 +74,7 @@ func attack():
|
||||
|
||||
func endAttack():
|
||||
damageCollision.disabled = true
|
||||
animatedSprite.disconnect("animation_finished", endAttack)
|
||||
animatedSprite.play("default")
|
||||
|
||||
func receive_damage(dmg):
|
||||
@ -103,4 +107,4 @@ func clean():
|
||||
|
||||
func _on_damage_area_body_entered(body):
|
||||
if body == enemy:
|
||||
enemy.receive_damage(damage)
|
||||
body.receive_damage(damage)
|
||||
|
@ -233,6 +233,7 @@ radius = 8.0
|
||||
[node name="TemplateSpawnable" type="CharacterBody2D"]
|
||||
collision_layer = 6
|
||||
collision_mask = 6
|
||||
motion_mode = 1
|
||||
script = ExtResource("1_rkej7")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
|
@ -58,9 +58,31 @@ func _process(delta):
|
||||
|
||||
# AI STUFF
|
||||
#velocity += processAI(list,delta)
|
||||
var x = 0
|
||||
var y = 0
|
||||
|
||||
if Input.is_action_pressed("ui_left"):
|
||||
# Move as long as the key/button is pressed.
|
||||
x -= delta * 50
|
||||
elif Input.is_action_pressed("ui_right"):
|
||||
# Move as long as the key/button is pressed.
|
||||
x += delta * 50
|
||||
else:
|
||||
velocity.x *= 0.8
|
||||
if Input.is_action_pressed("ui_up"):
|
||||
# Move as long as the key/button is pressed.
|
||||
y -= delta * 50
|
||||
elif Input.is_action_pressed("ui_down"):
|
||||
# Move as long as the key/button is pressed.
|
||||
y += delta * 50
|
||||
else:
|
||||
velocity.y *= 0.8
|
||||
|
||||
velocity.x += x
|
||||
velocity.y += y
|
||||
|
||||
|
||||
|
||||
velocity.x += delta * 4
|
||||
velocity.y += delta * 4
|
||||
|
||||
if !hitanim.is_emitting():
|
||||
anim.modulate.a = 1
|
||||
|
@ -19,6 +19,7 @@ config/icon="res://icon.svg"
|
||||
|
||||
window/size/viewport_width=960
|
||||
window/size/viewport_height=540
|
||||
window/size/mode=4
|
||||
window/size/resizable=false
|
||||
window/stretch/mode="viewport"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user