Skip to content

Commit

Permalink
Merge branch 'main' of github.com:ligen131/ggj2024-game
Browse files Browse the repository at this point in the history
  • Loading branch information
cutekibry committed Jan 27, 2024
2 parents a2cb1c1 + 4d16180 commit 421685c
Show file tree
Hide file tree
Showing 33 changed files with 258 additions and 45 deletions.
19 changes: 16 additions & 3 deletions levels/base_level/base_level.gd
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ func init(_chap_id: int, _lvl_id: int) -> void:


func _ready():
$HUDs/BackButton.set_word("<")
$HUDs/BackButton/icon.play("return")
$HUDs/ReplayButton/icon.play("replay")

func _process(_delta):
pass
Expand All @@ -144,7 +145,8 @@ func _process(_delta):
func stage_clear() -> void:
$SFXs/LevelClear.play()
for card_base: CardBase in $CardBases.get_children():
card_base.call("start_fade")
card_base.call("set_victory")

$HUDs/TableCloth/GoldenCloth.set_visible(true)


Expand Down Expand Up @@ -179,11 +181,22 @@ func _on_card_put() -> void:
block.call("shake")
else:
stage_clear()


func _input(event: InputEvent):
if event is InputEventKey:
if event.keycode == KEY_R and event.pressed:
_on_replay_button_pressed()
if event.keycode == KEY_ESCAPE and event.pressed:
_on_back_button_pressed()


func _on_back_button_pressed():
var level_menu = LevelMenu.instantiate()
level_menu.init(chap_id, -1)
get_tree().root.add_child(level_menu)
queue_free()


func _on_replay_button_pressed():
for card_base: CardBase in $CardBases.get_children():
card_base.reset_all_card_position()
59 changes: 58 additions & 1 deletion levels/base_level/base_level.tscn
Original file line number Diff line number Diff line change
@@ -1,11 +1,51 @@
[gd_scene load_steps=7 format=3 uid="uid://cother2aiigge"]
[gd_scene load_steps=15 format=3 uid="uid://cother2aiigge"]

[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="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"]
[ext_resource type="Texture2D" uid="uid://cyl7cqhs4xnux" path="res://objects/styled_button/return2.png" id="4_sctgt"]
[ext_resource type="AudioStream" uid="uid://c6rflw11edxrt" path="res://levels/base_level/wrong_answer.wav" id="4_yxsxp"]
[ext_resource type="Texture2D" uid="uid://b48fn2ikxq33d" path="res://objects/styled_button/return3.png" id="5_u8ht0"]
[ext_resource type="Texture2D" uid="uid://cuyseoi8y3567" path="res://objects/styled_button/replay1.png" id="7_xfna7"]
[ext_resource type="Texture2D" uid="uid://dhjiokm51casd" path="res://objects/styled_button/replay2.png" id="8_60asn"]
[ext_resource type="Texture2D" uid="uid://btyxqeveaeh6h" path="res://objects/styled_button/replay3.png" id="9_gpaci"]

[sub_resource type="SpriteFrames" id="SpriteFrames_yulkh"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("3_4xtpo")
}, {
"duration": 1.0,
"texture": ExtResource("4_sctgt")
}, {
"duration": 1.0,
"texture": ExtResource("5_u8ht0")
}],
"loop": true,
"name": &"return",
"speed": 5.0
}]

[sub_resource type="SpriteFrames" id="SpriteFrames_5hm0m"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("7_xfna7")
}, {
"duration": 1.0,
"texture": ExtResource("8_60asn")
}, {
"duration": 1.0,
"texture": ExtResource("9_gpaci")
}],
"loop": true,
"name": &"replay",
"speed": 5.0
}]

[node name="BaseLevel" type="Node"]
script = ExtResource("1_diojb")
Expand All @@ -14,6 +54,12 @@ script = ExtResource("1_diojb")

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

[node name="icon" type="AnimatedSprite2D" parent="HUDs/BackButton"]
position = Vector2(8, 8)
sprite_frames = SubResource("SpriteFrames_yulkh")
animation = &"return"
centered = false

[node name="Title" type="Label" parent="HUDs"]
offset_top = 8.0
offset_right = 480.0
Expand All @@ -23,6 +69,16 @@ text = "Title"
horizontal_alignment = 1
vertical_alignment = 1

[node name="ReplayButton" parent="HUDs" instance=ExtResource("2_0egdl")]
offset_left = 440.0
offset_right = 480.0

[node name="icon" type="AnimatedSprite2D" parent="HUDs/ReplayButton"]
position = Vector2(6, 6)
sprite_frames = SubResource("SpriteFrames_5hm0m")
animation = &"replay"
centered = false

[node name="Calculator" parent="." instance=ExtResource("1_tpuy7")]

[node name="Cards" type="Node" parent="."]
Expand All @@ -41,3 +97,4 @@ stream = ExtResource("4_yxsxp")
volume_db = 1.0

[connection signal="pressed" from="HUDs/BackButton" to="." method="_on_back_button_pressed"]
[connection signal="pressed" from="HUDs/ReplayButton" to="." method="_on_replay_button_pressed"]
1 change: 0 additions & 1 deletion levels/chapter_menu/chapter_menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const button_width : int = 50
const button_heigth : int = 50

func init() -> void:
print("1")
var chap_num : int = len(BaseLevel.instantiate().DATA)
for chapter_id in range(0, chap_num):
# print(chapter_id)
Expand Down
7 changes: 6 additions & 1 deletion levels/chapter_menu/level_menu/level_menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,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
Expand All @@ -34,6 +34,7 @@ func init(chap_id : int, lvl_num : int) -> void:
add_child(button)

func _ready():
$BackButton/icon.play("return")
#print(BaseLevel.instantiate().DATA[chapter_id])
#var level_num : int = len(BaseLevel.instantiate().DATA[chapter_id])
#print(level_num)
Expand All @@ -53,6 +54,10 @@ func _on_button_enter_level(chap_id: int, lvl_id: int) -> void:
get_tree().root.add_child(base_level)
queue_free()

func _input(event: InputEvent):
if event is InputEventKey:
if event.keycode == KEY_ESCAPE and event.pressed:
_on_back_button_pressed()

func _on_back_button_pressed():
var ChapterMenu = load("res://levels/chapter_menu/chapter_menu.tscn")
Expand Down
28 changes: 27 additions & 1 deletion levels/chapter_menu/level_menu/level_menu.tscn
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
[gd_scene load_steps=4 format=3 uid="uid://doirpa1bwbjhr"]
[gd_scene load_steps=8 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="Texture2D" uid="uid://bxda1ilvqwc6f" path="res://objects/styled_button/return1.png" id="3_6x831"]
[ext_resource type="FontFile" uid="uid://1000owdyvwfg" path="res://fonts/unifont-15.1.04.otf" id="3_jlnpm"]
[ext_resource type="Texture2D" uid="uid://cyl7cqhs4xnux" path="res://objects/styled_button/return2.png" id="4_wd0qw"]
[ext_resource type="Texture2D" uid="uid://b48fn2ikxq33d" path="res://objects/styled_button/return3.png" id="5_eexmd"]

[sub_resource type="SpriteFrames" id="SpriteFrames_waq31"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("3_6x831")
}, {
"duration": 1.0,
"texture": ExtResource("4_wd0qw")
}, {
"duration": 1.0,
"texture": ExtResource("5_eexmd")
}],
"loop": true,
"name": &"return",
"speed": 5.0
}]

[node name="LevelMenu" type="Node2D"]
script = ExtResource("1_sd65g")

[node name="BackButton" parent="." instance=ExtResource("2_saprs")]

[node name="icon" type="AnimatedSprite2D" parent="BackButton"]
position = Vector2(8, 8)
sprite_frames = SubResource("SpriteFrames_waq31")
animation = &"return"
centered = false

[node name="Title" type="Label" parent="."]
offset_top = 8.0
offset_right = 480.0
Expand Down
10 changes: 9 additions & 1 deletion objects/card/card.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ signal put
signal back_to_origin_global_position

var is_dragging = false
var have_deal_on_mouse_release = true
var origin_global_position: Vector2
var last_global_position: Vector2
var is_card_entered = 0
Expand All @@ -15,12 +16,15 @@ var last_occupied_area: Block
var is_card_base_entered = 0
var entered_card_base_global_position: Vector2

var is_victory = false

func _ready():
origin_global_position = global_position
last_global_position = global_position

func _on_mouse_release():
#prints(entered_area.name, is_card_entered, entered_area.occupied)
have_deal_on_mouse_release = true
if is_card_entered > 0 and entered_area and not entered_area.occupied:
global_position = entered_area.global_position
last_global_position = global_position
Expand Down Expand Up @@ -56,6 +60,7 @@ func reset_position():
last_occupied_area = null

func _on_mouse_pressed():
have_deal_on_mouse_release = false
last_global_position = global_position
is_dragging = true
is_card_entered = 0
Expand All @@ -64,7 +69,7 @@ func _on_mouse_pressed():

func _input_event(viewport: Object, event: InputEvent, shape_idx: int) -> void:
#prints(self, event)
if event is InputEventMouseButton:
if not is_victory and event is InputEventMouseButton:
if event.is_pressed() and event.button_index == MOUSE_BUTTON_LEFT:
_on_mouse_pressed()
elif not event.is_pressed() and is_dragging:
Expand All @@ -75,7 +80,10 @@ func _input_event(viewport: Object, event: InputEvent, shape_idx: int) -> void:

func _process(delta: float) -> void:
#prints(name, global_position)
if not have_deal_on_mouse_release and not Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
_on_mouse_release()
if is_dragging:
have_deal_on_mouse_release = false
global_position = get_global_mouse_position()

func on_card_entered(area: Block) -> void:
Expand Down
14 changes: 9 additions & 5 deletions objects/card_base/card_base.gd
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,19 @@ func set_word(e: String) -> void:
func _on_card_put():
emit_signal("card_put")





func start_fade() -> void:
func set_victory() -> void:
# start_fade
fade_flag = true
$FadeTimer.start()
$CollisionShape2D.set_deferred("disabled", true)
$Label.set_visible(false)

for card: Card in $Cards.get_children():
card.is_victory = true

func reset_all_card_position():
for card: Card in $Cards.get_children():
card.reset_position()

func _process(delta) -> void:
if fade_flag:
Expand Down
3 changes: 1 addition & 2 deletions objects/main_menu/main_menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +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():
$start_button/AnimatedSprite2D.play()
play("init")
pass # Replace with function body.

Expand All @@ -12,8 +13,6 @@ func _ready():
func _process(delta):
pass



func _on_animation_finished():
play("wait_for_start")

Expand Down
6 changes: 3 additions & 3 deletions objects/main_menu/main_menu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
[ext_resource type="Texture2D" uid="uid://bqm3lgo8c8nfb" path="res://objects/main_menu/background/main_menu14.png" id="14_tufeb"]
[ext_resource type="Texture2D" uid="uid://bw8xulwxqnhbc" path="res://objects/main_menu/background/main_menu15.png" id="15_qjtad"]
[ext_resource type="Texture2D" uid="uid://cmcc5xrpkrd0f" path="res://objects/card/card_highlighted.png" id="16_5m8f1"]
[ext_resource type="Texture2D" uid="uid://83p3glm3htsp" path="res://objects/word/sprites/start1.png" id="16_skwdr"]
[ext_resource type="Texture2D" uid="uid://64ivn20qcjoy" path="res://objects/word/sprites/start2.png" id="17_mrqss"]
[ext_resource type="Texture2D" uid="uid://cbwkjh7uudgr5" path="res://objects/word/sprites/start3.png" id="18_qh4cp"]
[ext_resource type="Texture2D" uid="uid://83p3glm3htsp" path="res://objects/styled_button/start1.png" id="16_skwdr"]
[ext_resource type="Texture2D" uid="uid://64ivn20qcjoy" path="res://objects/styled_button/start2.png" id="17_mrqss"]
[ext_resource type="Texture2D" uid="uid://cbwkjh7uudgr5" path="res://objects/styled_button/start3.png" id="18_qh4cp"]

[sub_resource type="SpriteFrames" id="SpriteFrames_b4517"]
animations = [{
Expand Down
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://7m6phyj5rj5h"
path="res://.godot/imported/next1.png-bf654a011116d813d4402bb80daf9035.ctex"
path="res://.godot/imported/next1.png-e2501d06a1e36de52abd8ae05c750b5f.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://objects/word/sprites/next1.png"
dest_files=["res://.godot/imported/next1.png-bf654a011116d813d4402bb80daf9035.ctex"]
source_file="res://objects/styled_button/next1.png"
dest_files=["res://.godot/imported/next1.png-e2501d06a1e36de52abd8ae05c750b5f.ctex"]

[params]

Expand Down
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://dk12agqmgqcfv"
path="res://.godot/imported/next2.png-039190e59dfca4de0cfc76c28d67a6b1.ctex"
path="res://.godot/imported/next2.png-85e4aa26e1c98501d6087489c185955e.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://objects/word/sprites/next2.png"
dest_files=["res://.godot/imported/next2.png-039190e59dfca4de0cfc76c28d67a6b1.ctex"]
source_file="res://objects/styled_button/next2.png"
dest_files=["res://.godot/imported/next2.png-85e4aa26e1c98501d6087489c185955e.ctex"]

[params]

Expand Down
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://dijnhgkenbees"
path="res://.godot/imported/next3.png-b09f340489e4c8fd080596296fc73f35.ctex"
path="res://.godot/imported/next3.png-745f6441bf9e364c756e2f9ef9296ff3.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://objects/word/sprites/next3.png"
dest_files=["res://.godot/imported/next3.png-b09f340489e4c8fd080596296fc73f35.ctex"]
source_file="res://objects/styled_button/next3.png"
dest_files=["res://.godot/imported/next3.png-745f6441bf9e364c756e2f9ef9296ff3.ctex"]

[params]

Expand Down
Binary file added objects/styled_button/replay1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 421685c

Please sign in to comment.