Compare commits

..

3 commits

Author SHA1 Message Date
1adf5b5ed7
Create prototype for map (unfinished)
All checks were successful
/ test (push) Successful in 2s
2025-03-11 06:42:57 +01:00
f6c53bf5ca
Color text when chanting
All checks were successful
/ test (push) Successful in 2s
2025-03-09 10:31:55 +01:00
097de25931
Add ritual incantation
All checks were successful
/ test (push) Successful in 2s
2025-03-09 09:17:55 +01:00
21 changed files with 340 additions and 6 deletions

21
curved_label.gd Normal file
View file

@ -0,0 +1,21 @@
@tool
class_name CurvedLabel
extends Control
@export var curve: Curve
@export var text: String:
set(new_value):
text = new_value
queue_redraw()
@export var enable_rotation: bool = true:
set(new_value):
enable_rotation = new_value
queue_redraw()
func _draw():
var rotation = 0.0
for i in text.length():
draw_char(get_theme_default_font(), Vector2.ZERO + (Vector2.RIGHT * (i*10)), text[i])
rotation += 10.0 if enable_rotation else 0
draw_set_transform(Vector2.ZERO, deg_to_rad(rotation))

1
curved_label.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://dcj3w8wie6ohv

58
incantation.gd Normal file
View file

@ -0,0 +1,58 @@
extends Path2D
signal completed
var is_mouse_in_path_follow_area: bool = false
var is_incantation_started: bool = false
var incantation_progress: float = 0.0
var is_incantation_completed: bool = false
@onready var area: Area2D = $Area2D
@onready var incantation_text: IncantationText = $IncantationText
func _ready():
area.mouse_entered.connect(func(): is_mouse_in_path_follow_area = true)
area.mouse_exited.connect(func():
is_mouse_in_path_follow_area = false
reset_incantation()
)
func _draw():
# Draws debug line accross the path in game
#var points = curve.get_baked_points()
#for i in points.size():
# if i == 0: continue
# draw_line(points[i-1], points[i], Color.BLACK, 2.0)
pass
var previous_offset: float:
set(new_value):
previous_offset = new_value
incantation_text.colored_offset = previous_offset
func _input(event):
if is_incantation_completed: return
if event is InputEventMouseButton:
if event.is_pressed() and is_mouse_in_path_follow_area and not is_incantation_started:
is_incantation_started = true
if event is InputEventMouseMotion and is_incantation_started:
var motion_event = event as InputEventMouseMotion
var next_point = curve.get_closest_point(to_local(motion_event.global_position))
var next_offset = curve.get_closest_offset(next_point)
if previous_offset <= 0.0:
previous_offset = next_offset
elif next_offset - previous_offset <= 0:
return
previous_offset = next_offset
area.position = next_point
if next_point == curve.get_point_position(curve.point_count - 1):
completed.emit()
is_incantation_completed = true
func reset_incantation():
if is_incantation_completed: return
is_incantation_started = false
area.position = curve.get_point_position(0)
previous_offset = 0.0

1
incantation.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://dak6uc4v3us7w

27
incantation_text.gd Normal file
View file

@ -0,0 +1,27 @@
@tool
class_name IncantationText
extends Control
@export_multiline var text: String:
set(new_value):
text = new_value
queue_redraw()
@export var colored_offset: float = 0:
set(new_value):
colored_offset = new_value
queue_redraw()
var curve: Curve2D
func _ready():
curve = (get_parent() as Path2D).curve
func _draw():
if text.length() < 2: return
var offset = 0
for c in text:
var t = curve.sample_baked_with_rotation(offset)
draw_set_transform(t.origin - (Vector2.UP * 5).rotated(t.get_rotation()), t.get_rotation())
draw_char(get_theme_default_font(), Vector2.ZERO, c, 16, Color.WHITE if offset >= colored_offset else Color.RED)
offset += 10

1
incantation_text.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://cpscp5a5nxfop

View file

@ -2,6 +2,7 @@ extends Node2D
const DARK_CUT_SCENE = preload("res://operation/prototype_dark_cut.tscn")
const DIALOG_SCENE = preload("res://dialog.tscn")
const RITUAL_BOOK_SCENE = preload("res://prototype_ritual_book.tscn")
@onready var room: Node2D = $Room
@ -53,3 +54,7 @@ func _disable_node2d(node: Node2D):
func _enable_node2d(node: Node2D):
node.show()
node.set_deferred("process", true)
func _on_ritual_book_clicked():
pass # Replace with function body.

View file

@ -1,9 +1,11 @@
[gd_scene load_steps=28 format=3 uid="uid://w3ntt1yh1nq7"]
[gd_scene load_steps=32 format=3 uid="uid://w3ntt1yh1nq7"]
[ext_resource type="Script" uid="uid://lnmooufxbuym" path="res://main.gd" id="1_dp5o4"]
[ext_resource type="PackedScene" uid="uid://3oqyqft8w72m" path="res://selectable.tscn" id="3_g5hfc"]
[ext_resource type="Script" uid="uid://c3dlxuhruho8c" path="res://operation/feedback_canvas_modulate.gd" id="4_0odxb"]
[ext_resource type="Texture2D" uid="uid://bicjfwpoa3pma" path="res://operation/test_table.png" id="5_lswn8"]
[ext_resource type="Script" uid="uid://ctpgjvo5g0sav" path="res://ritual_book.gd" id="12_ycdy4"]
[ext_resource type="PackedScene" uid="uid://qkwh186nbcya" path="res://prototype_ritual_book.tscn" id="13_ycdy4"]
[ext_resource type="Texture2D" uid="uid://ccy71gl4qatjy" path="res://operation/pliers.png" id="17_b1qrp"]
[ext_resource type="Script" uid="uid://crkr8emyhv1fo" path="res://operation/pliers.gd" id="18_come4"]
[ext_resource type="PackedScene" uid="uid://c3of67m4ic212" path="res://operation/pickup_area.tscn" id="19_h8e4i"]
@ -49,8 +51,8 @@ width = 170
height = 170
[sub_resource type="Gradient" id="Gradient_b76e3"]
offsets = PackedFloat32Array(0.0881356)
colors = PackedColorArray(0.0885599, 0.0885599, 0.0885599, 1)
offsets = PackedFloat32Array(0.240678)
colors = PackedColorArray(0.737193, 0.737193, 0.737193, 1)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_soglf"]
gradient = SubResource("Gradient_b76e3")
@ -76,6 +78,15 @@ radius = 5.65684
[sub_resource type="RectangleShape2D" id="RectangleShape2D_0odxb"]
size = Vector2(110, 65)
[sub_resource type="Gradient" id="Gradient_vivmo"]
offsets = PackedFloat32Array(0.353357, 0.929329, 1)
colors = PackedColorArray(0, 0, 0, 1, 0.498233, 0.498233, 0.498233, 1, 1, 1, 1, 1)
[sub_resource type="GradientTexture2D" id="GradientTexture2D_2cqfq"]
gradient = SubResource("Gradient_vivmo")
width = 32
height = 128
[node name="Main" type="Node2D"]
script = ExtResource("1_dp5o4")
@ -131,8 +142,6 @@ position = Vector2(242, 258)
texture = SubResource("GradientTexture2D_ty4ro")
[node name="Selectable" parent="Room/Bob" instance=ExtResource("3_g5hfc")]
collision_layer = 256
collision_mask = 256
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Room/Bob/Selectable"]
polygon = PackedVector2Array(-50, 100, -50, -100, 50, -100, 50, 100)
@ -249,8 +258,31 @@ collision_mask = 8
scale = Vector2(0.983051, 1)
shape = SubResource("RectangleShape2D_0odxb")
[node name="RitualBook" type="Node2D" parent="Shelves"]
position = Vector2(-92, 240.5)
script = ExtResource("12_ycdy4")
[node name="Sprite2D" type="Sprite2D" parent="Shelves/RitualBook"]
texture = SubResource("GradientTexture2D_2cqfq")
[node name="Selectable" parent="Shelves/RitualBook/Sprite2D" instance=ExtResource("3_g5hfc")]
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Shelves/RitualBook/Sprite2D/Selectable"]
polygon = PackedVector2Array(-16, -64, -16, 64, 16, 64, 16, -64)
[node name="Label" type="Label" parent="Shelves/RitualBook"]
offset_left = -17.0
offset_top = 40.5
offset_right = 68.0
offset_bottom = 63.5
rotation = -1.5708
text = "Rituals 101"
[node name="PrototypeRitualBook" parent="." instance=ExtResource("13_ycdy4")]
[connection signal="clicked" from="Room/Bob/Selectable" to="." method="_on_bob_clicked"]
[connection signal="clicked" from="Room/RitualPlace/Selectable" to="." method="_on_ritual_place_clicked"]
[connection signal="area_entered" from="Shelves/Scalpel/CutArea" to="Shelves/Scalpel" method="_on_cut_area_area_entered"]
[connection signal="area_exited" from="Shelves/Scalpel/CutArea" to="Shelves/Scalpel" method="_on_cut_area_area_exited"]
[connection signal="timeout" from="Shelves/Scalpel/CutHurtTimer" to="Shelves/Scalpel" method="_on_cut_hurt_timer_timeout"]
[connection signal="clicked" from="Shelves/RitualBook/Sprite2D/Selectable" to="." method="_on_ritual_book_clicked"]

26
map_point.gd Normal file
View file

@ -0,0 +1,26 @@
@tool
class_name MapPoint
extends Node2D
@export_tool_button("Update lines", "Callable") var update_lines = queue_redraw
@export var connected_map_points: Array[MapPoint] = []:
set(new_value):
connected_map_points = new_value
queue_redraw()
@onready var hover_dot: Sprite2D = $HoverDot
func _ready():
queue_redraw()
func _on_area_2d_mouse_entered():
hover_dot.show()
func _on_area_2d_mouse_exited():
hover_dot.hide()
func _draw():
for p in connected_map_points:
draw_dashed_line(Vector2.ZERO, to_local(p.global_position), Color.BLACK)

1
map_point.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://bhct6bhjtnml0

48
map_point.tscn Normal file
View file

@ -0,0 +1,48 @@
[gd_scene load_steps=7 format=3 uid="uid://b5tdh43sbe5nj"]
[ext_resource type="Script" uid="uid://bhct6bhjtnml0" path="res://map_point.gd" id="1_jfx02"]
[sub_resource type="Gradient" id="Gradient_tn1m0"]
offsets = PackedFloat32Array(0.40636, 0.45583)
colors = PackedColorArray(1, 1, 1, 1, 0, 0, 0, 0)
[sub_resource type="GradientTexture2D" id="GradientTexture2D_pw3im"]
gradient = SubResource("Gradient_tn1m0")
width = 40
height = 40
fill = 1
fill_from = Vector2(0.5, 0.5)
[sub_resource type="Gradient" id="Gradient_ywy6p"]
offsets = PackedFloat32Array(0.40636, 0.45583)
colors = PackedColorArray(0, 0, 0, 1, 0, 0, 0, 0)
[sub_resource type="GradientTexture2D" id="GradientTexture2D_gpntq"]
gradient = SubResource("Gradient_ywy6p")
width = 32
height = 32
fill = 1
fill_from = Vector2(0.5, 0.5)
[sub_resource type="CircleShape2D" id="CircleShape2D_01fxh"]
radius = 13.0384
[node name="MapPoint" type="Node2D"]
script = ExtResource("1_jfx02")
[node name="HoverDot" type="Sprite2D" parent="."]
visible = false
texture = SubResource("GradientTexture2D_pw3im")
[node name="Dot" type="Sprite2D" parent="."]
texture = SubResource("GradientTexture2D_gpntq")
[node name="Area2D" type="Area2D" parent="."]
collision_layer = 1024
collision_mask = 1024
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource("CircleShape2D_01fxh")
[connection signal="mouse_entered" from="Area2D" to="." method="_on_area_2d_mouse_entered"]
[connection signal="mouse_exited" from="Area2D" to="." method="_on_area_2d_mouse_exited"]

View file

@ -27,6 +27,10 @@ cutter=""
grabber=""
patience_bar=""
[gui]
theme/default_font_multichannel_signed_distance_field=true
[layer_names]
2d_physics/layer_1="Scalpel"
@ -34,6 +38,8 @@ patience_bar=""
2d_physics/layer_3="Body"
2d_physics/layer_4="Pliers"
2d_physics/layer_9="Selectable"
2d_physics/layer_10="Incantation"
2d_physics/layer_11="Map"
[rendering]

1
prototype_map.gd Normal file
View file

@ -0,0 +1 @@
extends Node2D

1
prototype_map.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://cvcec0uf3erkv

36
prototype_map.tscn Normal file
View file

@ -0,0 +1,36 @@
[gd_scene load_steps=5 format=3 uid="uid://cb4cokd0lxacj"]
[ext_resource type="Script" uid="uid://cvcec0uf3erkv" path="res://prototype_map.gd" id="1_mj08v"]
[ext_resource type="PackedScene" uid="uid://b5tdh43sbe5nj" path="res://map_point.tscn" id="2_mj08v"]
[sub_resource type="Gradient" id="Gradient_6vn6g"]
offsets = PackedFloat32Array(0.575972, 0.929329, 1)
colors = PackedColorArray(0.74902, 0.647059, 0.541176, 1, 0.61, 0.527447, 0.4392, 1, 0.19, 0.164287, 0.1368, 1)
[sub_resource type="GradientTexture2D" id="GradientTexture2D_fjiih"]
gradient = SubResource("Gradient_6vn6g")
width = 850
height = 500
fill = 2
fill_from = Vector2(0.5, 0.5)
[node name="PrototypeMap" type="Node2D"]
script = ExtResource("1_mj08v")
[node name="Background" type="Sprite2D" parent="."]
position = Vector2(497, 315)
texture = SubResource("GradientTexture2D_fjiih")
[node name="MapPoint" parent="." node_paths=PackedStringArray("connected_map_points") instance=ExtResource("2_mj08v")]
position = Vector2(199, 332)
connected_map_points = [NodePath("../MapPoint2")]
[node name="MapPoint2" parent="." node_paths=PackedStringArray("connected_map_points") instance=ExtResource("2_mj08v")]
position = Vector2(256, 299)
connected_map_points = [NodePath("../MapPoint3"), NodePath("../MapPoint4")]
[node name="MapPoint3" parent="." instance=ExtResource("2_mj08v")]
position = Vector2(315, 278)
[node name="MapPoint4" parent="." instance=ExtResource("2_mj08v")]
position = Vector2(320, 330)

6
prototype_ritual_book.gd Normal file
View file

@ -0,0 +1,6 @@
extends Node2D
signal incantation_completed
func _on_incantation_completed():
incantation_completed.emit()

View file

@ -0,0 +1 @@
uid://dsiaa53vt3y6e

View file

@ -0,0 +1,59 @@
[gd_scene load_steps=8 format=3 uid="uid://qkwh186nbcya"]
[ext_resource type="Script" uid="uid://dak6uc4v3us7w" path="res://incantation.gd" id="1_v6csu"]
[ext_resource type="Script" uid="uid://dsiaa53vt3y6e" path="res://prototype_ritual_book.gd" id="1_yc2mw"]
[ext_resource type="Script" uid="uid://cpscp5a5nxfop" path="res://incantation_text.gd" id="2_5ntyk"]
[sub_resource type="Gradient" id="Gradient_2cqfq"]
offsets = PackedFloat32Array(0.80212, 0.978799, 1)
colors = PackedColorArray(0.74902, 0.647059, 0.541176, 1, 0.43, 0.371807, 0.3096, 1, 0.19, 0.164287, 0.1368, 1)
[sub_resource type="GradientTexture2D" id="GradientTexture2D_yaehf"]
gradient = SubResource("Gradient_2cqfq")
width = 300
height = 400
[sub_resource type="Curve2D" id="Curve2D_5ntyk"]
_data = {
"points": PackedVector2Array(0, 0, 0, 0, 202, 149, -40.482, 1.54217, 40.482, -1.54217, 248, 178, -17.3494, 5.01206, 17.3494, -5.01206, 309, 150, -10.7952, -15.0362, 10.7952, 15.0362, 380, 180, 0, 0, 0, 0, 380, 180, 32.7712, -32.7712, -32.7712, 32.7712, 379, 257, 30.385, 3.70613, -30.385, -3.70613, 305, 219, 0, 0, -49.7351, 23.1326, 255, 252, 27.3736, -12.3374, -27.3736, 12.3374, 198, 230, -28.5302, -24.6748, 28.5302, 24.6748, 202, 319, 0, 0, 0, 0, 377, 318)
}
point_count = 11
[sub_resource type="CircleShape2D" id="CircleShape2D_v6csu"]
radius = 13.8924
[node name="PrototypeRitualBook" type="Node2D"]
script = ExtResource("1_yc2mw")
[node name="Left" type="Sprite2D" parent="."]
position = Vector2(306, 311)
texture = SubResource("GradientTexture2D_yaehf")
[node name="Right" type="Sprite2D" parent="."]
position = Vector2(606, 311)
rotation = 3.14159
texture = SubResource("GradientTexture2D_yaehf")
[node name="Incantation" type="Path2D" parent="."]
position = Vector2(-1, 1)
curve = SubResource("Curve2D_5ntyk")
script = ExtResource("1_v6csu")
[node name="Area2D" type="Area2D" parent="Incantation"]
position = Vector2(202, 149)
rotation = 0.562498
collision_layer = 512
collision_mask = 512
[node name="CollisionShape2D" type="CollisionShape2D" parent="Incantation/Area2D"]
shape = SubResource("CircleShape2D_v6csu")
[node name="IncantationText" type="Control" parent="Incantation"]
layout_mode = 3
anchors_preset = 0
offset_right = 40.0
offset_bottom = 23.0
script = ExtResource("2_5ntyk")
text = "Hallo dies ist ein langer TExt, er könnte auch eine Ritual sein. Wir werden sehen"
[connection signal="completed" from="Incantation" to="." method="_on_incantation_completed"]

2
ritual_book.gd Normal file
View file

@ -0,0 +1,2 @@
class_name RitualBook
extends Node2D

1
ritual_book.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://ctpgjvo5g0sav

View file

@ -23,7 +23,7 @@ func _ready():
func _input(event):
if is_clickable and event is InputEventMouseButton and event.is_pressed():
clicked.emit()
clicked.emit()
func _on_mouse_entered():
is_clickable = true