Skip to content

Commit

Permalink
Building on alex's work
Browse files Browse the repository at this point in the history
  • Loading branch information
MatrixFrog committed Jan 8, 2024
1 parent cdef190 commit cc5ced1
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 58 deletions.
1 change: 0 additions & 1 deletion 2d/role_playing_game/Game.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
extends Node


@export var combat_screen: NodePath
@export var exploration_screen: NodePath

Expand Down
2 changes: 1 addition & 1 deletion 2d/role_playing_game/Game.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[ext_resource type="Script" path="res://Game.gd" id="1"]
[ext_resource type="PackedScene" uid="uid://1a847rc1yude" path="res://combat/Combat.tscn" id="2"]
[ext_resource type="PackedScene" path="res://grid_movement/Exploration.tscn" id="3"]
[ext_resource type="PackedScene" uid="uid://343t45ghceqo" path="res://grid_movement/Exploration.tscn" id="3"]

[sub_resource type="Animation" id="1"]
length = 0.5
Expand Down
2 changes: 0 additions & 2 deletions 2d/role_playing_game/combat/Combat.gd
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
extends Node


signal combat_finished(winner, loser)


func initialize(combat_combatants):
for combatant in combat_combatants:
combatant = combatant.instantiate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ var dialogue_text = ""
signal dialogue_started
signal dialogue_finished


func start_dialogue():
emit_signal("dialogue_started")
current = 0
Expand Down
57 changes: 26 additions & 31 deletions 2d/role_playing_game/grid_movement/Exploration.tscn

Large diffs are not rendered by default.

35 changes: 14 additions & 21 deletions 2d/role_playing_game/grid_movement/grid/Grid.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ enum CellType { ACTOR, OBSTACLE, OBJECT }

func _ready():
for child in get_children():
#TODO
#set_cellv(local_to_map(child.position), child.type)
print(get_layers_count())
# set_cell? (int layer, Vector2i coords, int source_id=-1, Vector2i atlas_coords=Vector2i(-1, -1), int alternative_tile=0)
# https://docs.godotengine.org/en/latest/classes/class_tilemap.html#class-tilemap-method-set-cell
#set_cell(local_to_map(child.position), child.type)

set_cell(0, local_to_map(child.position), child.type)

func get_cell_pawn(cell, type = CellType.ACTOR):
for node in get_children():
Expand All @@ -25,17 +19,16 @@ func request_move(pawn, direction):
var cell_start = local_to_map(pawn.position)
var cell_target = cell_start + direction

#TODO
# var cell_tile_id = get_cellv(cell_target)
# match cell_tile_id:
# -1:
# set_cellv(cell_target, CellType.ACTOR)
# set_cellv(cell_start, -1)
# return map_to_local(cell_target) + cell_size / 2
# CellType.OBJECT, CellType.ACTOR:
# var target_pawn = get_cell_pawn(cell_target, cell_tile_id)
# print("Cell %s contains %s" % [cell_target, target_pawn.name])
#
# if not target_pawn.has_node("DialoguePlayer"):
# return
# get_node(dialogue_ui).show_dialogue(pawn, target_pawn.get_node(^"DialoguePlayer"))
var cell_tile_id = get_cell_source_id(0, cell_target)
match cell_tile_id:
-1:
set_cell(0, cell_target, CellType.ACTOR)
set_cell(0, cell_start, -1)
return map_to_local(cell_target) + Vector2(tile_set.tile_size.x / 2, tile_set.tile_size.y / 2)
CellType.OBJECT, CellType.ACTOR:
var target_pawn = get_cell_pawn(cell_target, cell_tile_id)
print("Cell %s contains %s" % [cell_target, target_pawn.name])

if not target_pawn.has_node("DialoguePlayer"):
return
get_node(dialogue_ui).show_dialogue(pawn, target_pawn.get_node(^"DialoguePlayer"))
2 changes: 1 addition & 1 deletion 2d/role_playing_game/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ and GDScript. It also includes a simple JRPG-style dialogue and
battle system on top of it."
config/tags=PackedStringArray("2d", "demo", "gui", "official", "tilemap")
run/main_scene="res://Game.tscn"
config/features=PackedStringArray("4.1")
config/features=PackedStringArray("4.2")
config/icon="res://icon.webp"

[display]
Expand Down

0 comments on commit cc5ced1

Please sign in to comment.