summaryrefslogtreecommitdiff
path: root/scenes/score_window
diff options
context:
space:
mode:
authorJacob Janzen <jacob.a.s.janzen@gmail.com>2024-11-17 15:25:49 -0600
committerJacob Janzen <jacob.a.s.janzen@gmail.com>2024-11-17 15:25:49 -0600
commitf1c476b3f1bf2ed0e1e64a45e21a8d3918ca5354 (patch)
treed89f7a3bdacc52f353802f5642cb9bcbff5ba936 /scenes/score_window
parentdef01c3c3753826ab6da28996b8bff2c36e6fba8 (diff)
score insanity
Diffstat (limited to 'scenes/score_window')
-rw-r--r--scenes/score_window/score_window.gd51
1 files changed, 48 insertions, 3 deletions
diff --git a/scenes/score_window/score_window.gd b/scenes/score_window/score_window.gd
index d6c465d..01b0647 100644
--- a/scenes/score_window/score_window.gd
+++ b/scenes/score_window/score_window.gd
@@ -4,6 +4,45 @@ signal donezo
var net_worth: Big
+func lose_money(value: Big):
+ var strength
+ if value.isGreaterThan(Big.new(2, 300)):
+ strength = 2e300
+ else:
+ strength = float(value.toString())
+ $ShakePivot2.shake_strength = strength
+ $ShakePivot.shake_strength = strength
+
+ $ShakePivot.visible = true
+ $ShakePivot/Label.text = "-$%s" % value.toString()
+ $ShakePivot/Label.add_theme_color_override("font_color", Color.RED)
+ $ShakePivot.shake()
+ net_worth.minusEquals(value)
+
+ $ShakePivot/Timer.start()
+
+ $ShakePivot2.shake()
+
+func get_money(value: Big):
+ var strength
+ if value.isGreaterThan(Big.new(2, 300)):
+ strength = 2e300
+ else:
+ strength = float(value.toString())
+ $ShakePivot2.shake_strength = strength
+ $ShakePivot.shake_strength = strength
+
+ $ShakePivot.visible = true
+ $ShakePivot/Label.text = "+$%s" % value.toString()
+ $ShakePivot/Label.add_theme_color_override("font_color", Color.WEB_GREEN)
+ $ShakePivot.shake()
+ net_worth.plusEquals(value)
+
+ $ShakePivot/Timer.start()
+
+ $ShakePivot2.shake()
+
+
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
net_worth = Big.new(1000)
@@ -15,15 +54,21 @@ func _ready() -> void:
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
- $Score.text = "Net worth: \n$%s" % net_worth.toString()
+ $ShakePivot2/Score.text = "Net worth: \n$%s" % net_worth.toString()
if net_worth.isLessThan(Big.new(0)) or net_worth.toString()[0] == '-':
donezo.emit()
func _on_stock_ticker_buy(amount: Variant) -> void:
- net_worth = net_worth.minus(amount)
+ lose_money(amount)
func _on_stock_ticker_sell(amount: Variant) -> void:
- net_worth = net_worth.plus(amount)
+ get_money(amount)
+
+
+func _on_timer_timeout() -> void:
+ $ShakePivot.visible = false
+
+ $ShakePivot/Timer.stop()