Skip to content

Commit 20e0635

Browse files
Main game code and assets
1 parent 163fc21 commit 20e0635

16 files changed

Lines changed: 589 additions & 0 deletions

FONTH___.TTF

34.6 KB
Binary file not shown.

Main.gd

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
extends PanelContainer
2+
3+
onready var light = $Content/MainContent/Light
4+
5+
onready var main_button_not = $Content/MainContent/NotContainer/Button
6+
onready var main_border = $Content/MainContent/MainConditionPanel
7+
8+
onready var first_border = $Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer/FirstConditionPanel
9+
onready var first_button_not = $Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer/FirstConditionPanel/HBoxContainer/ButtonNot
10+
onready var first_button_bool = $Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer/FirstConditionPanel/HBoxContainer/ButtonBool
11+
12+
onready var and_or_button = $Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer/AndContainer/ButtonAndOr
13+
14+
onready var second_border = $Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer/SecondConditionPanel
15+
onready var second_button_not = $Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer/SecondConditionPanel/HBoxContainer/ButtonNot
16+
onready var second_button_bool = $Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer/SecondConditionPanel/HBoxContainer/ButtonBool
17+
18+
var previous_value = true
19+
export(bool) var main_condition = true
20+
export(bool) var first_condition = true
21+
export(bool) var is_first_true = true
22+
export(bool) var second_condition = true
23+
export(bool) var is_second_true = true
24+
25+
export(bool) var enable_main_not = false
26+
export(bool) var enable_first_not = false
27+
export(bool) var enable_second_not = false
28+
export(bool) var is_middle_and = true
29+
30+
export(Resource) var theme_green
31+
export(Resource) var theme_red
32+
33+
export(Texture) var light_on
34+
export(Texture) var light_off
35+
36+
export(Color) var disabled_text_color = Color("#898c89")
37+
export(Color) var enabled_text_color = Color("#7cf67b")
38+
export(Color) var false_text_color = Color("#fb6161")
39+
40+
func _ready():
41+
previous_value = main_condition
42+
43+
func _process(delta):
44+
first_condition = (not enable_first_not and is_first_true) or (enable_first_not and not is_first_true)
45+
_set_not_color(first_button_not, enable_first_not)
46+
_set_bool_button(first_button_bool, is_first_true)
47+
_set_border(first_border, first_condition)
48+
49+
second_condition = (not enable_second_not and is_second_true) or (enable_second_not and not is_second_true)
50+
_set_not_color(second_button_not, enable_second_not)
51+
_set_bool_button(second_button_bool, is_second_true)
52+
_set_border(second_border, second_condition)
53+
54+
_set_not_color(main_button_not, enable_main_not)
55+
56+
if is_middle_and:
57+
and_or_button.text = "AND"
58+
main_condition = first_condition and second_condition
59+
else:
60+
and_or_button.text = "OR"
61+
main_condition = first_condition or second_condition
62+
63+
main_condition = (not enable_main_not and main_condition) or (enable_main_not and not main_condition)
64+
65+
_set_border(main_border, main_condition)
66+
67+
if previous_value != main_condition:
68+
light.texture = light_on if main_condition else light_off
69+
70+
previous_value = main_condition
71+
72+
func _set_not_color(button : Button, is_enabled):
73+
if is_enabled:
74+
button.add_color_override("font_color", enabled_text_color)
75+
else:
76+
button.add_color_override("font_color", disabled_text_color)
77+
78+
func _set_bool_button(button : Button, is_true):
79+
if is_true:
80+
button.add_color_override("font_color", enabled_text_color)
81+
button.text = "TRUE"
82+
else:
83+
button.add_color_override("font_color", false_text_color)
84+
button.text = "FALSE"
85+
86+
func _set_border(panel : Panel, is_enabled):
87+
panel.add_stylebox_override("panel", theme_green if is_enabled else theme_red)
88+
89+
func _on_MainNot_pressed():
90+
enable_main_not = not enable_main_not
91+
92+
func _on_FirstNot_pressed():
93+
enable_first_not = not enable_first_not
94+
95+
func _on_FirstBool_pressed():
96+
is_first_true = not is_first_true
97+
98+
func _on_ButtonAndOr_pressed():
99+
is_middle_and = not is_middle_and
100+
101+
func _on_SecondNot_pressed():
102+
enable_second_not = not enable_second_not
103+
104+
func _on_SecondBool_pressed():
105+
is_second_true = not is_second_true

Main.tscn

Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
[gd_scene load_steps=10 format=2]
2+
3+
[ext_resource path="res://lightbulb-on.png" type="Texture" id=1]
4+
[ext_resource path="res://white.png" type="Texture" id=2]
5+
[ext_resource path="res://style_green.tres" type="StyleBox" id=3]
6+
[ext_resource path="res://style_red.tres" type="StyleBox" id=4]
7+
[ext_resource path="res://font_buttons.tres" type="DynamicFont" id=5]
8+
[ext_resource path="res://Main.gd" type="Script" id=6]
9+
[ext_resource path="res://lightbulb-off.png" type="Texture" id=7]
10+
11+
[sub_resource type="DynamicFontData" id=1]
12+
font_path = "res://FONTH___.TTF"
13+
14+
[sub_resource type="DynamicFont" id=2]
15+
size = 25
16+
outline_color = Color( 0, 0, 0, 1 )
17+
font_data = SubResource( 1 )
18+
19+
[node name="Main" type="PanelContainer"]
20+
anchor_right = 1.0
21+
anchor_bottom = 1.0
22+
script = ExtResource( 6 )
23+
__meta__ = {
24+
"_edit_use_anchors_": false
25+
}
26+
theme_green = ExtResource( 3 )
27+
theme_red = ExtResource( 4 )
28+
light_on = ExtResource( 1 )
29+
light_off = ExtResource( 7 )
30+
31+
[node name="TextureRect" type="TextureRect" parent="."]
32+
margin_left = 7.0
33+
margin_top = 7.0
34+
margin_right = 1017.0
35+
margin_bottom = 595.0
36+
grow_horizontal = 2
37+
grow_vertical = 2
38+
size_flags_horizontal = 3
39+
size_flags_vertical = 3
40+
texture = ExtResource( 2 )
41+
stretch_mode = 1
42+
__meta__ = {
43+
"_edit_use_anchors_": false
44+
}
45+
46+
[node name="Content" type="VBoxContainer" parent="."]
47+
margin_left = 7.0
48+
margin_top = 7.0
49+
margin_right = 1017.0
50+
margin_bottom = 595.0
51+
alignment = 1
52+
53+
[node name="VSplitContainer4" type="VSplitContainer" parent="Content"]
54+
margin_right = 1010.0
55+
margin_bottom = 10.0
56+
rect_min_size = Vector2( 0, 10 )
57+
58+
[node name="Label" type="Label" parent="Content"]
59+
margin_top = 14.0
60+
margin_right = 1010.0
61+
margin_bottom = 77.0
62+
custom_fonts/font = SubResource( 2 )
63+
custom_colors/font_color = Color( 0.0980392, 0.0980392, 0.0980392, 1 )
64+
text = "TESTES LÓGICOS
65+
Clique nos botões para inverter os valores."
66+
align = 1
67+
68+
[node name="VSplitContainer" type="VSplitContainer" parent="Content"]
69+
margin_top = 81.0
70+
margin_right = 1010.0
71+
margin_bottom = 96.0
72+
rect_min_size = Vector2( 0, 15 )
73+
74+
[node name="MainContent" type="HBoxContainer" parent="Content"]
75+
margin_top = 100.0
76+
margin_right = 1010.0
77+
margin_bottom = 526.0
78+
alignment = 1
79+
80+
[node name="HSplitContainer2" type="HSplitContainer" parent="Content/MainContent"]
81+
margin_right = 25.0
82+
margin_bottom = 426.0
83+
rect_min_size = Vector2( 25, 0 )
84+
85+
[node name="NotContainer" type="CenterContainer" parent="Content/MainContent"]
86+
margin_left = 29.0
87+
margin_right = 97.0
88+
margin_bottom = 426.0
89+
90+
[node name="Button" type="Button" parent="Content/MainContent/NotContainer"]
91+
margin_top = 192.0
92+
margin_right = 68.0
93+
margin_bottom = 234.0
94+
size_flags_horizontal = 0
95+
size_flags_vertical = 0
96+
custom_fonts/font = ExtResource( 5 )
97+
custom_colors/font_color = Color( 0.537255, 0.54902, 0.537255, 1 )
98+
text = "NOT"
99+
100+
[node name="HSplitContainer3" type="HSplitContainer" parent="Content/MainContent"]
101+
margin_left = 101.0
102+
margin_right = 126.0
103+
margin_bottom = 426.0
104+
rect_min_size = Vector2( 25, 0 )
105+
split_offset = 25
106+
107+
[node name="MainConditionPanel" type="Panel" parent="Content/MainContent"]
108+
margin_left = 130.0
109+
margin_right = 522.0
110+
margin_bottom = 426.0
111+
size_flags_horizontal = 3
112+
size_flags_vertical = 3
113+
custom_styles/panel = ExtResource( 3 )
114+
115+
[node name="ConditionsContainer" type="CenterContainer" parent="Content/MainContent/MainConditionPanel"]
116+
anchor_left = 0.5
117+
anchor_top = 0.5
118+
anchor_right = 0.5
119+
anchor_bottom = 0.5
120+
margin_left = -42.0
121+
margin_top = -34.0
122+
margin_right = 42.0
123+
margin_bottom = 34.0
124+
grow_horizontal = 2
125+
grow_vertical = 2
126+
__meta__ = {
127+
"_edit_use_anchors_": false
128+
}
129+
130+
[node name="InnerContainer" type="VBoxContainer" parent="Content/MainContent/MainConditionPanel/ConditionsContainer"]
131+
margin_right = 220.0
132+
margin_bottom = 328.0
133+
size_flags_horizontal = 3
134+
size_flags_vertical = 3
135+
__meta__ = {
136+
"_edit_use_anchors_": false
137+
}
138+
139+
[node name="FirstConditionPanel" type="Panel" parent="Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer"]
140+
margin_right = 220.0
141+
margin_bottom = 120.0
142+
rect_min_size = Vector2( 220, 120 )
143+
custom_styles/panel = ExtResource( 3 )
144+
145+
[node name="HBoxContainer" type="HBoxContainer" parent="Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer/FirstConditionPanel"]
146+
anchor_left = 0.5
147+
anchor_top = 0.5
148+
anchor_right = 0.5
149+
anchor_bottom = 0.5
150+
margin_left = -96.0
151+
margin_top = -21.0
152+
margin_right = 96.0
153+
margin_bottom = 21.0
154+
size_flags_horizontal = 3
155+
size_flags_vertical = 3
156+
__meta__ = {
157+
"_edit_use_anchors_": false
158+
}
159+
160+
[node name="ButtonNot" type="Button" parent="Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer/FirstConditionPanel/HBoxContainer"]
161+
margin_right = 68.0
162+
margin_bottom = 42.0
163+
size_flags_horizontal = 0
164+
size_flags_vertical = 0
165+
custom_fonts/font = ExtResource( 5 )
166+
text = "NOT"
167+
168+
[node name="ButtonBool" type="Button" parent="Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer/FirstConditionPanel/HBoxContainer"]
169+
margin_left = 72.0
170+
margin_right = 192.0
171+
margin_bottom = 42.0
172+
rect_min_size = Vector2( 120, 0 )
173+
size_flags_horizontal = 0
174+
size_flags_vertical = 0
175+
custom_fonts/font = ExtResource( 5 )
176+
custom_colors/font_color = Color( 0.984314, 0.380392, 0.380392, 1 )
177+
text = "TRUE"
178+
179+
[node name="VSplitContainer" type="VSplitContainer" parent="Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer"]
180+
margin_top = 124.0
181+
margin_right = 220.0
182+
margin_bottom = 139.0
183+
rect_min_size = Vector2( 0, 15 )
184+
185+
[node name="AndContainer" type="CenterContainer" parent="Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer"]
186+
margin_top = 143.0
187+
margin_right = 220.0
188+
margin_bottom = 185.0
189+
190+
[node name="ButtonAndOr" type="Button" parent="Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer/AndContainer"]
191+
margin_left = 70.0
192+
margin_right = 150.0
193+
margin_bottom = 42.0
194+
rect_min_size = Vector2( 80, 0 )
195+
size_flags_horizontal = 0
196+
size_flags_vertical = 0
197+
custom_fonts/font = ExtResource( 5 )
198+
custom_colors/font_color = Color( 0.360784, 0.905882, 0.945098, 1 )
199+
text = "AND"
200+
201+
[node name="VSplitContainer2" type="VSplitContainer" parent="Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer"]
202+
margin_top = 189.0
203+
margin_right = 220.0
204+
margin_bottom = 204.0
205+
rect_min_size = Vector2( 0, 15 )
206+
207+
[node name="SecondConditionPanel" type="Panel" parent="Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer"]
208+
margin_top = 208.0
209+
margin_right = 220.0
210+
margin_bottom = 328.0
211+
rect_min_size = Vector2( 220, 120 )
212+
custom_styles/panel = ExtResource( 3 )
213+
214+
[node name="HBoxContainer" type="HBoxContainer" parent="Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer/SecondConditionPanel"]
215+
anchor_left = 0.5
216+
anchor_top = 0.5
217+
anchor_right = 0.5
218+
anchor_bottom = 0.5
219+
margin_left = -96.0
220+
margin_top = -21.0
221+
margin_right = 96.0
222+
margin_bottom = 21.0
223+
size_flags_horizontal = 3
224+
size_flags_vertical = 3
225+
__meta__ = {
226+
"_edit_use_anchors_": false
227+
}
228+
229+
[node name="ButtonNot" type="Button" parent="Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer/SecondConditionPanel/HBoxContainer"]
230+
margin_right = 68.0
231+
margin_bottom = 42.0
232+
size_flags_horizontal = 0
233+
size_flags_vertical = 0
234+
custom_fonts/font = ExtResource( 5 )
235+
text = "NOT"
236+
237+
[node name="ButtonBool" type="Button" parent="Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer/SecondConditionPanel/HBoxContainer"]
238+
margin_left = 72.0
239+
margin_right = 192.0
240+
margin_bottom = 42.0
241+
rect_min_size = Vector2( 120, 0 )
242+
size_flags_horizontal = 0
243+
size_flags_vertical = 0
244+
custom_fonts/font = ExtResource( 5 )
245+
text = "TRUE"
246+
247+
[node name="HSplitContainer" type="HSplitContainer" parent="Content/MainContent"]
248+
margin_left = 526.0
249+
margin_right = 551.0
250+
margin_bottom = 426.0
251+
rect_min_size = Vector2( 25, 0 )
252+
253+
[node name="Light" type="TextureRect" parent="Content/MainContent"]
254+
margin_left = 555.0
255+
margin_right = 981.0
256+
margin_bottom = 426.0
257+
texture = ExtResource( 1 )
258+
259+
[node name="HSplitContainer4" type="HSplitContainer" parent="Content/MainContent"]
260+
margin_left = 985.0
261+
margin_right = 1010.0
262+
margin_bottom = 426.0
263+
rect_min_size = Vector2( 25, 0 )
264+
265+
[node name="VSplitContainer2" type="VSplitContainer" parent="Content"]
266+
margin_top = 530.0
267+
margin_right = 1010.0
268+
margin_bottom = 540.0
269+
rect_min_size = Vector2( 0, 10 )
270+
271+
[node name="Label2" type="Label" parent="Content"]
272+
margin_top = 544.0
273+
margin_right = 1010.0
274+
margin_bottom = 574.0
275+
custom_fonts/font = SubResource( 2 )
276+
custom_colors/font_color = Color( 0.0980392, 0.0980392, 0.0980392, 1 )
277+
text = "youtube.com/CriaJogo"
278+
align = 1
279+
280+
[node name="VSplitContainer3" type="VSplitContainer" parent="Content"]
281+
margin_top = 578.0
282+
margin_right = 1010.0
283+
margin_bottom = 588.0
284+
rect_min_size = Vector2( 0, 10 )
285+
[connection signal="pressed" from="Content/MainContent/NotContainer/Button" to="." method="_on_MainNot_pressed"]
286+
[connection signal="pressed" from="Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer/FirstConditionPanel/HBoxContainer/ButtonNot" to="." method="_on_FirstNot_pressed"]
287+
[connection signal="pressed" from="Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer/FirstConditionPanel/HBoxContainer/ButtonBool" to="." method="_on_FirstBool_pressed"]
288+
[connection signal="pressed" from="Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer/AndContainer/ButtonAndOr" to="." method="_on_ButtonAndOr_pressed"]
289+
[connection signal="pressed" from="Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer/SecondConditionPanel/HBoxContainer/ButtonNot" to="." method="_on_SecondNot_pressed"]
290+
[connection signal="pressed" from="Content/MainContent/MainConditionPanel/ConditionsContainer/InnerContainer/SecondConditionPanel/HBoxContainer/ButtonBool" to="." method="_on_SecondBool_pressed"]

0 commit comments

Comments
 (0)