summaryrefslogtreecommitdiff
path: root/scenes/score_window/score_window.gd
diff options
context:
space:
mode:
authorZoey Kitt <zoey.kitt@outlook.com>2024-11-17 15:51:37 -0600
committerZoey Kitt <zoey.kitt@outlook.com>2024-11-17 15:51:37 -0600
commit03efa21bae32c16a7028275b3914fb0bf35a99a0 (patch)
tree0b71e62b6bfe73d7a64f47b9081e5056077c9d5b /scenes/score_window/score_window.gd
parent4fc8ff1304191ed75efc4aca6d5102792a09e96c (diff)
parent67371be0130f40cd9108ea50a65092d390c7d305 (diff)
Merge branch 'main' into clippette-dialogue
Diffstat (limited to 'scenes/score_window/score_window.gd')
-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()