Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

For those who cannot see the main code on code google docs, here it is here

extends Control

#var questions = ["what is 20 * 100", "what is 50 * 100", "what is 60 * 50"]

var current_question = {}

onready var player_text = $VBoxContainer/HBoxContainer/playertext

onready var display_text = $VBoxContainer/displaytext

var attempets : int = 3

var right_answers : int = 0

func _ready():

select_question_and_answer()

func select_question_and_answer():

randomize()

var questions = $Questions.get_child_count()

var selected_question = randi() % questions

current_question.questions = $Questions.get_child(selected_question).questions

current_question.answer = $Questions.get_child(selected_question).answer

display_text.text = current_question.questions

func _on_playertext_text_entered(new_text):

check_answer()

func _on_TextureButton_pressed():

check_answer()

func check_answer():

if player_text.text == current_question.answer:

right()

select_question_and_answer()

$AudioStreamPlayer.stream = load("res://Recording (4).ogg")

$AudioStreamPlayer.play()

else:

attempts()

select_question_and_answer()

$AudioStreamPlayer.stream = load("res://Recording (3).ogg")

$AudioStreamPlayer.play()

player_text.clear()

func right():

right_answers += 1

check_end_game()

func check_end_game():

if right_answers >= 3:

get_tree().change_scene("res://You got the Right answer.tscn")

func attempts():

attempets -= 1

right_answers = 0

if attempets <= 0:

get_tree().change_scene("res://MainMenu.tscn")

func _process(delta):

$Riths.text = str(right_answers)

$Wrongs.text = str(attempets)