summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scenes/main.gd12
-rw-r--r--scenes/main.tscn12
-rw-r--r--scenes/stockticker/Stock Ticker.tscn6
-rw-r--r--scenes/stockticker/stonks.gd7
-rw-r--r--scenes/stockticker/transactions.gd17
5 files changed, 49 insertions, 5 deletions
diff --git a/scenes/main.gd b/scenes/main.gd
index e5dedb8..c984f43 100644
--- a/scenes/main.gd
+++ b/scenes/main.gd
@@ -1,9 +1,11 @@
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)
# Called every frame. 'delta' is the elapsed time since the previous frame.
@@ -11,6 +13,8 @@ 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:
@@ -33,3 +37,11 @@ func _on_microgame_spawn_timer_timeout() -> void:
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)
diff --git a/scenes/main.tscn b/scenes/main.tscn
index 3dd15c9..c2c58b1 100644
--- a/scenes/main.tscn
+++ b/scenes/main.tscn
@@ -1,10 +1,11 @@
-[gd_scene load_steps=4 format=3 uid="uid://d06d1vihf2oqp"]
+[gd_scene load_steps=5 format=3 uid="uid://d06d1vihf2oqp"]
[ext_resource type="Texture2D" uid="uid://b03ygtrwha22g" path="res://taytay/IMG_5199.jpeg" id="1_o2s48"]
[ext_resource type="Script" path="res://scenes/main.gd" id="1_y7a0r"]
[ext_resource type="AudioStream" uid="uid://wtoxhk0tf8ev" path="res://funny_sounds/Cat Meow - Minecraft Sound Effect (HD).mp3" id="3_gatxj"]
+[ext_resource type="PackedScene" uid="uid://g2veoq55y14i" path="res://scenes/stockticker/Stock Ticker.tscn" id="4_0ankd"]
-[node name="Node2D" type="Node2D"]
+[node name="Node2D2" type="Node2D"]
script = ExtResource("1_y7a0r")
[node name="Sprite2D" type="Sprite2D" parent="."]
@@ -25,4 +26,11 @@ autostart = true
[node name="Meow" type="AudioStreamPlayer" parent="."]
stream = ExtResource("3_gatxj")
+[node name="Window" type="Window" parent="."]
+size = Vector2i(1280, 720)
+
+[node name="Stock ticker" parent="Window" instance=ExtResource("4_0ankd")]
+
[connection signal="timeout" from="Microgame spawn timer" to="." method="_on_microgame_spawn_timer_timeout"]
+[connection signal="buy" from="Window/Stock ticker" to="." method="_on_stock_ticker_buy"]
+[connection signal="sell" from="Window/Stock ticker" to="." method="_on_stock_ticker_sell"]
diff --git a/scenes/stockticker/Stock Ticker.tscn b/scenes/stockticker/Stock Ticker.tscn
index 01388d0..6c0e1fb 100644
--- a/scenes/stockticker/Stock Ticker.tscn
+++ b/scenes/stockticker/Stock Ticker.tscn
@@ -1,5 +1,6 @@
-[gd_scene load_steps=10 format=3 uid="uid://g2veoq55y14i"]
+[gd_scene load_steps=11 format=3 uid="uid://g2veoq55y14i"]
+[ext_resource type="Script" path="res://scenes/stockticker/transactions.gd" id="1_1gmdn"]
[ext_resource type="Texture2D" uid="uid://voruypgyi77e" path="res://scenes/stockticker/UI-Background-Colour.png" id="1_wbfee"]
[ext_resource type="Script" path="res://scenes/stockticker/stonks.gd" id="2_pan4m"]
[ext_resource type="Theme" uid="uid://ve18rbkeiwti" path="res://UI/text.tres" id="3_dv3dr"]
@@ -11,6 +12,7 @@
[ext_resource type="Texture2D" uid="uid://dpp7abs35p6i5" path="res://scenes/stockticker/fishe/gar.png" id="9_bv8iw"]
[node name="Node2D" type="Node2D"]
+script = ExtResource("1_1gmdn")
[node name="Background" type="Sprite2D" parent="."]
modulate = Color(0.796078, 0.796078, 0.796078, 1)
@@ -150,5 +152,7 @@ theme_override_font_sizes/font_size = 82
text = "GAR"
[connection signal="timeout" from="Timer" to="Stonks" method="_on_timer_timeout"]
+[connection signal="buy" from="Stonks" to="." method="_on_stonks_buy"]
+[connection signal="sell" from="Stonks" to="." method="_on_stonks_sell"]
[connection signal="button_up" from="Stonks/SellButton" to="Stonks" method="_on_sell_button_button_up"]
[connection signal="button_up" from="Stonks/BuyButton" to="Stonks" method="_on_buy_button_button_up"]
diff --git a/scenes/stockticker/stonks.gd b/scenes/stockticker/stonks.gd
index 508fb82..1279382 100644
--- a/scenes/stockticker/stonks.gd
+++ b/scenes/stockticker/stonks.gd
@@ -1,5 +1,8 @@
extends Node2D
+signal buy(amount)
+signal sell(amount)
+
const MAX_PRICES = 15
const Y_START = 60
@@ -125,8 +128,6 @@ func _on_timer_timeout() -> void:
new_price = new_price.times(mult)
if new_price.isLessThan(1) or new_price.toString()[0] == '-':
- print(bailout_counter)
- print(new_price.toString())
if bailout_counter == 0:
darksouls_background.visible = true
darksouls_text.visible = true
@@ -158,6 +159,7 @@ func _on_buy_button_button_up() -> void:
shares += 1
shares_label.text = "Shares\nHeld:%d" % shares
hype_mult += hype_inc
+ buy.emit(prev_price)
func _on_sell_button_button_up() -> void:
@@ -165,3 +167,4 @@ func _on_sell_button_button_up() -> void:
shares -= 1
shares_label.text = "Shares\nHeld:%d" % shares
panic_mult += panic_inc
+ sell.emit(prev_price)
diff --git a/scenes/stockticker/transactions.gd b/scenes/stockticker/transactions.gd
new file mode 100644
index 0000000..daff901
--- /dev/null
+++ b/scenes/stockticker/transactions.gd
@@ -0,0 +1,17 @@
+extends Node2D
+
+## I need the signal-emitter to be the root node of this scene and when I
+## tried to just move the script it broke the stonk line so here this is I guess lol
+
+signal buy(amount: Variant)
+signal sell(amount: Variant)
+
+func _on_stonks_buy(amount: Variant) -> void:
+ print("-$%s" % amount.toString())
+ buy.emit(amount)
+
+
+func _on_stonks_sell(amount: Variant) -> void:
+ print("+$%s" % amount.toString())
+ sell.emit(amount)
+