summaryrefslogtreecommitdiff
path: root/scenes/stockticker
diff options
context:
space:
mode:
authorZoey Kitt <zoey.kitt@outlook.com>2024-11-16 17:18:21 -0600
committerZoey Kitt <zoey.kitt@outlook.com>2024-11-16 17:18:21 -0600
commit98c0e0e97e0f01a28ad55873da44e3aa586c3424 (patch)
treeb74466593ec729ef7630b0f4ac2dce31e9b3ba2f /scenes/stockticker
parent9ab6f6e2093038a7f79c6321fda8ad44bd99347b (diff)
Make stonk window shake upon bankruptcy
Diffstat (limited to 'scenes/stockticker')
-rw-r--r--scenes/stockticker/Stock Ticker.tscn18
-rw-r--r--scenes/stockticker/stonks.gd4
2 files changed, 15 insertions, 7 deletions
diff --git a/scenes/stockticker/Stock Ticker.tscn b/scenes/stockticker/Stock Ticker.tscn
index 16e8176..cdd12c8 100644
--- a/scenes/stockticker/Stock Ticker.tscn
+++ b/scenes/stockticker/Stock Ticker.tscn
@@ -1,9 +1,10 @@
-[gd_scene load_steps=12 format=3 uid="uid://g2veoq55y14i"]
+[gd_scene load_steps=13 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"]
+[ext_resource type="Script" path="res://libs/shake_pivot.gd" id="4_ofsrv"]
[ext_resource type="Texture2D" uid="uid://vie3nmimge1t" path="res://scenes/stockticker/BuyButton.png" id="5_mpf30"]
[ext_resource type="Texture2D" uid="uid://dvidbk3clx6dn" path="res://scenes/stockticker/BuyButtonPressed.png" id="6_styy2"]
[ext_resource type="Texture2D" uid="uid://dw8wpd47me7wu" path="res://scenes/stockticker/SellButton.png" id="7_h6hir"]
@@ -27,6 +28,16 @@ autostart = true
[node name="Stonks" type="Node2D" parent="."]
script = ExtResource("2_pan4m")
+[node name="ShakePivot" type="Node2D" parent="Stonks"]
+script = ExtResource("4_ofsrv")
+NOISE_SHAKE_STRENGTH = 30.0
+SHAKE_DECAY_RATE = 5.0
+
+[node name="StonkWindow" type="Sprite2D" parent="Stonks/ShakePivot"]
+position = Vector2(582, 205)
+scale = Vector2(1062.25, 337)
+texture = ExtResource("1_wbfee")
+
[node name="SellButton" type="TextureButton" parent="Stonks"]
offset_left = 439.0
offset_top = 565.0
@@ -35,11 +46,6 @@ offset_bottom = 694.0
texture_normal = ExtResource("7_h6hir")
texture_pressed = ExtResource("8_essj7")
-[node name="StonkWindow" type="Sprite2D" parent="Stonks"]
-position = Vector2(582, 205)
-scale = Vector2(1062.25, 337)
-texture = ExtResource("1_wbfee")
-
[node name="TopLine" type="Line2D" parent="Stonks"]
points = PackedVector2Array(50, 60, 1000, 60)
width = 1.0
diff --git a/scenes/stockticker/stonks.gd b/scenes/stockticker/stonks.gd
index cb556f4..5cb0ab4 100644
--- a/scenes/stockticker/stonks.gd
+++ b/scenes/stockticker/stonks.gd
@@ -20,7 +20,7 @@ var darksouls_text: Label
var price_history = []
var base_pos_mult = 0.5 # no size limit
-var base_neg_mult = 0.5 # probably keep this below 1
+var base_neg_mult = 100.5 # probably keep this below 1
var hype_mult = 1.0
var hype_decr = 0.1
@@ -71,6 +71,7 @@ func draw_stonks(minval: Big, maxval: Big) -> void:
var pos = Vector2(x_pos, y_pos)
stonks.add_point(pos, index)
index += 1
+
func get_min_price() -> Big:
var minval = Big.new(-1)
@@ -136,6 +137,7 @@ func _on_timer_timeout() -> void:
shares = 0
shares_label.text = "Shares\nHeld:%d" % shares
$AudioStreamPlayer.play()
+ $ShakePivot.shake()
if len(price_history) >= MAX_PRICES:
price_history.pop_front()