Skip to content

Commit 020c32d

Browse files
authored
Merge pull request #6 from aibrahim185/a
A
2 parents 4fb72e8 + bd9c1fa commit 020c32d

File tree

7 files changed

+587
-30
lines changed

7 files changed

+587
-30
lines changed

src/main_scene/main_scene.cpp

Lines changed: 386 additions & 20 deletions
Large diffs are not rendered by default.

src/main_scene/main_scene.hpp

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
#include <godot_cpp/classes/node3d.hpp>
44
#include <godot_cpp/classes/camera3d.hpp>
5+
#include <godot_cpp/classes/world3d.hpp>
56
#include <godot_cpp/classes/input_event_mouse_button.hpp>
7+
#include <godot_cpp/classes/input_event_mouse_motion.hpp>
8+
#include <godot_cpp/classes/physics_direct_space_state3d.hpp>
9+
#include <godot_cpp/classes/physics_ray_query_parameters3d.hpp>
610
#include <godot_cpp/classes/button.hpp>
711
#include <godot_cpp/classes/option_button.hpp>
812
#include <godot_cpp/classes/label.hpp>
@@ -17,6 +21,8 @@
1721
#include <godot_cpp/classes/collision_shape3d.hpp>
1822
#include <godot_cpp/classes/concave_polygon_shape3d.hpp>
1923
#include <godot_cpp/classes/scene_tree.hpp>
24+
#include <godot_cpp/classes/v_box_container.hpp>
25+
#include <godot_cpp/classes/scene_tree_timer.hpp>
2026
#include <godot_cpp/classes/tween.hpp>
2127
#include <godot_cpp/classes/property_tweener.hpp>
2228
#include <godot_cpp/classes/engine.hpp>
@@ -26,6 +32,7 @@
2632
#include <fstream>
2733
#include <vector>
2834
#include <map>
35+
#include <cmath>
2936

3037
#include "../utils/utils.hpp"
3138

@@ -44,7 +51,9 @@ class MainScene : public Node3D {
4451
bool is_solved = false;
4552
AlgoType algo_type = BFS;
4653

54+
Label* node_label = nullptr;
4755
Label* time_label = nullptr;
56+
Label* move_label = nullptr;
4857

4958
Button* solve_button = nullptr;
5059
Button* reset_button = nullptr;
@@ -53,6 +62,7 @@ class MainScene : public Node3D {
5362

5463
Ref<PackedScene> car2_template;
5564
Ref<PackedScene> car3_template;
65+
Ref<PackedScene> gate_template;
5666
Ref<StandardMaterial3D> primary_piece_material;
5767
Ref<StandardMaterial3D> non_primary_piece_material;
5868
MeshInstance3D* floor = nullptr;
@@ -64,13 +74,25 @@ class MainScene : public Node3D {
6474
Solution current_solution;
6575
int current_move_index = -1;
6676
bool is_animating_solution = false;
67-
const float ANIMATION_DURATION = 0.5f;
77+
const float ANIMATION_DURATION = 0.25f;
6878

6979
Camera3D* camera_node;
7080
float zoom_speed = 0.5f;
7181
float min_zoom_distance = 2.0f;
7282
float max_zoom_distance = 20.0f;
7383

84+
int notification_count = 0;
85+
VBoxContainer* notification_container = nullptr;
86+
Label* notification_label_template = nullptr;
87+
88+
Node3D* dragged_car_node = nullptr;
89+
Piece* dragged_piece_data = nullptr;
90+
Vector3 drag_start_mouse_world_pos;
91+
Vector3 drag_start_car_3d_pos;
92+
Coordinates drag_start_piece_coords;
93+
bool is_dragging_piece = false;
94+
int current_manual_moves = 0;
95+
7496
void _animate_next_move();
7597
void _on_move_animation_finished();
7698
Vector3 _get_3d_position_for_piece_coords(const Coordinates& piece_top_left_coords, int piece_size, bool is_vertical_piece);
@@ -89,6 +111,11 @@ class MainScene : public Node3D {
89111
void _clear_all_cars();
90112
void _spawn_piece_as_car(const Piece& piece_data);
91113

114+
void add_notification(const String& p_message);
115+
116+
Coordinates _get_grid_coords_from_3d_position(const Vector3& pos_3d, int piece_size, bool is_vertical_piece);
117+
bool _is_move_valid(const Coordinates& from_coords, const Coordinates& to_coords, char piece_id_moving, bool is_vertical);
118+
92119
protected:
93120
static void _bind_methods();
94121
void _notification(int p_what);
@@ -98,5 +125,5 @@ class MainScene : public Node3D {
98125
~MainScene();
99126

100127
void _process(double delta) override;
101-
void _input(const Ref<InputEvent>& event);
128+
void _input(const Ref<InputEvent>& event) override;
102129
};

test/2.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
5 5
2-
5
3-
EAAA.
2+
4
3+
...P.
44
ED.PB
55
.D.PB
66
.DCCB

tukang-parkir-simulator/export_presets.cfg

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ custom_features=""
99
export_filter="all_resources"
1010
include_filter=""
1111
exclude_filter=""
12-
export_path="../../executable/godot cpp template.html"
12+
export_path="../bin/web/Tukang Parkir Simulator.html"
1313
patches=PackedStringArray()
1414
encryption_include_filters=""
1515
encryption_exclude_filters=""
@@ -22,7 +22,7 @@ script_export_mode=2
2222

2323
custom_template/debug=""
2424
custom_template/release=""
25-
variant/extensions_support=false
25+
variant/extensions_support=true
2626
variant/thread_support=false
2727
vram_texture_compression/for_desktop=true
2828
vram_texture_compression/for_mobile=false
@@ -47,13 +47,13 @@ progressive_web_app/background_color=Color(0, 0, 0, 1)
4747
name="Windows Desktop"
4848
platform="Windows Desktop"
4949
runnable=true
50-
advanced_options=false
50+
advanced_options=true
5151
dedicated_server=false
5252
custom_features=""
5353
export_filter="all_resources"
5454
include_filter=""
5555
exclude_filter=""
56-
export_path=""
56+
export_path="../bin/windows/Tukang Parkir Simulator.exe"
5757
patches=PackedStringArray()
5858
encryption_include_filters=""
5959
encryption_exclude_filters=""

tukang-parkir-simulator/project.godot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ window/stretch/mode="viewport"
2727

2828
[rendering]
2929

30+
textures/canvas_textures/default_texture_filter=0
3031
renderer/rendering_method="gl_compatibility"
3132
renderer/rendering_method.mobile="gl_compatibility"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[gd_scene load_steps=2 format=3 uid="uid://dvm8u67mw7kiy"]
2+
3+
[sub_resource type="BoxShape3D" id="BoxShape3D_ghoj6"]
4+
size = Vector3(0.15, 0.1, 0.15)
5+
6+
[node name="Gate" type="StaticBody3D"]
7+
8+
[node name="CSGPolygon3D" type="CSGPolygon3D" parent="."]
9+
transform = Transform3D(-1, 1.19209e-07, 0, -1.19209e-07, -1, 0, 0, 0, 1, 0, 0.05, 0)
10+
flip_faces = true
11+
polygon = PackedVector2Array(0.2, 0.1, 0, 0.75, 0.35, 0.15, 0.1, -0.1)
12+
mode = 1
13+
spin_degrees = 360.0
14+
spin_sides = 10
15+
smooth_faces = true
16+
17+
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
18+
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.025, 1.1, 0.025)
19+
shape = SubResource("BoxShape3D_ghoj6")

tukang-parkir-simulator/scenes/main.tscn

Lines changed: 146 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
[gd_scene load_steps=12 format=3 uid="uid://deic8j1v28f5m"]
1+
[gd_scene load_steps=15 format=3 uid="uid://deic8j1v28f5m"]
22

33
[ext_resource type="PackedScene" uid="uid://bj1kkdl8im8kb" path="res://scenes/car2.tscn" id="1_0wfyh"]
44
[ext_resource type="Shader" uid="uid://dif4yb3527o0r" path="res://scenes/floor.gdshader" id="1_sugp2"]
55
[ext_resource type="PackedScene" uid="uid://nk8hrlhom63t" path="res://scenes/car3.tscn" id="2_sugp2"]
6+
[ext_resource type="PackedScene" uid="uid://dvm8u67mw7kiy" path="res://scenes/gate.tscn" id="4_jyhfs"]
67

78
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_kuqtn"]
89
sky_horizon_color = Color(0.662243, 0.671743, 0.686743, 1)
@@ -14,9 +15,9 @@ sky_material = SubResource("ProceduralSkyMaterial_kuqtn")
1415
[sub_resource type="Environment" id="Environment_3lc0u"]
1516
background_mode = 1
1617
background_color = Color(0.364706, 0, 0.0862745, 1)
18+
background_energy_multiplier = 4.0
1719
sky = SubResource("Sky_whr1e")
1820
tonemap_mode = 2
19-
glow_enabled = true
2021

2122
[sub_resource type="ShaderMaterial" id="ShaderMaterial_jyhfs"]
2223
render_priority = 0
@@ -38,6 +39,44 @@ size = Vector2(6, 6)
3839
data = PackedVector3Array(50, 0, 50, -50, 0, 50, 50, 0, -50, -50, 0, 50, -50, 0, -50, 50, 0, -50)
3940

4041
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_kuqtn"]
42+
bg_color = Color(0.91815, 0, 0.228352, 1)
43+
border_width_left = 5
44+
border_width_top = 5
45+
border_width_right = 5
46+
border_width_bottom = 5
47+
border_color = Color(0.825689, 0.839261, 7.70092e-07, 1)
48+
corner_radius_top_left = 10
49+
corner_radius_top_right = 10
50+
corner_radius_bottom_right = 10
51+
corner_radius_bottom_left = 10
52+
53+
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_tbgi4"]
54+
content_margin_left = 15.0
55+
content_margin_right = 15.0
56+
bg_color = Color(0.91815, 0, 0.228352, 1)
57+
border_width_left = 5
58+
border_width_top = 5
59+
border_width_right = 5
60+
border_width_bottom = 5
61+
border_color = Color(0.825689, 0.839261, 7.70092e-07, 1)
62+
corner_radius_top_left = 10
63+
corner_radius_top_right = 10
64+
corner_radius_bottom_right = 10
65+
corner_radius_bottom_left = 10
66+
67+
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jyhfs"]
68+
content_margin_left = 15.0
69+
content_margin_right = 15.0
70+
bg_color = Color(0.91815, 0, 0.228352, 1)
71+
border_width_left = 5
72+
border_width_top = 5
73+
border_width_right = 5
74+
border_width_bottom = 5
75+
border_color = Color(0.825689, 0.839261, 7.70092e-07, 1)
76+
corner_radius_top_left = 10
77+
corner_radius_top_right = 10
78+
corner_radius_bottom_right = 10
79+
corner_radius_bottom_left = 10
4180

4281
[node name="Main" type="MainScene"]
4382

@@ -55,6 +94,9 @@ sky_mode = 1
5594
material_override = SubResource("ShaderMaterial_jyhfs")
5695
mesh = SubResource("PlaneMesh_0wfyh")
5796

97+
[node name="Gate" parent="StaticBody3D/Floor" instance=ExtResource("4_jyhfs")]
98+
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.5, 0.5, -0.5)
99+
58100
[node name="Car2" parent="StaticBody3D/Floor" instance=ExtResource("1_0wfyh")]
59101
transform = Transform3D(1, 0, 1.06581e-14, 0, 1, 0, -1.06581e-14, 0, 1, -1.5, 0.5, -1)
60102

@@ -83,6 +125,18 @@ offset_bottom = -26.0
83125
grow_horizontal = 2
84126
grow_vertical = 0
85127
focus_mode = 0
128+
theme_override_colors/font_color = Color(0.825689, 0.839261, 7.70092e-07, 1)
129+
theme_override_font_sizes/font_size = 31
130+
theme_override_styles/focus = SubResource("StyleBoxFlat_kuqtn")
131+
theme_override_styles/disabled_mirrored = SubResource("StyleBoxFlat_kuqtn")
132+
theme_override_styles/disabled = SubResource("StyleBoxFlat_kuqtn")
133+
theme_override_styles/hover_pressed_mirrored = SubResource("StyleBoxFlat_kuqtn")
134+
theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_kuqtn")
135+
theme_override_styles/hover_mirrored = SubResource("StyleBoxFlat_kuqtn")
136+
theme_override_styles/hover = SubResource("StyleBoxFlat_kuqtn")
137+
theme_override_styles/pressed_mirrored = SubResource("StyleBoxFlat_kuqtn")
138+
theme_override_styles/pressed = SubResource("StyleBoxFlat_kuqtn")
139+
theme_override_styles/normal_mirrored = SubResource("StyleBoxFlat_kuqtn")
86140
theme_override_styles/normal = SubResource("StyleBoxFlat_kuqtn")
87141
text = "Solve"
88142

@@ -99,6 +153,18 @@ offset_bottom = -27.0
99153
grow_horizontal = 2
100154
grow_vertical = 0
101155
focus_mode = 0
156+
theme_override_colors/font_color = Color(0.825689, 0.839261, 7.70092e-07, 1)
157+
theme_override_font_sizes/font_size = 31
158+
theme_override_styles/focus = SubResource("StyleBoxFlat_kuqtn")
159+
theme_override_styles/disabled_mirrored = SubResource("StyleBoxFlat_kuqtn")
160+
theme_override_styles/disabled = SubResource("StyleBoxFlat_kuqtn")
161+
theme_override_styles/hover_pressed_mirrored = SubResource("StyleBoxFlat_kuqtn")
162+
theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_kuqtn")
163+
theme_override_styles/hover_mirrored = SubResource("StyleBoxFlat_kuqtn")
164+
theme_override_styles/hover = SubResource("StyleBoxFlat_kuqtn")
165+
theme_override_styles/pressed_mirrored = SubResource("StyleBoxFlat_kuqtn")
166+
theme_override_styles/pressed = SubResource("StyleBoxFlat_kuqtn")
167+
theme_override_styles/normal_mirrored = SubResource("StyleBoxFlat_kuqtn")
102168
theme_override_styles/normal = SubResource("StyleBoxFlat_kuqtn")
103169
text = "Load"
104170

@@ -115,6 +181,18 @@ offset_bottom = -25.0
115181
grow_horizontal = 2
116182
grow_vertical = 0
117183
focus_mode = 0
184+
theme_override_colors/font_color = Color(0.825689, 0.839261, 7.70092e-07, 1)
185+
theme_override_font_sizes/font_size = 31
186+
theme_override_styles/focus = SubResource("StyleBoxFlat_kuqtn")
187+
theme_override_styles/disabled_mirrored = SubResource("StyleBoxFlat_kuqtn")
188+
theme_override_styles/disabled = SubResource("StyleBoxFlat_kuqtn")
189+
theme_override_styles/hover_pressed_mirrored = SubResource("StyleBoxFlat_kuqtn")
190+
theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_kuqtn")
191+
theme_override_styles/hover_mirrored = SubResource("StyleBoxFlat_kuqtn")
192+
theme_override_styles/hover = SubResource("StyleBoxFlat_kuqtn")
193+
theme_override_styles/pressed_mirrored = SubResource("StyleBoxFlat_kuqtn")
194+
theme_override_styles/pressed = SubResource("StyleBoxFlat_kuqtn")
195+
theme_override_styles/normal_mirrored = SubResource("StyleBoxFlat_kuqtn")
118196
theme_override_styles/normal = SubResource("StyleBoxFlat_kuqtn")
119197
text = "Reset"
120198

@@ -127,6 +205,26 @@ offset_top = 25.0
127205
offset_right = -30.0
128206
offset_bottom = 69.0
129207
grow_horizontal = 0
208+
theme_override_styles/focus = SubResource("StyleBoxFlat_kuqtn")
209+
theme_override_styles/disabled_mirrored = SubResource("StyleBoxFlat_kuqtn")
210+
theme_override_styles/disabled = SubResource("StyleBoxFlat_kuqtn")
211+
theme_override_styles/hover_mirrored = SubResource("StyleBoxFlat_kuqtn")
212+
theme_override_styles/hover = SubResource("StyleBoxFlat_tbgi4")
213+
theme_override_styles/normal_mirrored = SubResource("StyleBoxFlat_kuqtn")
214+
theme_override_styles/normal = SubResource("StyleBoxFlat_jyhfs")
215+
216+
[node name="NodeLabel" type="Label" parent="UI"]
217+
anchors_preset = 7
218+
anchor_left = 0.5
219+
anchor_top = 1.0
220+
anchor_right = 0.5
221+
anchor_bottom = 1.0
222+
offset_left = -177.0
223+
offset_top = -23.0
224+
offset_right = -99.0
225+
grow_horizontal = 2
226+
grow_vertical = 0
227+
text = "Node: 0"
130228

131229
[node name="TimeLabel" type="Label" parent="UI"]
132230
anchors_preset = 7
@@ -140,3 +238,49 @@ offset_right = 20.0
140238
grow_horizontal = 2
141239
grow_vertical = 0
142240
text = "Time: 0.0s"
241+
242+
[node name="MoveLabel" type="Label" parent="UI"]
243+
anchors_preset = 7
244+
anchor_left = 0.5
245+
anchor_top = 1.0
246+
anchor_right = 0.5
247+
anchor_bottom = 1.0
248+
offset_left = 111.0
249+
offset_top = -25.0
250+
offset_right = 189.0
251+
offset_bottom = -2.0
252+
grow_horizontal = 2
253+
grow_vertical = 0
254+
text = "Move: 0"
255+
256+
[node name="MarginContainer" type="MarginContainer" parent="UI"]
257+
anchors_preset = 11
258+
anchor_left = 1.0
259+
anchor_right = 1.0
260+
anchor_bottom = 1.0
261+
offset_left = -365.0
262+
grow_horizontal = 0
263+
grow_vertical = 2
264+
mouse_filter = 2
265+
theme_override_constants/margin_right = 20
266+
theme_override_constants/margin_bottom = 20
267+
268+
[node name="ScrollContainer" type="ScrollContainer" parent="UI/MarginContainer"]
269+
layout_mode = 2
270+
mouse_filter = 2
271+
272+
[node name="VBoxContainer" type="VBoxContainer" parent="UI/MarginContainer/ScrollContainer"]
273+
layout_mode = 2
274+
size_flags_horizontal = 3
275+
size_flags_vertical = 3
276+
mouse_filter = 2
277+
theme_override_constants/separation = 20
278+
alignment = 2
279+
280+
[node name="Label" type="Label" parent="UI/MarginContainer/ScrollContainer/VBoxContainer"]
281+
layout_mode = 2
282+
size_flags_vertical = 1
283+
theme_override_styles/normal = SubResource("StyleBoxFlat_jyhfs")
284+
text = "Congratulations! You reached the exit in \" + String::num_int64(current_manual_moves) + \" moves!"
285+
vertical_alignment = 1
286+
autowrap_mode = 1

0 commit comments

Comments
 (0)