operation
This commit is contained in:
parent
7dbd914f28
commit
a58c87cfeb
2 changed files with 77 additions and 3 deletions
|
@ -1,9 +1,47 @@
|
|||
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():
|
||||
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():
|
||||
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