extends Node

var hit
var caestus = 300
var maxcae = 300
var rng = 0
var ready = false
var breaking = 0
var gamend = false
var hitnum = 0
var expon = 0.04
var score = 1
var gamestart = false
var phase = 1

func _randomize_it():
	rng = randi()%6 +1
	
	
func _wait():
	if caestus <= 0:
		ready = true
		caestus = maxcae
	else:
		caestus = caestus - 1
		ready = false
	
		
		
func _ready():
	randomize()
	rng = 1
	print (rng)
	

func _process(delta):
	if gamestart == true:
		_wait()
		if ready == true:
			_randomize_it()	
			print (rng)
			
		if hitnum == 4 or Input.is_action_just_pressed("ui_cancel"):
			gamend = true
			get_tree().change_scene("GameOver.tscn")
			breaking = 0
			gamestart = false

		if maxcae >= 100:
			maxcae = maxcae - expon
			print (maxcae)
		if maxcae == 250:
			expon = 0.06
		if maxcae == 200:
			expon = 0.09
		if maxcae == 150:
			expon = 0.15
		else: 
			phase = 2