From b244f8f08ed11b6a70902903a0b3dcadc2de0c44 Mon Sep 17 00:00:00 2001 From: MarcEricMartel Date: Tue, 10 Oct 2023 18:27:21 -0400 Subject: [PATCH 1/2] Happy? --- Scripts/Enemy.gd | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Scripts/Enemy.gd b/Scripts/Enemy.gd index 9efb664..5e551fa 100644 --- a/Scripts/Enemy.gd +++ b/Scripts/Enemy.gd @@ -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 From 0f501386d4c8582b13532e1f21cb8d41a869732b Mon Sep 17 00:00:00 2001 From: Victor Turgeon Date: Tue, 10 Oct 2023 18:29:06 -0400 Subject: [PATCH 2/2] BING CHILLING --- Scenes/Levels/level_test.tscn | 4 +++- Scenes/Spawnables/AIs/ai_bat.gd | 4 ++-- Scenes/Spawnables/AIs/ai_template.gd | 2 +- Scenes/Spawnables/template_spawnable.gd | 14 +++++++++----- Scenes/Spawnables/template_spawnable.tscn | 1 + project.godot | 1 + 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Scenes/Levels/level_test.tscn b/Scenes/Levels/level_test.tscn index 33abc78..d0c2ed9 100644 --- a/Scenes/Levels/level_test.tscn +++ b/Scenes/Levels/level_test.tscn @@ -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 diff --git a/Scenes/Spawnables/AIs/ai_bat.gd b/Scenes/Spawnables/AIs/ai_bat.gd index 03e53f1..39366e1 100644 --- a/Scenes/Spawnables/AIs/ai_bat.gd +++ b/Scenes/Spawnables/AIs/ai_bat.gd @@ -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() diff --git a/Scenes/Spawnables/AIs/ai_template.gd b/Scenes/Spawnables/AIs/ai_template.gd index ad017cf..fcfdc42 100644 --- a/Scenes/Spawnables/AIs/ai_template.gd +++ b/Scenes/Spawnables/AIs/ai_template.gd @@ -1,5 +1,5 @@ class_name AITemplate extends Node -func getDirection(position, enemyPosition) -> Vector2: +func getDirection(_position, _enemyPosition) -> Vector2: return Vector2.ZERO diff --git a/Scenes/Spawnables/template_spawnable.gd b/Scenes/Spawnables/template_spawnable.gd index 702b9c4..1377ac1 100644 --- a/Scenes/Spawnables/template_spawnable.gd +++ b/Scenes/Spawnables/template_spawnable.gd @@ -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) diff --git a/Scenes/Spawnables/template_spawnable.tscn b/Scenes/Spawnables/template_spawnable.tscn index 96d9ead..232bc34 100644 --- a/Scenes/Spawnables/template_spawnable.tscn +++ b/Scenes/Spawnables/template_spawnable.tscn @@ -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="."] diff --git a/project.godot b/project.godot index 9335552..b6769b5 100644 --- a/project.godot +++ b/project.godot @@ -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"