Skip to content

Commit

Permalink
Merge pull request #25 from ligen131/dev-cutekibry
Browse files Browse the repository at this point in the history
Dev cutekibry
  • Loading branch information
ligen131 authored Jan 27, 2024
2 parents 421685c + ecfb122 commit 45eb5a4
Show file tree
Hide file tree
Showing 17 changed files with 163 additions and 21 deletions.
14 changes: 12 additions & 2 deletions levels/base_level/base_level.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const Block := preload("res://objects/block/block.tscn")
const CardBase := preload("res://objects/card_base/card_base.tscn")
const LevelMenu := preload("res://levels/chapter_menu/level_menu/level_menu.tscn")
const TableCloth := preload("res://objects/table_cloth/table_cloth.tscn")
const BaseLevel := preload("res://levels/base_level/base_level.tscn")
const HEIGHT := 1080 / 4
const WIDTH := 1920 / 4
const SEP := 28
Expand Down Expand Up @@ -148,7 +149,7 @@ func stage_clear() -> void:
card_base.call("set_victory")

$HUDs/TableCloth/GoldenCloth.set_visible(true)

$HUDs/NextLevelButton.start_fade()


func _on_card_put() -> void:
Expand Down Expand Up @@ -196,7 +197,16 @@ func _on_back_button_pressed():
get_tree().root.add_child(level_menu)
queue_free()


func _on_next_level_button_pressed():
var base_level := BaseLevel.instantiate()

if lvl_id == len(DATA[chap_id]) - 1:
base_level.init(chap_id + 1, 0)
else:
base_level.init(chap_id, lvl_id + 1)
get_tree().root.add_child(base_level)
queue_free()

func _on_replay_button_pressed():
for card_base: CardBase in $CardBases.get_children():
card_base.reset_all_card_position()
5 changes: 5 additions & 0 deletions levels/base_level/base_level.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[ext_resource type="Script" path="res://levels/base_level/base_level.gd" id="1_diojb"]
[ext_resource type="PackedScene" uid="uid://xom5kpqs1rue" path="res://objects/calculator/calculator.tscn" id="1_tpuy7"]
[ext_resource type="PackedScene" uid="uid://bepyyenjtc0p3" path="res://levels/chapter_menu/level_menu/level_button/level_button.tscn" id="2_0egdl"]
[ext_resource type="PackedScene" uid="uid://d1mp3ld6wsrwo" path="res://levels/base_level/next_level_button/next_level_button.tscn" id="2_0363i"]
[ext_resource type="Texture2D" uid="uid://bxda1ilvqwc6f" path="res://objects/styled_button/return1.png" id="3_4xtpo"]
[ext_resource type="AudioStream" uid="uid://cjhl2qr4mau8g" path="res://levels/base_level/level_clear.wav" id="3_ou3kh"]
[ext_resource type="FontFile" uid="uid://1000owdyvwfg" path="res://fonts/unifont-15.1.04.otf" id="3_q0kqv"]
Expand Down Expand Up @@ -52,6 +53,8 @@ script = ExtResource("1_diojb")

[node name="HUDs" type="Node" parent="."]

[node name="NextLevelButton" parent="HUDs" instance=ExtResource("2_0363i")]

[node name="BackButton" parent="HUDs" instance=ExtResource("2_0egdl")]

[node name="icon" type="AnimatedSprite2D" parent="HUDs/BackButton"]
Expand Down Expand Up @@ -91,10 +94,12 @@ centered = false

[node name="LevelClear" type="AudioStreamPlayer2D" parent="SFXs"]
stream = ExtResource("3_ou3kh")
volume_db = -26.29

[node name="WrongAnswer" type="AudioStreamPlayer2D" parent="SFXs"]
stream = ExtResource("4_yxsxp")
volume_db = 1.0

[connection signal="pressed" from="HUDs/NextLevelButton" to="." method="_on_next_level_button_pressed"]
[connection signal="pressed" from="HUDs/BackButton" to="." method="_on_back_button_pressed"]
[connection signal="pressed" from="HUDs/ReplayButton" to="." method="_on_replay_button_pressed"]
22 changes: 22 additions & 0 deletions levels/base_level/next_level_button/next_level_button.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
extends Button


const WIDTH := 1920 / 4
const HEIGHT := 1080 / 4


var fade_flag := false


func start_fade():
fade_flag = true
$FadeTimer.start()

func _ready():
position = Vector2(WIDTH / 2 - 20, HEIGHT + 80)
$Word.set_word(">")

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if fade_flag:
position.y = HEIGHT + 50 - 120 * (1 - pow($FadeTimer.time_left / $FadeTimer.wait_time, 1.5))
11 changes: 11 additions & 0 deletions levels/base_level/next_level_button/next_level_button.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[gd_scene load_steps=3 format=3 uid="uid://d1mp3ld6wsrwo"]

[ext_resource type="PackedScene" uid="uid://bepyyenjtc0p3" path="res://levels/chapter_menu/level_menu/level_button/level_button.tscn" id="1_sa21d"]
[ext_resource type="Script" path="res://levels/base_level/next_level_button/next_level_button.gd" id="2_yogj1"]

[node name="NextLevelButton" instance=ExtResource("1_sa21d")]
script = ExtResource("2_yogj1")

[node name="FadeTimer" type="Timer" parent="." index="2"]
wait_time = 0.3
one_shot = true
6 changes: 4 additions & 2 deletions levels/chapter_menu/level_menu/level_button/level_button.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends Button
extends StyledButton

signal enter_level(chapter_id:int, level_id : int)

Expand Down Expand Up @@ -36,7 +36,9 @@ func init(chapter_id: int, level_id : int, pos : Vector2, type : int) -> void :
button_type = type

func _on_pressed():
# print("choose: ",chap_id,"-",lvl_id)
print("choose: ",chap_id,"-",lvl_id)
print("! ")
$SFXButtonDown.play()
if button_type == 1:
enter_level.emit(chap_id, lvl_id)
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
[ext_resource type="Script" path="res://levels/chapter_menu/level_menu/level_button/level_button.gd" id="1_wwqfn"]
[ext_resource type="PackedScene" uid="uid://cvx7wowcbfo0r" path="res://objects/word/word.tscn" id="3_js2i2"]

[node name="StyledButton" instance=ExtResource("1_4bgxw")]
[node name="LevelButton" instance=ExtResource("1_4bgxw")]
offset_right = 40.0
offset_bottom = 40.0
script = ExtResource("1_wwqfn")

[node name="Word" parent="." index="0" instance=ExtResource("3_js2i2")]
position = Vector2(19, 19)
scale = Vector2(1.5, 1.5)

[connection signal="pressed" from="." to="." method="_on_pressed"]
2 changes: 0 additions & 2 deletions objects/block/block.gd
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ 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)
Expand Down
10 changes: 10 additions & 0 deletions objects/card/card.gd
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func _on_mouse_release():
last_occupied_area = entered_area
entered_area.occupied_word = $Word.get_word()
emit_signal("put")
$SFXPutDown.play()
# prints("card", $Word.get_word(), "put at", entered_area.name, "at global_position", global_position, "when origin global_position at", origin_global_position)
else:
global_position = last_global_position
Expand Down Expand Up @@ -108,3 +109,12 @@ func set_word(e: String) -> void:

func get_word() -> String:
return $Word.get_word()




func _on_mouse_entered():
$CardBackSprite.animation = "highlighted"

func _on_mouse_exited():
$CardBackSprite.animation = "default"
11 changes: 9 additions & 2 deletions objects/card/card.tscn
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[gd_scene load_steps=9 format=3 uid="uid://b223s12rqgt4h"]
[gd_scene load_steps=10 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"]
[ext_resource type="AudioStream" uid="uid://cj4v8ehypq3sk" path="res://objects/card/put_down.wav" id="7_u4ylf"]

[sub_resource type="RectangleShape2D" id="RectangleShape2D_gu6l6"]

Expand Down Expand Up @@ -48,5 +49,11 @@ shape = SubResource("RectangleShape2D_gu6l6")

[node name="CardBackSprite" type="AnimatedSprite2D" parent="."]
sprite_frames = SubResource("SpriteFrames_fo0r0")
animation = &"highlighted"
autoplay = "default"

[node name="SFXPutDown" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("7_u4ylf")
volume_db = 6.558

[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]
Binary file added objects/card/put_down.wav
Binary file not shown.
24 changes: 24 additions & 0 deletions objects/card/put_down.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[remap]

importer="wav"
type="AudioStreamWAV"
uid="uid://cj4v8ehypq3sk"
path="res://.godot/imported/put_down.wav-4b821ef15f26d3e3b29c28f8d2015b38.sample"

[deps]

source_file="res://objects/card/put_down.wav"
dest_files=["res://.godot/imported/put_down.wav-4b821ef15f26d3e3b29c28f8d2015b38.sample"]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
24 changes: 18 additions & 6 deletions objects/card_base/card_base.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ signal card_put


var fade_flag := false
var mouse_on := false


var card_count = 0
Expand All @@ -22,12 +23,12 @@ func _ready():

func set_card_count(value):
card_count = value
if card_count == 2:
$AnimatedSprite2D.animation = "default"
elif card_count == 1:
# TODO: 更改 texture
$AnimatedSprite2D.animation = "default"
elif card_count == 0:
if card_count > 0:
if mouse_on:
$AnimatedSprite2D.animation = "highlighted"
else:
$AnimatedSprite2D.animation = "default"
else:
$AnimatedSprite2D.animation = "disabled"
update_card_count_label()

Expand Down Expand Up @@ -95,3 +96,14 @@ func _process(delta) -> void:
offset = (1 - pow(offset, 1.5)) * FADE_MOVE_AMOUNT
$AnimatedSprite2D.position.y = offset
$Word.position.y = offset


func _on_mouse_entered():
mouse_on = true
if $AnimatedSprite2D.animation == "default":
$AnimatedSprite2D.animation = "highlighted"

func _on_mouse_exited():
mouse_on = false
if $AnimatedSprite2D.animation == "highlighted":
$AnimatedSprite2D.animation = "default"
9 changes: 6 additions & 3 deletions objects/card_base/card_base.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ animations = [{
[node name="CardBase" type="Area2D"]
script = ExtResource("1_k5qn1")

[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_2cmwb")
debug_color = Color(0.65098, 0.431373, 0.756863, 0.419608)

[node name="Word" parent="." instance=ExtResource("2_jvsp3")]
z_index = 1
frame_progress = 0.953211
Expand All @@ -55,9 +59,6 @@ text = "0"
horizontal_alignment = 1
vertical_alignment = 1

[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_2cmwb")

[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
sprite_frames = SubResource("SpriteFrames_bhb3x")

Expand All @@ -73,3 +74,5 @@ one_shot = true

[connection signal="area_entered" from="." to="." method="_on_area_entered"]
[connection signal="area_exited" from="." to="." method="_on_area_exited"]
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]
Binary file added objects/styled_button/button_down.wav
Binary file not shown.
24 changes: 24 additions & 0 deletions objects/styled_button/button_down.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[remap]

importer="wav"
type="AudioStreamWAV"
uid="uid://dpwscp4bw7pay"
path="res://.godot/imported/button_down.wav-577d8f023953f645606364b1089d1ba6.sample"

[deps]

source_file="res://objects/styled_button/button_down.wav"
dest_files=["res://.godot/imported/button_down.wav-577d8f023953f645606364b1089d1ba6.sample"]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
7 changes: 7 additions & 0 deletions objects/styled_button/styled_button.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extends Button

class_name StyledButton


func _on_pressed():
$SFXButtonDown.play()
11 changes: 10 additions & 1 deletion objects/styled_button/styled_button.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[gd_scene load_steps=6 format=3 uid="uid://drl1xe103umpi"]
[gd_scene load_steps=8 format=3 uid="uid://drl1xe103umpi"]

[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"]
[ext_resource type="Script" path="res://objects/styled_button/styled_button.gd" id="3_rtcig"]
[ext_resource type="AudioStream" uid="uid://dpwscp4bw7pay" path="res://objects/styled_button/button_down.wav" id="4_no3m1"]

[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_c0uot"]
texture = ExtResource("1_l6dpy")
Expand All @@ -22,3 +24,10 @@ 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")
script = ExtResource("3_rtcig")

[node name="SFXButtonDown" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("4_no3m1")
volume_db = 10.306

[connection signal="pressed" from="." to="." method="_on_pressed"]

0 comments on commit 45eb5a4

Please sign in to comment.