summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrique Alves <henriquelalves@gmail.com>2022-07-16 15:32:08 -0300
committerHenrique Alves <henriquelalves@gmail.com>2022-07-16 15:32:08 -0300
commit0a3148bc9dfc4b3ff20046b93832592ed5c6e7ae (patch)
treeaa7c3ef68463138cb1eea8ba16a0f608be3783c9
parent093a70adfe922f22b07bbf3b02fa52774c989943 (diff)
downloadgamejam-gmtk-2022-0a3148bc9dfc4b3ff20046b93832592ed5c6e7ae.tar.gz
gamejam-gmtk-2022-0a3148bc9dfc4b3ff20046b93832592ed5c6e7ae.tar.bz2
gamejam-gmtk-2022-0a3148bc9dfc4b3ff20046b93832592ed5c6e7ae.zip
Add health to enemies
-rw-r--r--Scenes/Dungeon.gd14
-rw-r--r--Scenes/Dungeon.tscn11
-rw-r--r--Scenes/Monster.gd5
-rw-r--r--Scenes/Monster.tscn33
-rw-r--r--Scenes/MonsterRandCardinal.gd19
-rw-r--r--Scenes/Player.gd43
6 files changed, 107 insertions, 18 deletions
diff --git a/Scenes/Dungeon.gd b/Scenes/Dungeon.gd
index 38800ba..32a30ae 100644
--- a/Scenes/Dungeon.gd
+++ b/Scenes/Dungeon.gd
@@ -122,10 +122,16 @@ func process_turn_logic():
if tiles_entities.has(new_tile):
var monster = tiles_entities[new_tile]
if monster is Monster:
- monster.alive = false
- monster.add_action("cor_dies", [])
- Global.turns += int(player.get_upper_face())
- kill_entity(monster)
+ var top = int(player.get_upper_face())
+ if monster.health - top <= 0:
+ monster.alive = false
+ monster.add_action("cor_dies", [])
+ Global.turns += int(player.get_upper_face())
+ kill_entity(monster)
+ else:
+ monster.health -= top
+ monster.add_action("cor_stomp", [])
+ player.add_action("cor_half_move", [tile_to_pos(new_tile), 0.2])
player.roll(-input)
# player move
diff --git a/Scenes/Dungeon.tscn b/Scenes/Dungeon.tscn
index 5795e4d..2126367 100644
--- a/Scenes/Dungeon.tscn
+++ b/Scenes/Dungeon.tscn
@@ -1,8 +1,9 @@
-[gd_scene load_steps=8 format=2]
+[gd_scene load_steps=9 format=2]
[ext_resource path="res://Scenes/Dungeon.gd" type="Script" id=1]
[ext_resource path="res://Scenes/CameraControl.gd" type="Script" id=2]
[ext_resource path="res://Assets/Environment/Floor_tile.png" type="Texture" id=3]
+[ext_resource path="res://Scenes/UIController.gd" type="Script" id=4]
[sub_resource type="PlaneMesh" id=1]
@@ -48,3 +49,11 @@ size = 7.35
[node name="DirectionalLight" type="DirectionalLight" parent="."]
transform = Transform( 0.73644, 0.441272, -0.512773, 0, 0.757975, 0.652284, 0.676503, -0.480367, 0.558203, 0, 35.1428, 0 )
light_energy = 0.5
+
+[node name="CanvasLayer" type="CanvasLayer" parent="."]
+script = ExtResource( 4 )
+
+[node name="NumberOfTurns" type="Label" parent="CanvasLayer"]
+margin_right = 40.0
+margin_bottom = 14.0
+rect_scale = Vector2( 2, 2 )
diff --git a/Scenes/Monster.gd b/Scenes/Monster.gd
index 38ea3ef..a760d64 100644
--- a/Scenes/Monster.gd
+++ b/Scenes/Monster.gd
@@ -5,6 +5,7 @@ class_name Monster
enum MonsterActionType {IDLE, ATTACK, MOVE}
export(int) var damage = 1
+export(int) var health = 1
onready var alive = true
onready var sprite = $Sprite3D
@@ -19,6 +20,10 @@ func try_moving(player_pos : Vector2, monster_pos : Vector2) -> MonsterAction:
func cor_attack(args : Array):
yield()
+func cor_stomp(args : Array):
+ $AnimationPlayer.play("stomp")
+ yield($AnimationPlayer, "animation_finished")
+
func cor_dies(args : Array):
$AnimationPlayer.play("fucking_dies")
yield($AnimationPlayer, "animation_finished")
diff --git a/Scenes/Monster.tscn b/Scenes/Monster.tscn
index 5be54c8..1759983 100644
--- a/Scenes/Monster.tscn
+++ b/Scenes/Monster.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=6 format=2]
+[gd_scene load_steps=7 format=2]
[ext_resource path="res://icon.png" type="Texture" id=1]
[ext_resource path="res://Scenes/Monster.gd" type="Script" id=2]
@@ -44,7 +44,7 @@ tracks/0/keys = {
"times": PoolRealArray( 0, 0.2 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
-"values": [ Vector3( 1, 1, 1 ), Vector3( 1, 0, 1 ) ]
+"values": [ Vector3( 1, 1, 1 ), Vector3( 1.5, 0, 1 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("Sprite3D:translation")
@@ -59,6 +59,34 @@ tracks/1/keys = {
"values": [ Vector3( 0, 0.605694, 0 ), Vector3( 0, 0, 0 ) ]
}
+[sub_resource type="Animation" id=3]
+resource_name = "stomp"
+length = 0.2
+tracks/0/type = "value"
+tracks/0/path = NodePath("Sprite3D:scale")
+tracks/0/interp = 1
+tracks/0/loop_wrap = true
+tracks/0/imported = false
+tracks/0/enabled = true
+tracks/0/keys = {
+"times": PoolRealArray( 0, 0.1, 0.2 ),
+"transitions": PoolRealArray( 1, 1, 1 ),
+"update": 0,
+"values": [ Vector3( 1, 1, 1 ), Vector3( 1.4, 0.5, 1 ), Vector3( 1, 1, 1 ) ]
+}
+tracks/1/type = "value"
+tracks/1/path = NodePath("Sprite3D:translation")
+tracks/1/interp = 1
+tracks/1/loop_wrap = true
+tracks/1/imported = false
+tracks/1/enabled = true
+tracks/1/keys = {
+"times": PoolRealArray( 0, 0.1, 0.2 ),
+"transitions": PoolRealArray( 1, 1, 1 ),
+"update": 0,
+"values": [ Vector3( 0, 0.605694, 0 ), Vector3( 0, 0, 0 ), Vector3( 0, 0.605694, 0 ) ]
+}
+
[node name="Monster" type="Spatial"]
script = ExtResource( 2 )
actionable = true
@@ -83,3 +111,4 @@ texture = ExtResource( 3 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/RESET = SubResource( 1 )
anims/fucking_dies = SubResource( 2 )
+anims/stomp = SubResource( 3 )
diff --git a/Scenes/MonsterRandCardinal.gd b/Scenes/MonsterRandCardinal.gd
index 8689b51..0fdabb1 100644
--- a/Scenes/MonsterRandCardinal.gd
+++ b/Scenes/MonsterRandCardinal.gd
@@ -2,28 +2,25 @@ extends Monster
onready var cardinal = Vector2.UP
onready var moved = false
-onready var wait = -1
+onready var wait = 0
func _ready():
._ready()
if randf() < 0.5:
cardinal = Vector2.RIGHT
- if randf() < 0.5:
- wait = 0
func get_weakness():
return ['2','4','6']
func try_moving(player_pos : Vector2, monster_pos : Vector2) -> MonsterAction:
var action = MonsterAction.new()
-
- if wait != -1:
- if wait == 0:
- wait = 1
- action.type = MonsterActionType.IDLE
- return action
- else:
- wait = 0
+
+ if wait == 0:
+ wait = 1
+ action.type = MonsterActionType.IDLE
+ return action
+ else:
+ wait = 0
var next_movement = cardinal
if moved:
diff --git a/Scenes/Player.gd b/Scenes/Player.gd
index 6cde567..e0ce5ff 100644
--- a/Scenes/Player.gd
+++ b/Scenes/Player.gd
@@ -92,6 +92,49 @@ func cor_move(args : Array): # args = [Vector3, float]
yield(get_tree(), "idle_frame")
+func cor_half_move(args : Array): # args = [Vector3, float]
+ var pos_original = translation
+ var pos_a = translation
+ var pos_b = args[0]
+
+ var dir = pos_b - pos_a
+
+ var basis_a = mesh.transform.basis
+ var basis_b = basis_a.rotated(Vector3(dir.z, 0, -dir.x), PI / 2)
+
+ var duration = args[1]
+ var time = 0
+
+ while true:
+ time = min(time + get_process_delta_time(), duration)
+ var weight = time / (duration)
+
+ translation = pos_a + dir * weight
+ mesh.transform.basis = basis_a.slerp(basis_b, weight)
+ mesh.translation = Vector3(0, 0.5 + sin(weight * PI) / 4, 0)
+
+ if time >= (duration):
+ break
+
+ yield(get_tree(), "idle_frame")
+
+ pos_b = pos_original
+ pos_a = translation
+ dir = pos_b - pos_a
+ time = 0
+
+ while true:
+ time = min(time + get_process_delta_time(), duration)
+ var weight = time / (duration)
+
+ translation = pos_a + dir * weight
+
+ if time >= (duration):
+ break
+
+ yield(get_tree(), "idle_frame")
+
+
func cor_shake(args : Array):
var duration = args[0]
var time = 0