summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrenin Cardoso <behilustra@gmail.com>2022-07-16 14:35:23 -0300
committerBrenin Cardoso <behilustra@gmail.com>2022-07-16 14:35:23 -0300
commit093a70adfe922f22b07bbf3b02fa52774c989943 (patch)
treea4442d58f37b501a33c1c6da6bd050dc556c6e64
parent72e676dbe630b5e34dd5dbf297065902d19e7a11 (diff)
parent474d7a8112f81712e0b612c22ec3ac9608a858d1 (diff)
downloadgamejam-gmtk-2022-093a70adfe922f22b07bbf3b02fa52774c989943.tar.gz
gamejam-gmtk-2022-093a70adfe922f22b07bbf3b02fa52774c989943.tar.bz2
gamejam-gmtk-2022-093a70adfe922f22b07bbf3b02fa52774c989943.zip
Merge remote-tracking branch 'origin/main'
# Conflicts: # Scenes/Dungeon.tscn
-rw-r--r--Scenes/Door.gd4
-rw-r--r--Scenes/Dungeon.gd53
-rw-r--r--Scenes/Global.gd17
-rw-r--r--Scenes/UIController.gd8
-rw-r--r--project.godot4
5 files changed, 72 insertions, 14 deletions
diff --git a/Scenes/Door.gd b/Scenes/Door.gd
index 2918d8b..c366514 100644
--- a/Scenes/Door.gd
+++ b/Scenes/Door.gd
@@ -6,6 +6,10 @@ export(bool) var is_open = false
onready var mesh = $Mesh
+func _ready():
+ ._ready()
+ add_to_group("doors")
+
func cor_open(args : Array):
var duration = args[0]
var time = 0
diff --git a/Scenes/Dungeon.gd b/Scenes/Dungeon.gd
index 7c923db..38800ba 100644
--- a/Scenes/Dungeon.gd
+++ b/Scenes/Dungeon.gd
@@ -44,23 +44,32 @@ func build_floor():
for i in range(4):
rand_pos = Vector2(randi()%8 - 4, randi()%8 - 4)
+ while tiles_entities.has(rand_pos):
+ rand_pos = Vector2(randi()%8 - 4, randi()%8 - 4)
var obstacle = Obstacle.instance()
set_tile(obstacle, rand_pos)
add_child(obstacle)
for i in range(4):
rand_pos = Vector2(randi()%8 - 4, randi()%8 - 4)
+ while tiles_entities.has(rand_pos):
+ rand_pos = Vector2(randi()%8 - 4, randi()%8 - 4)
var monster = MonsterScene.instance()
set_tile(monster, rand_pos)
add_child(monster)
- for i in range(2):
- rand_pos = Vector2(randi()%6 - 3, randi()%6 - 3)
+ var number_doors = floor(Global.current_stage / 10.0) + 1
+ for i in range(number_doors):
+ rand_pos = Vector2(randi()%8 - 4, randi()%8 - 4)
+ while tiles_entities.has(rand_pos):
+ rand_pos = Vector2(randi()%8 - 4, randi()%8 - 4)
var door = Door.instance()
set_tile(door, rand_pos)
add_child(door)
- rand_pos = Vector2(randi()%6 - 3, randi()%6 - 3)
+ rand_pos = Vector2(randi()%8 - 4, randi()%8 - 4)
+ while tiles_entities.has(rand_pos):
+ rand_pos = Vector2(randi()%8 - 4, randi()%8 - 4)
var plate_key = PlateKey.instance()
plate_key.set_door(door)
tiles_floor[rand_pos] = plate_key
@@ -76,7 +85,6 @@ func build_floor():
func _process(delta):
var actionables = get_tree().get_nodes_in_group("actionables")
-
var idle = true
for actionable in actionables:
@@ -85,11 +93,24 @@ func _process(delta):
idle = false
break
+ var doors = get_tree().get_nodes_in_group("doors")
+ var next_stage = true
+ for door in doors:
+ if not door.is_open:
+ next_stage = false
+ break
+ if next_stage:
+ next_stage()
+
if not idle or input == Vector2.ZERO:
return
process_turn_logic()
+func next_stage():
+ Global.turns += Global.BONUS_TURNS_STAGE_FINISH
+ Global.current_stage += 1
+ get_tree().change_scene("res://Scenes/Dungeon.tscn")
func process_turn_logic():
# player attack
@@ -100,16 +121,20 @@ func process_turn_logic():
player.roll(input)
if tiles_entities.has(new_tile):
var monster = tiles_entities[new_tile]
- if monster.has_method("get_weakness"):
- if tiles_entities[new_tile].get_weakness().has(player.get_upper_face()):
- monster.alive = false
- monster.add_action("cor_dies", [])
- kill_entity(monster)
+ if monster is Monster:
+ monster.alive = false
+ monster.add_action("cor_dies", [])
+ Global.turns += int(player.get_upper_face())
+ kill_entity(monster)
player.roll(-input)
# player move
if move_entity(player, input):
player.roll(input)
+
+ var player_tile = entities_tiles[player]
+ if tiles_floor.has(player_tile):
+ tiles_floor[player_tile].step(player.get_top())
input = Vector2.ZERO
# check tile player
@@ -125,6 +150,7 @@ func process_turn_logic():
pass
Monster.MonsterActionType.ATTACK:
player.add_action("cor_shake", [0.2])
+ Global.turns -= 1
Monster.MonsterActionType.MOVE:
move_entity(monster, monster_action.dir)
@@ -134,6 +160,8 @@ func process_turn_logic():
var actionables = get_tree().get_nodes_in_group("actionables")
for actionable in actionables:
actionable.play_actions()
+
+ Global.turns -= 1
func _input(event):
if input != Vector2.ZERO:
@@ -152,11 +180,13 @@ func _input(event):
KEY_LEFT:
input = Vector2(-1,0)
KEY_ESCAPE:
+ Global.turns = Global.STARTING_TURNS
get_tree().change_scene("res://Scenes/Dungeon.tscn")
func move_entity(entity : Entity, dir : Vector2):
var cur_tile = entities_tiles[entity]
var new_tile = cur_tile + dir
+ new_tile = Vector2(round(new_tile.x), round(new_tile.y))
if tiles_entities.has(new_tile):
if entity.has_method("cor_shake"):
@@ -164,13 +194,8 @@ func move_entity(entity : Entity, dir : Vector2):
return false
set_tile(entity, new_tile)
-
-
entity.add_action("cor_move", [tile_to_pos(new_tile), 0.2])
- if tiles_floor.has(new_tile):
- tiles_floor[new_tile].step(entity.get_top())
-
return true
func tile_to_pos(tile : Vector2):
diff --git a/Scenes/Global.gd b/Scenes/Global.gd
new file mode 100644
index 0000000..1a4c020
--- /dev/null
+++ b/Scenes/Global.gd
@@ -0,0 +1,17 @@
+extends Node
+
+onready var STARTING_TURNS = 20
+onready var BONUS_TURNS_STAGE_FINISH = 10
+
+onready var turns = STARTING_TURNS setget set_turns
+onready var current_stage = 0 setget set_stage
+
+signal update_ui
+
+func set_turns(t):
+ turns = t
+ emit_signal("update_ui")
+
+func set_stage(s):
+ current_stage = s
+ emit_signal("update_ui")
diff --git a/Scenes/UIController.gd b/Scenes/UIController.gd
new file mode 100644
index 0000000..1599d03
--- /dev/null
+++ b/Scenes/UIController.gd
@@ -0,0 +1,8 @@
+extends CanvasLayer
+
+func _ready():
+ Global.connect("update_ui", self, "_on_update_ui")
+ _on_update_ui()
+
+func _on_update_ui():
+ $NumberOfTurns.text = "Number of turns: %d" % Global.turns
diff --git a/project.godot b/project.godot
index 153840b..241443a 100644
--- a/project.godot
+++ b/project.godot
@@ -42,6 +42,10 @@ config/name="gmtk2022"
run/main_scene="res://Scenes/Dungeon.tscn"
config/icon="res://icon.png"
+[autoload]
+
+Global="*res://Scenes/Global.gd"
+
[physics]
common/enable_pause_aware_picking=true