extends Node2D

var money_display = 0.0
var money_target = 0

onready var label = get_node("label")

var ticker_speed = 1


func incMoney():
	money_target += 135


func _process(delta):
	if updateMoney(delta):
		renderMoney()

func updateMoney(delta):
	if money_display == money_target:
		return false
	var diff = money_target - money_display
	if diff < 2:
		money_display = money_target
		return true
	
	delta = diff * delta * ticker_speed
	if abs(delta) >= abs(diff):
		money_display = money_target
		return true
		
	money_display += delta
	return true
	

func renderMoney():
	var v = round(money_display)
	var hundreds = floor(v / 100)
	var cents = v - hundreds*100
	
	var lblstr = str(hundreds).pad_zeros(2) + "." + str(cents).pad_zeros(2)
	
	label.text = lblstr








