operation
This commit is contained in:
parent
7dbd914f28
commit
a58c87cfeb
2 changed files with 77 additions and 3 deletions
|
@ -1,7 +1,43 @@
|
||||||
[gd_scene load_steps=3 format=3 uid="uid://c3qlt4pa4qbji"]
|
[gd_scene load_steps=4 format=3 uid="uid://c3qlt4pa4qbji"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://n06gkookqeml" path="res://scenes/game/windows/Ads.tscn" id="1_2b68r"]
|
[ext_resource type="PackedScene" uid="uid://n06gkookqeml" path="res://scenes/game/windows/Ads.tscn" id="1_2b68r"]
|
||||||
[ext_resource type="Script" path="res://scripts/ads/ads_operation.gd" id="2_jop1v"]
|
[ext_resource type="Script" path="res://scripts/ads/ads_operation.gd" id="2_jop1v"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://goinpjd4qxgd" path="res://ressources/assets/Operation/Operation.png" id="3_nc0f5"]
|
||||||
|
|
||||||
[node name="Windows" instance=ExtResource("1_2b68r")]
|
[node name="Windows" instance=ExtResource("1_2b68r")]
|
||||||
script = ExtResource("2_jop1v")
|
script = ExtResource("2_jop1v")
|
||||||
|
|
||||||
|
[node name="Operation" type="Sprite2D" parent="." index="2"]
|
||||||
|
position = Vector2(250.5, 224)
|
||||||
|
scale = Vector2(0.400833, 0.35)
|
||||||
|
texture = ExtResource("3_nc0f5")
|
||||||
|
|
||||||
|
[node name="Question" type="Label" parent="." index="3"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 82.0
|
||||||
|
offset_top = 144.0
|
||||||
|
offset_right = 385.0
|
||||||
|
offset_bottom = 249.0
|
||||||
|
theme_override_colors/font_color = Color(0.905882, 0.639216, 0.858824, 1)
|
||||||
|
theme_override_font_sizes/font_size = 76
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="Button1" type="Button" parent="." index="4"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 103.0
|
||||||
|
offset_top = 229.0
|
||||||
|
offset_right = 235.0
|
||||||
|
offset_bottom = 325.0
|
||||||
|
theme_override_font_sizes/font_size = 31
|
||||||
|
|
||||||
|
[node name="Button2" type="Button" parent="." index="5"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 237.0
|
||||||
|
offset_top = 230.0
|
||||||
|
offset_right = 381.0
|
||||||
|
offset_bottom = 326.0
|
||||||
|
theme_override_font_sizes/font_size = 31
|
||||||
|
|
||||||
|
[connection signal="pressed" from="Button1" to="." method="_on_button_1_pressed"]
|
||||||
|
[connection signal="pressed" from="Button2" to="." method="_on_button_2_pressed"]
|
||||||
|
|
|
@ -1,9 +1,47 @@
|
||||||
extends "res://scripts/ads/ads_default.gd"
|
extends "res://scripts/ads/ads_default.gd"
|
||||||
|
|
||||||
# TODO
|
@onready var question := $Question
|
||||||
|
@onready var responseA := $Button1
|
||||||
|
@onready var responseB := $Button2
|
||||||
|
|
||||||
|
enum OP {
|
||||||
|
ADD,
|
||||||
|
SUB,
|
||||||
|
MUL,
|
||||||
|
}
|
||||||
|
|
||||||
|
var reponse
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
pass
|
var a := randi_range(0, 9)
|
||||||
|
var b := randi_range(0, 9)
|
||||||
|
|
||||||
|
var operation = OP.values().pick_random()
|
||||||
|
var operator := ""
|
||||||
|
|
||||||
|
match operation:
|
||||||
|
OP.ADD:
|
||||||
|
reponse = a + b
|
||||||
|
operator = "+"
|
||||||
|
OP.SUB:
|
||||||
|
reponse = a - b
|
||||||
|
operator = "-"
|
||||||
|
OP.MUL:
|
||||||
|
reponse = a * b
|
||||||
|
operator = "*"
|
||||||
|
|
||||||
|
question.text = str(str(a), " ", operator, " " , str(b))
|
||||||
|
|
||||||
|
var buttons := [responseA, responseB]
|
||||||
|
buttons.shuffle()
|
||||||
|
buttons[0].text = str(reponse)
|
||||||
|
buttons[1].text = str(randi_range(-10, 30))
|
||||||
|
|
||||||
func exit_condition():
|
func exit_condition():
|
||||||
return condition
|
return condition
|
||||||
|
|
||||||
|
func _on_button_1_pressed():
|
||||||
|
condition = int(responseA.text) == reponse
|
||||||
|
|
||||||
|
func _on_button_2_pressed():
|
||||||
|
condition = int(responseB.text) == reponse
|
||||||
|
|
Reference in a new issue