summaryrefslogtreecommitdiff
path: root/scenes/main.gd
blob: b20524bae1549e5ce40b5c525be19cdef057e0b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
extends Node2D

var net_worth: Big

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	_on_microgame_spawn_timer_timeout()
	net_worth = Big.new(1000)
	
	var window = get_window()
	window.position = Vector2(450, 360)
	window.size = Vector2(500, 300)

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	# The most important functionality
	if Input.is_action_just_pressed("G"):
		$Meow.play()
		
	$Score.text = "Net worth: $%s" % net_worth.toString()


func _on_microgame_spawn_timer_timeout() -> void:
	print("WAAAHAHAHA MICROGAMES")
	
	# Spawn a microgame window
	var window_scene = preload("res://scenes/microgames/ad/ad_window.tscn")
	var window_instance = window_scene.instantiate()
	add_child(window_instance)
	
	# Randomize window position
	var screen_size = DisplayServer.screen_get_size()
	var window_x = randi_range(0, screen_size.x - window_instance.size.x)
	var window_y = randi_range(0, screen_size.y - window_instance.size.y)
	window_instance.position = Vector2(window_x, window_y)
	
	# Connect signals
	window_instance.win.connect(_on_microgame_win)
	

func _on_microgame_win(window: MicrogameWindow):
	print("yay")


func _on_stock_ticker_buy(amount: Variant) -> void:
	net_worth = net_worth.minus(amount)


func _on_stock_ticker_sell(amount: Variant) -> void:
	net_worth = net_worth.plus(amount)