diff options
Diffstat (limited to 'scenes/stockticker')
-rw-r--r-- | scenes/stockticker/Stock Ticker.tscn | 2 | ||||
-rw-r--r-- | scenes/stockticker/buy_n_sell.gd | 25 | ||||
-rw-r--r-- | scenes/stockticker/stonks.gd | 2 |
3 files changed, 27 insertions, 2 deletions
diff --git a/scenes/stockticker/Stock Ticker.tscn b/scenes/stockticker/Stock Ticker.tscn index 122bdfc..9352ef8 100644 --- a/scenes/stockticker/Stock Ticker.tscn +++ b/scenes/stockticker/Stock Ticker.tscn @@ -3,7 +3,7 @@ [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://scenes/buy_n_sell.gd" id="4_l8sru"] +[ext_resource type="Script" path="res://scenes/stockticker/buy_n_sell.gd" id="4_l8sru"] [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"] diff --git a/scenes/stockticker/buy_n_sell.gd b/scenes/stockticker/buy_n_sell.gd new file mode 100644 index 0000000..be0e777 --- /dev/null +++ b/scenes/stockticker/buy_n_sell.gd @@ -0,0 +1,25 @@ +extends Node2D + +var stonks = 0 + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + var label = $"Shares Held Label" + label.text = "Shares\nHeld:%d" % stonks + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass + + +func _on_buy_button_button_up() -> void: + if stonks < 100: + stonks += 1 + var label = $"Shares Held Label" + label.text = "Shares\nHeld:%d" % stonks + +func _on_sell_button_button_up() -> void: + if stonks > 0: + stonks -= 1 + var label = $"Shares Held Label" + label.text = "Shares\nHeld:%d" % stonks diff --git a/scenes/stockticker/stonks.gd b/scenes/stockticker/stonks.gd index 9b7b845..fefc340 100644 --- a/scenes/stockticker/stonks.gd +++ b/scenes/stockticker/stonks.gd @@ -18,7 +18,7 @@ func _ready() -> void: label.text = "Price:\n$%f" % start_val price_history.push_front(start_val) - + # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: pass |