From 4c5307a025ca857ab9fe2b1be6f4d79a0c523008 Mon Sep 17 00:00:00 2001 From: Jacob Janzen Date: Sat, 16 Nov 2024 08:23:23 -0600 Subject: minor refactor --- scenes/buy_n_sell.gd | 25 ------------------------- scenes/stockticker/Stock Ticker.tscn | 2 +- scenes/stockticker/buy_n_sell.gd | 25 +++++++++++++++++++++++++ scenes/stockticker/stonks.gd | 2 +- 4 files changed, 27 insertions(+), 27 deletions(-) delete mode 100644 scenes/buy_n_sell.gd create mode 100644 scenes/stockticker/buy_n_sell.gd (limited to 'scenes') diff --git a/scenes/buy_n_sell.gd b/scenes/buy_n_sell.gd deleted file mode 100644 index be0e777..0000000 --- a/scenes/buy_n_sell.gd +++ /dev/null @@ -1,25 +0,0 @@ -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/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 -- cgit v1.2.3