v1.0 finished

This commit is contained in:
2025-03-22 22:27:56 -04:00
parent f61114dce9
commit 5228b81e8b
19 changed files with 48 additions and 51 deletions

View File

@@ -24,7 +24,9 @@ func _explode():
func _determine_seconds_left() -> float:
var difficulty_calc:float = 20-float(GLOBALVARS.difficulty)
return difficulty_calc if difficulty_calc >= 3.0 else 3.0
difficulty_calc = difficulty_calc if difficulty_calc >= 3.0 else 3.0
GLOBALVARS.start_seconds = difficulty_calc
return difficulty_calc
func _on_answer_text_submitted(_new_text: String) -> void:
if GLOBALVARS.current_solution == (%ANSWER.text).to_int() and (%ANSWER.text).is_valid_int():
@@ -49,41 +51,26 @@ func _generate_question() -> void:
# 0 - add
# 1 - subtract
# 2 - multiply
# 3 - divide
var rand_int:int = randi_range(0,2)
var x:int = randi_range(1,10)
var y:int = randi_range(1,10)
var rand_int:int = randi_range(0,3)
var x:int
var y:int
if rand_int == 0:
x = randi_range(1,50)
y = randi_range(1,20)
GLOBALVARS.current_solution = x+y
GLOBALVARS.current_operand = "+"
elif rand_int == 1:
x = randi_range(1,50)
y = randi_range(1,20)
GLOBALVARS.current_solution = x-y
GLOBALVARS.current_operand = "-"
elif rand_int == 2:
x = randi_range(0,10) # simplify multiplication
y = randi_range(0,10)
x = randi_range(0,12) # simplify multiplication
y = randi_range(0,12)
GLOBALVARS.current_solution = x*y
GLOBALVARS.current_operand = "*"
elif rand_int == 3:
var fail:int = 0
var solution:int
GLOBALVARS.current_operand = "/"
while x%y != 0 and fail < 10000: # keep going til the remainder is 0
x = randi_range(1,10)
y = randi_range(1,10)
@warning_ignore('integer_division')
solution = floor(x/y)
fail+=1
GLOBALVARS.current_solution = solution
if fail >= 10000: # fallback to addition if no division problem can be found in 10000 loops
GLOBALVARS.current_operand = "+"
GLOBALVARS.current_solution = x+y
%QUESTION.text = "%s %s %s = " % [x,GLOBALVARS.current_operand,y]
%QUESTION.visible = true
@@ -103,7 +90,9 @@ func _physics_process(_delta: float) -> void:
if GLOBALVARS.selected_player == 0:
%ANSWER.editable = true
%ANSWER.grab_focus()
%ANSWER.edit()
else:
%ANSWER.release_focus()
%ANSWER.editable = false
if GLOBALVARS.seconds_left <= 0: