diff options
author | Victor Andrade de Almeida <vct.a.almeida@gmail.com> | 2022-07-16 15:18:11 -0300 |
---|---|---|
committer | Victor Andrade de Almeida <vct.a.almeida@gmail.com> | 2022-07-16 15:18:11 -0300 |
commit | bdfd427adb0a262c460e6ae020d587206e0fc1ea (patch) | |
tree | b71006238f61e9de1a95f81c5781ca29fdd829b6 | |
parent | 093a70adfe922f22b07bbf3b02fa52774c989943 (diff) | |
download | gamejam-gmtk-2022-bdfd427adb0a262c460e6ae020d587206e0fc1ea.tar.gz gamejam-gmtk-2022-bdfd427adb0a262c460e6ae020d587206e0fc1ea.tar.bz2 gamejam-gmtk-2022-bdfd427adb0a262c460e6ae020d587206e0fc1ea.zip |
Replace doors with crystals
-rw-r--r-- | Scenes/Crystal.gd | 32 | ||||
-rw-r--r-- | Scenes/Crystal.tscn | 20 | ||||
-rw-r--r-- | Scenes/Door.gd | 28 | ||||
-rw-r--r-- | Scenes/Door.tscn | 18 | ||||
-rw-r--r-- | Scenes/Dungeon.gd | 24 | ||||
-rw-r--r-- | Scenes/PlateKey.gd | 14 | ||||
-rw-r--r-- | project.godot | 6 |
7 files changed, 74 insertions, 68 deletions
diff --git a/Scenes/Crystal.gd b/Scenes/Crystal.gd new file mode 100644 index 0000000..620cea5 --- /dev/null +++ b/Scenes/Crystal.gd @@ -0,0 +1,32 @@ +extends Entity + +class_name Crystal + +export(bool) var is_active = false +export(Color) var active_color + +onready var mesh : MeshInstance = $Mesh + +func _ready(): + ._ready() + add_to_group("crystals") + +func cor_activate(args : Array): + var duration = args[0] + var time = 0 + + var material = mesh.get_active_material(0) + var color = material.albedo_color + + while true: + time = min(time + get_process_delta_time(), duration) + var weight = time / duration + + material.albedo_color = color.linear_interpolate(active_color, weight) + + if time >= duration: + break + + yield(get_tree(), "idle_frame") + + is_active = true diff --git a/Scenes/Crystal.tscn b/Scenes/Crystal.tscn new file mode 100644 index 0000000..3e87bcd --- /dev/null +++ b/Scenes/Crystal.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://Scenes/Crystal.gd" type="Script" id=1] + +[sub_resource type="PrismMesh" id=3] +size = Vector3( 1, 1, 1 ) + +[sub_resource type="SpatialMaterial" id=2] +resource_local_to_scene = true +albedo_color = Color( 0.819608, 0.858824, 0.921569, 1 ) + +[node name="Crystal" type="Spatial"] +script = ExtResource( 1 ) +actionable = true +active_color = Color( 0.564706, 0.294118, 1, 1 ) + +[node name="Mesh" type="MeshInstance" parent="."] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0 ) +mesh = SubResource( 3 ) +material/0 = SubResource( 2 ) diff --git a/Scenes/Door.gd b/Scenes/Door.gd deleted file mode 100644 index c366514..0000000 --- a/Scenes/Door.gd +++ /dev/null @@ -1,28 +0,0 @@ -extends Entity - -class_name Door - -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 - - while true: - time = min(time + get_process_delta_time(), duration) - var weight = time / duration - - mesh.translation = Vector3(0, 0.5 - weight * 0.95, 0) - - if time >= duration: - break - - yield(get_tree(), "idle_frame") - - is_open = true diff --git a/Scenes/Door.tscn b/Scenes/Door.tscn deleted file mode 100644 index 0b3e869..0000000 --- a/Scenes/Door.tscn +++ /dev/null @@ -1,18 +0,0 @@ -[gd_scene load_steps=4 format=2] - -[ext_resource path="res://Scenes/Door.gd" type="Script" id=1] - -[sub_resource type="CubeMesh" id=1] -size = Vector3( 1, 1, 1 ) - -[sub_resource type="SpatialMaterial" id=2] -albedo_color = Color( 0.34902, 0.541176, 0.835294, 1 ) - -[node name="Door" type="Spatial"] -script = ExtResource( 1 ) -actionable = true - -[node name="Mesh" type="MeshInstance" parent="."] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0 ) -mesh = SubResource( 1 ) -material/0 = SubResource( 2 ) diff --git a/Scenes/Dungeon.gd b/Scenes/Dungeon.gd index 38800ba..43e8476 100644 --- a/Scenes/Dungeon.gd +++ b/Scenes/Dungeon.gd @@ -4,7 +4,7 @@ const Player = preload("res://Scenes/Player.tscn") const Obstacle = preload("res://Scenes/Obstacle.tscn") const MonsterScene = preload("res://Scenes/MonsterRandCardinal.tscn") const PlateKey = preload("res://Scenes/PlateKey.tscn") -const Door = preload("res://Scenes/Door.tscn") +const Crystal = preload("res://Scenes/Crystal.tscn") onready var camera = $Pitch onready var player : Entity = null @@ -58,20 +58,20 @@ func build_floor(): set_tile(monster, rand_pos) add_child(monster) - var number_doors = floor(Global.current_stage / 10.0) + 1 - for i in range(number_doors): + var number_crystals = floor(Global.current_stage / 10.0) + 1 + for i in range(number_crystals): 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) + var crystal = Crystal.instance() + set_tile(crystal, rand_pos) + add_child(crystal) 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) + plate_key.set_crystal(crystal) tiles_floor[rand_pos] = plate_key add_child(plate_key) @@ -93,10 +93,10 @@ func _process(delta): idle = false break - var doors = get_tree().get_nodes_in_group("doors") + var crystals = get_tree().get_nodes_in_group("crystals") var next_stage = true - for door in doors: - if not door.is_open: + for crystal in crystals: + if not crystal.is_active: next_stage = false break if next_stage: @@ -131,7 +131,7 @@ func process_turn_logic(): # 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()) @@ -160,7 +160,7 @@ 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): diff --git a/Scenes/PlateKey.gd b/Scenes/PlateKey.gd index 33c563b..e43d664 100644 --- a/Scenes/PlateKey.gd +++ b/Scenes/PlateKey.gd @@ -1,15 +1,15 @@ extends Plate -export(NodePath) var door_path +export(NodePath) var crystal_path -onready var door : Door = get_node(door_path) setget set_door +onready var crystal : Crystal = get_node(crystal_path) setget set_crystal func activate(): - if door == null or door.is_open: + if crystal == null or crystal.is_active: return - door.add_action("cor_open", [0.2]) + crystal.add_action("cor_activate", [0.2]) -func set_door(value : Door): - door = value - door_path = value.get_path() +func set_crystal(value : Crystal): + crystal = value + crystal_path = value.get_path() diff --git a/project.godot b/project.godot index 241443a..2fc313d 100644 --- a/project.godot +++ b/project.godot @@ -10,9 +10,9 @@ config_version=4 _global_script_classes=[ { "base": "Entity", -"class": "Door", +"class": "Crystal", "language": "GDScript", -"path": "res://Scenes/Door.gd" +"path": "res://Scenes/Crystal.gd" }, { "base": "Spatial", "class": "Entity", @@ -30,7 +30,7 @@ _global_script_classes=[ { "path": "res://Scenes/Plate.gd" } ] _global_script_class_icons={ -"Door": "", +"Crystal": "", "Entity": "", "Monster": "", "Plate": "" |