diff --git a/levels/base_level/base_level.gd b/levels/base_level/base_level.gd index 9588c51..a363fc6 100644 --- a/levels/base_level/base_level.gd +++ b/levels/base_level/base_level.gd @@ -87,6 +87,8 @@ func init(_chap_id: int, _lvl_id: int) -> void: table_cloth.size.x = sep * len(question) + 16 table_cloth.size.y = 48 + table_cloth.get_child(0).size.x = sep * len(question) + 16 + table_cloth.get_child(0).size.y = 48 table_cloth.position.x = WIDTH / 2 - sep * len(question) / 2 - 12 table_cloth.position.y = HEIGHT / 2 - 24 $HUDs.add_child(table_cloth) @@ -139,6 +141,13 @@ func _process(_delta): pass +func stage_clear() -> void: + $SFXs/LevelClear.play() + for card_base: CardBase in $CardBases.get_children(): + card_base.call("start_fade") + $HUDs/TableCloth/GoldenCloth.set_visible(true) + + func _on_card_put() -> void: for block : Block in $Blocks.get_children(): if not block.occupied: @@ -168,7 +177,7 @@ func _on_card_put() -> void: for block: Block in $Blocks.get_children(): block.call("shake") else: - $SFXs/LevelClear.play() + stage_clear() diff --git a/levels/chapter_menu/chapter_menu.tscn b/levels/chapter_menu/chapter_menu.tscn index 17b857c..86aed30 100644 --- a/levels/chapter_menu/chapter_menu.tscn +++ b/levels/chapter_menu/chapter_menu.tscn @@ -1,6 +1,17 @@ -[gd_scene load_steps=2 format=3 uid="uid://d138qs4pakk22"] +[gd_scene load_steps=3 format=3 uid="uid://d138qs4pakk22"] [ext_resource type="Script" path="res://levels/chapter_menu/chapter_menu.gd" id="1_sfx21"] +[ext_resource type="FontFile" uid="uid://1000owdyvwfg" path="res://fonts/unifont-15.1.04.otf" id="2_y2jwf"] [node name="ChapterMenu" type="Node2D"] script = ExtResource("1_sfx21") + +[node name="Label" type="Label" parent="."] +custom_minimum_size = Vector2(480, 1) +offset_top = 8.0 +offset_right = 480.0 +offset_bottom = 31.0 +theme_override_fonts/font = ExtResource("2_y2jwf") +text = "Chapter Select" +horizontal_alignment = 1 +vertical_alignment = 1 diff --git a/levels/chapter_menu/level_menu/level_button/level_button.tscn b/levels/chapter_menu/level_menu/level_button/level_button.tscn index c767ffa..ccd9efc 100644 --- a/levels/chapter_menu/level_menu/level_button/level_button.tscn +++ b/levels/chapter_menu/level_menu/level_button/level_button.tscn @@ -5,8 +5,8 @@ [ext_resource type="PackedScene" uid="uid://cvx7wowcbfo0r" path="res://objects/word/word.tscn" id="3_js2i2"] [node name="StyledButton" instance=ExtResource("1_4bgxw")] -offset_right = 42.0 -offset_bottom = 42.0 +offset_right = 40.0 +offset_bottom = 40.0 script = ExtResource("1_wwqfn") [node name="Word" parent="." index="0" instance=ExtResource("3_js2i2")] diff --git a/levels/chapter_menu/level_menu/level_menu.gd b/levels/chapter_menu/level_menu/level_menu.gd index 6f780bd..fe9bc15 100644 --- a/levels/chapter_menu/level_menu/level_menu.gd +++ b/levels/chapter_menu/level_menu/level_menu.gd @@ -2,6 +2,10 @@ extends Node2D +const CHAP_NAMES = ["=P", "Add", "Multiply", "()", "Equal?"] + + + const LevelButton := preload("res://levels/chapter_menu/level_menu/level_button/level_button.tscn") const BaseLevel := preload("res://levels/base_level/base_level.tscn") @@ -17,6 +21,7 @@ func init(chap_id : int, lvl_num : int) -> void: if lvl_num == -1: lvl_num = len(BaseLevel.instantiate().DATA[chap_id]) + $Title.set_text("Ch." + str(chap_id + 1) + " " + CHAP_NAMES[chap_id]) chapter_id = chap_id for level_id in range(0, lvl_num): diff --git a/levels/chapter_menu/level_menu/level_menu.tscn b/levels/chapter_menu/level_menu/level_menu.tscn index 87dbc22..3470225 100644 --- a/levels/chapter_menu/level_menu/level_menu.tscn +++ b/levels/chapter_menu/level_menu/level_menu.tscn @@ -1,11 +1,21 @@ -[gd_scene load_steps=3 format=3 uid="uid://doirpa1bwbjhr"] +[gd_scene load_steps=4 format=3 uid="uid://doirpa1bwbjhr"] [ext_resource type="Script" path="res://levels/chapter_menu/level_menu/level_menu.gd" id="1_sd65g"] [ext_resource type="PackedScene" uid="uid://bepyyenjtc0p3" path="res://levels/chapter_menu/level_menu/level_button/level_button.tscn" id="2_saprs"] +[ext_resource type="FontFile" uid="uid://1000owdyvwfg" path="res://fonts/unifont-15.1.04.otf" id="3_jlnpm"] [node name="LevelMenu" type="Node2D"] script = ExtResource("1_sd65g") [node name="BackButton" parent="." instance=ExtResource("2_saprs")] +[node name="Title" type="Label" parent="."] +offset_top = 8.0 +offset_right = 480.0 +offset_bottom = 31.0 +theme_override_fonts/font = ExtResource("3_jlnpm") +text = "Title" +horizontal_alignment = 1 +vertical_alignment = 1 + [connection signal="pressed" from="BackButton" to="." method="_on_back_button_pressed"] diff --git a/objects/block/block.gd b/objects/block/block.gd index cf08ae3..a31bb03 100644 --- a/objects/block/block.gd +++ b/objects/block/block.gd @@ -35,6 +35,8 @@ func set_word(e: String) -> void: func set_block_type(value: String) -> void: if value == "GOLDEN": $GoalFrameSprite.set_visible(true) + $GoalFrameSprite.set_texture(load("res://objects/block/goal_frame" + str(int(sqrt(randi_range(1, 16)))) + ".png")) + $PitSprite.set_visible(true) elif value == "PIT": $GoalFrameSprite.set_visible(false) diff --git a/objects/block/block.tscn b/objects/block/block.tscn index 7fb53e0..75f677a 100644 --- a/objects/block/block.tscn +++ b/objects/block/block.tscn @@ -6,7 +6,7 @@ [ext_resource type="Texture2D" uid="uid://cb71r50jw2a3i" path="res://objects/block/goal_frame2.png" id="4_v6rgm"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_3if4e"] -size = Vector2(24, 24) +size = Vector2(16, 16) [node name="Block" type="Area2D"] script = ExtResource("1_11h57") @@ -14,8 +14,9 @@ script = ExtResource("1_11h57") [node name="Word" parent="." instance=ExtResource("2_pjs40")] [node name="CollisionShape2D" type="CollisionShape2D" parent="."] -z_index = 2 +z_index = 50 shape = SubResource("RectangleShape2D_3if4e") +debug_color = Color(0.968627, 0, 0.470588, 0.419608) [node name="PitSprite" type="Sprite2D" parent="."] z_index = -1 diff --git a/objects/calculator/calculator.gd b/objects/calculator/calculator.gd index 9070153..313d67c 100644 --- a/objects/calculator/calculator.gd +++ b/objects/calculator/calculator.gd @@ -31,10 +31,20 @@ val: Q/0/1 Q 1 1 1 1 1 """ +""" +左/右 * < ( ) Q +* / / 0 / 0 +< / 0 0 / 0 +( / / 0 / 0 +) 0 0 1 0 1 +Q 0 0 1 0 1 +""" + const IS_PAIR_VALID := [[0, 0, 1, 0, 1], [0, 1, 1, 0, 1], [0, 0, 1, 0, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]] enum {OP, COMP, BRAC_L, BRAC_R, VAL} + func get_char_type(ch: String) -> int: if ch == "*" or ch == "+": return OP @@ -47,6 +57,9 @@ func get_char_type(ch: String) -> int: else: return VAL +func has_implict_prod(string: String) -> bool: + return get_char_type(string[0]) in [BRAC_R, VAL] and get_char_type(string[1]) in [BRAC_L, VAL] + func get_priority(ch: String) -> int: if ch == "*": return 4 @@ -66,8 +79,18 @@ func get_priority(ch: String) -> int: func infix_to_suffix(expr: String) -> String: var opt_stack: Array = [] var res := "" + var pre_ch := "@" for ch in expr: + if pre_ch != "@" and has_implict_prod(pre_ch + ch): + if not opt_stack.is_empty() and (get_char_type("*") != COMP or get_char_type(opt_stack.back()) != COMP): + while not opt_stack.is_empty() and get_priority("*") <= get_priority(opt_stack.back()): + res += opt_stack.back() + opt_stack.pop_back() + opt_stack.push_back("*") + + + print("ch=", ch, " stk=", opt_stack, " res=", res) if get_char_type(ch) == VAL: res += ch @@ -84,6 +107,7 @@ func infix_to_suffix(expr: String) -> String: res += opt_stack.back() opt_stack.pop_back() opt_stack.push_back(ch) + pre_ch = ch while not opt_stack.is_empty(): res += opt_stack.back() @@ -184,6 +208,7 @@ func check_always_true(expr: String) -> Dictionary: # 中缀转后缀 expr = infix_to_suffix(expr) + print(expr) for ch in expr: if is_alpha(ch) and not var_names.has(ch): @@ -229,7 +254,8 @@ func check(expr: String, req_pos: Array) -> Array: func _ready(): - assert(check("(1=P)+(0=P)", []) == ["OK", 200], "9") + check("q*Pq*bd*b=D", []) + #assert(check("(1=P)+(0=P)", []) == ["OK", 200], "9") #assert(check("Q+P=P+Q", [3, 4]) == ["OK", 200], "1") #assert(check("Q+P=P+Q", [4]) == ["OK", 200], "2") #assert(check("P+Q=Q+P", [3, 4]) == ["SMILE_UNSATISFIED", 3], "3") diff --git a/objects/card/card.tscn b/objects/card/card.tscn index 2e5e758..664f49a 100644 --- a/objects/card/card.tscn +++ b/objects/card/card.tscn @@ -1,13 +1,13 @@ -[gd_scene load_steps=8 format=3 uid="uid://b223s12rqgt4h"] +[gd_scene load_steps=9 format=3 uid="uid://b223s12rqgt4h"] [ext_resource type="Script" path="res://objects/card/card.gd" id="1_0bviv"] [ext_resource type="PackedScene" uid="uid://cvx7wowcbfo0r" path="res://objects/word/word.tscn" id="1_ns36n"] [ext_resource type="Texture2D" uid="uid://cfbqh1k0etr6g" path="res://objects/card/card1.png" id="3_o4f0v"] [ext_resource type="Texture2D" uid="uid://c8qjbksyn1bqt" path="res://objects/card/card2.png" id="4_c30j1"] [ext_resource type="Texture2D" uid="uid://bevrfq1hhyqwe" path="res://objects/card/card3.png" id="5_w81n3"] +[ext_resource type="Texture2D" uid="uid://cmcc5xrpkrd0f" path="res://objects/card/card_highlighted.png" id="6_po2i6"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_gu6l6"] -size = Vector2(14, 14) [sub_resource type="SpriteFrames" id="SpriteFrames_fo0r0"] animations = [{ @@ -24,6 +24,14 @@ animations = [{ "loop": true, "name": &"default", "speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": ExtResource("6_po2i6") +}], +"loop": true, +"name": &"highlighted", +"speed": 5.0 }] [node name="Card" type="Area2D"] @@ -40,5 +48,5 @@ shape = SubResource("RectangleShape2D_gu6l6") [node name="CardBackSprite" type="AnimatedSprite2D" parent="."] sprite_frames = SubResource("SpriteFrames_fo0r0") +animation = &"highlighted" autoplay = "default" -frame_progress = 0.275098 diff --git a/objects/card_base/card_base.gd b/objects/card_base/card_base.gd index ed3b257..cfd3e65 100644 --- a/objects/card_base/card_base.gd +++ b/objects/card_base/card_base.gd @@ -3,9 +3,14 @@ extends Area2D class_name CardBase const Card := preload("res://objects/card/card.tscn") +const FADE_MOVE_AMOUNT := 70 signal card_put + +var fade_flag := false + + var card_count = 0 var new_card_node: Card @@ -30,7 +35,7 @@ func set_card_count(value): func draw_card(): if card_count <= 0: return - set_card_count(card_count - 1) + set_card_count(card_count - 1) $SFXPickUp.play() new_card_node = Card.instantiate() new_card_node.set_word($Word.get_word()) @@ -70,3 +75,19 @@ func set_word(e: String) -> void: func _on_card_put(): emit_signal("card_put") + + + + +func start_fade() -> void: + fade_flag = true + $FadeTimer.start() + $CollisionShape2D.set_deferred("disabled", true) + $Label.set_visible(false) + +func _process(delta) -> void: + if fade_flag: + var offset = $FadeTimer.time_left / $FadeTimer.wait_time + offset = (1 - pow(offset, 1.5)) * FADE_MOVE_AMOUNT + $AnimatedSprite2D.position.y = offset + $Word.position.y = offset diff --git a/objects/card_base/card_base.tscn b/objects/card_base/card_base.tscn index 16c731a..3189131 100644 --- a/objects/card_base/card_base.tscn +++ b/objects/card_base/card_base.tscn @@ -67,5 +67,9 @@ sprite_frames = SubResource("SpriteFrames_bhb3x") stream = ExtResource("7_0c7kt") volume_db = 8.54 +[node name="FadeTimer" type="Timer" parent="."] +wait_time = 0.2 +one_shot = true + [connection signal="area_entered" from="." to="." method="_on_area_entered"] [connection signal="area_exited" from="." to="." method="_on_area_exited"] diff --git a/objects/main_menu/main_menu.gd b/objects/main_menu/main_menu.gd index 48b9e54..de15151 100644 --- a/objects/main_menu/main_menu.gd +++ b/objects/main_menu/main_menu.gd @@ -4,7 +4,7 @@ var ChapterMenu = preload("res://levels/chapter_menu/chapter_menu.tscn") # Called when the node enters the scene tree for the first time. func _ready(): - play() + play("init") pass # Replace with function body. diff --git a/objects/main_menu/main_menu.tscn b/objects/main_menu/main_menu.tscn index a330172..16c9a9a 100644 --- a/objects/main_menu/main_menu.tscn +++ b/objects/main_menu/main_menu.tscn @@ -52,9 +52,12 @@ animations = [{ }, { "duration": 1.0, "texture": ExtResource("10_6ukle") +}, { +"duration": 1.0, +"texture": ExtResource("11_j1jkd") }], "loop": false, -"name": &"default", +"name": &"init", "speed": 5.0 }, { "frames": [{ @@ -71,7 +74,7 @@ animations = [{ "texture": ExtResource("11_j1jkd") }], "loop": true, -"name": &"new_animation", +"name": &"wait_for_start", "speed": 5.0 }] @@ -110,6 +113,7 @@ animations = [{ [node name="MainMenu" type="AnimatedSprite2D"] scale = Vector2(2.5, 2.5) sprite_frames = SubResource("SpriteFrames_b4517") +animation = &"init" centered = false script = ExtResource("14_npy3s") diff --git a/objects/styled_button/styled_button.tscn b/objects/styled_button/styled_button.tscn index 2dba0db..8236470 100644 --- a/objects/styled_button/styled_button.tscn +++ b/objects/styled_button/styled_button.tscn @@ -1,28 +1,24 @@ -[gd_scene load_steps=9 format=3 uid="uid://drl1xe103umpi"] +[gd_scene load_steps=6 format=3 uid="uid://drl1xe103umpi"] -[ext_resource type="Texture2D" uid="uid://b5d2rfms7vyfi" path="res://objects/card_base/card_base1.png" id="1_rsfr7"] -[ext_resource type="Texture2D" uid="uid://cs7vfmsrhpomj" path="res://objects/card_base/card_base_highlighted.png" id="2_hwjbt"] -[ext_resource type="Texture2D" uid="uid://bkjbrw1ppac5q" path="res://objects/card_base/card_base_disabled.png" id="3_eoagx"] +[ext_resource type="Texture2D" uid="uid://cfbqh1k0etr6g" path="res://objects/card/card1.png" id="1_l6dpy"] +[ext_resource type="Texture2D" uid="uid://cmcc5xrpkrd0f" path="res://objects/card/card_highlighted.png" id="2_j1sqk"] -[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_0r0ru"] -texture = ExtResource("1_rsfr7") +[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_c0uot"] +texture = ExtResource("1_l6dpy") -[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_mqko3"] -texture = ExtResource("2_hwjbt") - -[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_0m6th"] -texture = ExtResource("3_eoagx") - -[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_5rbv7"] -texture = ExtResource("3_eoagx") +[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_eifmj"] +texture = ExtResource("2_j1sqk") +texture_margin_left = 4.0 +texture_margin_top = 4.0 +texture_margin_right = 4.0 +texture_margin_bottom = 4.0 [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_tfhr0"] [node name="StyledButton" type="Button"] offset_right = 100.0 offset_bottom = 100.0 -theme_override_styles/normal = SubResource("StyleBoxTexture_0r0ru") -theme_override_styles/hover = SubResource("StyleBoxTexture_mqko3") -theme_override_styles/pressed = SubResource("StyleBoxTexture_0m6th") -theme_override_styles/disabled = SubResource("StyleBoxTexture_5rbv7") +theme_override_styles/normal = SubResource("StyleBoxTexture_c0uot") +theme_override_styles/hover = SubResource("StyleBoxTexture_eifmj") +theme_override_styles/pressed = SubResource("StyleBoxTexture_eifmj") theme_override_styles/focus = SubResource("StyleBoxEmpty_tfhr0") diff --git a/objects/table_cloth/golden_cloth.png b/objects/table_cloth/golden_cloth.png new file mode 100644 index 0000000..46bfc19 Binary files /dev/null and b/objects/table_cloth/golden_cloth.png differ diff --git a/objects/table_cloth/golden_cloth.png.import b/objects/table_cloth/golden_cloth.png.import new file mode 100644 index 0000000..d1847c2 --- /dev/null +++ b/objects/table_cloth/golden_cloth.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cb5gytqlvjj2v" +path="res://.godot/imported/golden_cloth.png-d3073ab0f7dc2414ed963703c673bad9.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://objects/table_cloth/golden_cloth.png" +dest_files=["res://.godot/imported/golden_cloth.png-d3073ab0f7dc2414ed963703c673bad9.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/objects/table_cloth/table_cloth.tscn b/objects/table_cloth/table_cloth.tscn index ccfe6ae..7c0f2ee 100644 --- a/objects/table_cloth/table_cloth.tscn +++ b/objects/table_cloth/table_cloth.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=3 format=3 uid="uid://7kd53bu4qorc"] +[gd_scene load_steps=5 format=3 uid="uid://7kd53bu4qorc"] [ext_resource type="Texture2D" uid="uid://1gcwvbyjejey" path="res://objects/table_cloth/table_cloth.png" id="1_8qui1"] +[ext_resource type="Texture2D" uid="uid://cb5gytqlvjj2v" path="res://objects/table_cloth/golden_cloth.png" id="2_3edv5"] [sub_resource type="StyleBoxTexture" id="StyleBoxTexture_js8qc"] texture = ExtResource("1_8qui1") @@ -9,9 +10,24 @@ texture_margin_top = 16.0 texture_margin_right = 16.0 texture_margin_bottom = 16.0 +[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_7iyxp"] +texture = ExtResource("2_3edv5") +texture_margin_left = 16.0 +texture_margin_top = 16.0 +texture_margin_right = 16.0 +texture_margin_bottom = 16.0 + [node name="TableCloth" type="Panel"] z_index = -10 offset_right = 109.0 offset_bottom = 40.0 mouse_filter = 2 theme_override_styles/panel = SubResource("StyleBoxTexture_js8qc") + +[node name="GoldenCloth" type="Panel" parent="."] +visible = false +layout_mode = 0 +offset_right = 109.0 +offset_bottom = 40.0 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBoxTexture_7iyxp")