Anri/AdBlockNot
Archived
1
0
Fork 0
This repository has been archived on 2024-01-28. You can view files and clone it, but cannot push or open issues or pull requests.
AdBlockNot/scripts/ads/ads_operation.gd

48 lines
882 B
GDScript3
Raw Normal View History

2024-01-28 18:13:30 +01:00
extends "res://scripts/ads/ads_default.gd"
2024-01-28 19:07:40 +01:00
@onready var question := $Question
@onready var responseA := $Button1
@onready var responseB := $Button2
enum OP {
ADD,
SUB,
MUL,
}
var reponse
2024-01-28 18:13:30 +01:00
func _ready():
2024-01-28 19:07:40 +01:00
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))
2024-01-28 18:13:30 +01:00
func exit_condition():
return condition
2024-01-28 19:07:40 +01:00
func _on_button_1_pressed():
condition = int(responseA.text) == reponse
func _on_button_2_pressed():
condition = int(responseB.text) == reponse