From 29983fef392ab37c6ccbddab28efe3d97746b1fa Mon Sep 17 00:00:00 2001 From: Jacob Janzen Date: Fri, 15 Nov 2024 18:31:43 -0600 Subject: partially done --- ButtonBase.xcf | Bin 0 -> 11607 bytes ButtonBasePressed.xcf | Bin 0 -> 14164 bytes BuyButton.png | Bin 0 -> 1344 bytes BuyButton.png.import | 34 ++++++++++++++++++++++++++++++++++ BuyButtonPressed.png | Bin 0 -> 1357 bytes BuyButtonPressed.png.import | 34 ++++++++++++++++++++++++++++++++++ SellButton.png | Bin 0 -> 1462 bytes SellButton.png.import | 34 ++++++++++++++++++++++++++++++++++ SellButtonPressed.png | Bin 0 -> 1475 bytes SellButtonPressed.png.import | 34 ++++++++++++++++++++++++++++++++++ Stock Ticker.tscn | 33 +++++++++++++++++++++++++++++++++ UI-Background-Colour.png | Bin 0 -> 546 bytes UI-Background-Colour.png.import | 34 ++++++++++++++++++++++++++++++++++ UI-Background-Colour.xcf | Bin 0 -> 687 bytes buy_button.gd | 11 +++++++++++ 15 files changed, 214 insertions(+) create mode 100644 ButtonBase.xcf create mode 100644 ButtonBasePressed.xcf create mode 100644 BuyButton.png create mode 100644 BuyButton.png.import create mode 100644 BuyButtonPressed.png create mode 100644 BuyButtonPressed.png.import create mode 100644 SellButton.png create mode 100644 SellButton.png.import create mode 100644 SellButtonPressed.png create mode 100644 SellButtonPressed.png.import create mode 100644 Stock Ticker.tscn create mode 100644 UI-Background-Colour.png create mode 100644 UI-Background-Colour.png.import create mode 100644 UI-Background-Colour.xcf create mode 100644 buy_button.gd diff --git a/ButtonBase.xcf b/ButtonBase.xcf new file mode 100644 index 0000000..4c3e2f4 Binary files /dev/null and b/ButtonBase.xcf differ diff --git a/ButtonBasePressed.xcf b/ButtonBasePressed.xcf new file mode 100644 index 0000000..1740221 Binary files /dev/null and b/ButtonBasePressed.xcf differ diff --git a/BuyButton.png b/BuyButton.png new file mode 100644 index 0000000..8b35891 Binary files /dev/null and b/BuyButton.png differ diff --git a/BuyButton.png.import b/BuyButton.png.import new file mode 100644 index 0000000..0aab002 --- /dev/null +++ b/BuyButton.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dcsaf0afsn76" +path="res://.godot/imported/BuyButton.png-1c1b0b8028f98a92082f37a9e5446c45.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://BuyButton.png" +dest_files=["res://.godot/imported/BuyButton.png-1c1b0b8028f98a92082f37a9e5446c45.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/BuyButtonPressed.png b/BuyButtonPressed.png new file mode 100644 index 0000000..c028e5a Binary files /dev/null and b/BuyButtonPressed.png differ diff --git a/BuyButtonPressed.png.import b/BuyButtonPressed.png.import new file mode 100644 index 0000000..fc7c10e --- /dev/null +++ b/BuyButtonPressed.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ckd5ppryxuuum" +path="res://.godot/imported/BuyButtonPressed.png-52bdb0fc073bf2229b077e5e2c770886.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://BuyButtonPressed.png" +dest_files=["res://.godot/imported/BuyButtonPressed.png-52bdb0fc073bf2229b077e5e2c770886.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/SellButton.png b/SellButton.png new file mode 100644 index 0000000..55818d4 Binary files /dev/null and b/SellButton.png differ diff --git a/SellButton.png.import b/SellButton.png.import new file mode 100644 index 0000000..45ff4e1 --- /dev/null +++ b/SellButton.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://du8xy83ve1lm7" +path="res://.godot/imported/SellButton.png-a940d0a74daec8a650b2d33b6c2a6925.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://SellButton.png" +dest_files=["res://.godot/imported/SellButton.png-a940d0a74daec8a650b2d33b6c2a6925.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/SellButtonPressed.png b/SellButtonPressed.png new file mode 100644 index 0000000..3a3b2ee Binary files /dev/null and b/SellButtonPressed.png differ diff --git a/SellButtonPressed.png.import b/SellButtonPressed.png.import new file mode 100644 index 0000000..de8adba --- /dev/null +++ b/SellButtonPressed.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://qgsvhv16ghwf" +path="res://.godot/imported/SellButtonPressed.png-b273be20baf4b6e42e2e343931e3265f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://SellButtonPressed.png" +dest_files=["res://.godot/imported/SellButtonPressed.png-b273be20baf4b6e42e2e343931e3265f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Stock Ticker.tscn b/Stock Ticker.tscn new file mode 100644 index 0000000..425adef --- /dev/null +++ b/Stock Ticker.tscn @@ -0,0 +1,33 @@ +[gd_scene load_steps=7 format=3 uid="uid://by18nc16h76y0"] + +[ext_resource type="Texture2D" uid="uid://c6ed1ks2h58s7" path="res://UI-Background-Colour.png" id="1_1j58d"] +[ext_resource type="Texture2D" uid="uid://dcsaf0afsn76" path="res://BuyButton.png" id="2_8qhml"] +[ext_resource type="Texture2D" uid="uid://ckd5ppryxuuum" path="res://BuyButtonPressed.png" id="3_4kqfi"] +[ext_resource type="Script" path="res://buy_button.gd" id="4_lfir0"] +[ext_resource type="Texture2D" uid="uid://du8xy83ve1lm7" path="res://SellButton.png" id="5_salj8"] +[ext_resource type="Texture2D" uid="uid://qgsvhv16ghwf" path="res://SellButtonPressed.png" id="6_ifhss"] + +[node name="Node2D" type="Node2D"] + +[node name="Background" type="Sprite2D" parent="."] +modulate = Color(0.796078, 0.796078, 0.796078, 1) +position = Vector2(576.25, 323.75) +scale = Vector2(1153.5, 648.5) +texture = ExtResource("1_1j58d") + +[node name="BuyButton" type="TextureButton" parent="."] +offset_left = 168.0 +offset_top = 450.0 +offset_right = 523.0 +offset_bottom = 579.0 +texture_normal = ExtResource("2_8qhml") +texture_pressed = ExtResource("3_4kqfi") +script = ExtResource("4_lfir0") + +[node name="TextureButton" type="TextureButton" parent="."] +offset_left = 649.0 +offset_top = 450.0 +offset_right = 1004.0 +offset_bottom = 579.0 +texture_normal = ExtResource("5_salj8") +texture_pressed = ExtResource("6_ifhss") diff --git a/UI-Background-Colour.png b/UI-Background-Colour.png new file mode 100644 index 0000000..ddec89e Binary files /dev/null and b/UI-Background-Colour.png differ diff --git a/UI-Background-Colour.png.import b/UI-Background-Colour.png.import new file mode 100644 index 0000000..82fde74 --- /dev/null +++ b/UI-Background-Colour.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c6ed1ks2h58s7" +path="res://.godot/imported/UI-Background-Colour.png-bb6018e92357421b80f76ef27985e968.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://UI-Background-Colour.png" +dest_files=["res://.godot/imported/UI-Background-Colour.png-bb6018e92357421b80f76ef27985e968.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/UI-Background-Colour.xcf b/UI-Background-Colour.xcf new file mode 100644 index 0000000..7704326 Binary files /dev/null and b/UI-Background-Colour.xcf differ diff --git a/buy_button.gd b/buy_button.gd new file mode 100644 index 0000000..474dd4c --- /dev/null +++ b/buy_button.gd @@ -0,0 +1,11 @@ +extends TextureButton + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass -- cgit v1.2.3 From 7059818b6fc7a1ce7a305b07ec3e5870ac31ec99 Mon Sep 17 00:00:00 2001 From: Jacob Janzen Date: Fri, 15 Nov 2024 19:15:35 -0600 Subject: add stock screen --- Stock Ticker.tscn | 102 ++++++++++++++++++++++++++++++++++++++++++----- stonks.gd | 15 +++++++ templeos_font.ttf | Bin 0 -> 84460 bytes templeos_font.ttf.import | 34 ++++++++++++++++ text.tres | 8 ++++ 5 files changed, 150 insertions(+), 9 deletions(-) create mode 100644 stonks.gd create mode 100644 templeos_font.ttf create mode 100644 templeos_font.ttf.import create mode 100644 text.tres diff --git a/Stock Ticker.tscn b/Stock Ticker.tscn index 425adef..3cc6378 100644 --- a/Stock Ticker.tscn +++ b/Stock Ticker.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=7 format=3 uid="uid://by18nc16h76y0"] +[gd_scene load_steps=9 format=3 uid="uid://by18nc16h76y0"] [ext_resource type="Texture2D" uid="uid://c6ed1ks2h58s7" path="res://UI-Background-Colour.png" id="1_1j58d"] [ext_resource type="Texture2D" uid="uid://dcsaf0afsn76" path="res://BuyButton.png" id="2_8qhml"] @@ -6,6 +6,8 @@ [ext_resource type="Script" path="res://buy_button.gd" id="4_lfir0"] [ext_resource type="Texture2D" uid="uid://du8xy83ve1lm7" path="res://SellButton.png" id="5_salj8"] [ext_resource type="Texture2D" uid="uid://qgsvhv16ghwf" path="res://SellButtonPressed.png" id="6_ifhss"] +[ext_resource type="Script" path="res://stonks.gd" id="7_ecbtd"] +[ext_resource type="Theme" uid="uid://dx1tiwi1lo7om" path="res://text.tres" id="7_rtyuw"] [node name="Node2D" type="Node2D"] @@ -16,18 +18,100 @@ scale = Vector2(1153.5, 648.5) texture = ExtResource("1_1j58d") [node name="BuyButton" type="TextureButton" parent="."] -offset_left = 168.0 -offset_top = 450.0 -offset_right = 523.0 -offset_bottom = 579.0 +offset_left = 54.0 +offset_top = 475.0 +offset_right = 409.0 +offset_bottom = 604.0 texture_normal = ExtResource("2_8qhml") texture_pressed = ExtResource("3_4kqfi") script = ExtResource("4_lfir0") [node name="TextureButton" type="TextureButton" parent="."] -offset_left = 649.0 -offset_top = 450.0 -offset_right = 1004.0 -offset_bottom = 579.0 +offset_left = 441.0 +offset_top = 477.0 +offset_right = 796.0 +offset_bottom = 606.0 texture_normal = ExtResource("5_salj8") texture_pressed = ExtResource("6_ifhss") + +[node name="Price Label" type="Label" parent="."] +offset_left = 387.0 +offset_top = 387.0 +offset_right = 1112.0 +offset_bottom = 452.0 +theme = ExtResource("7_rtyuw") +text = "Price: +$" + +[node name="Shares Held Label" type="Label" parent="."] +offset_left = 6.0 +offset_top = 390.0 +offset_right = 336.0 +offset_bottom = 421.0 +theme = ExtResource("7_rtyuw") +text = "Shares +Held:" + +[node name="Timer" type="Timer" parent="."] + +[node name="Node2D" type="Node2D" parent="."] +script = ExtResource("7_ecbtd") + +[node name="Sprite2D" type="Sprite2D" parent="Node2D"] +position = Vector2(582, 205) +scale = Vector2(1062.25, 337) +texture = ExtResource("1_1j58d") + +[node name="TopLine" type="Line2D" parent="Node2D"] +points = PackedVector2Array(50, 60, 1000, 60) +width = 1.0 +default_color = Color(0.458824, 0.458824, 0.458824, 1) + +[node name="MidLine" type="Line2D" parent="Node2D"] +position = Vector2(0, 1) +points = PackedVector2Array(50, 208, 1000, 208) +width = 1.0 +default_color = Color(0.458824, 0.458824, 0.458824, 1) + +[node name="BottomLine" type="Line2D" parent="Node2D"] +position = Vector2(0, -1) +points = PackedVector2Array(50, 356, 1000, 356) +width = 1.0 +default_color = Color(0.46, 0.46, 0.46, 1) + +[node name="Top" type="Label" parent="Node2D"] +offset_left = 1021.0 +offset_top = 58.0 +offset_right = 1114.0 +offset_bottom = 89.0 +theme = ExtResource("7_rtyuw") +theme_override_colors/font_color = Color(0.63, 0.63, 0.63, 1) +theme_override_font_sizes/font_size = 12 +text = "0" +horizontal_alignment = 1 + +[node name="Middle" type="Label" parent="Node2D"] +offset_left = 1022.0 +offset_top = 208.0 +offset_right = 1115.0 +offset_bottom = 239.0 +theme = ExtResource("7_rtyuw") +theme_override_colors/font_color = Color(0.63, 0.63, 0.63, 1) +theme_override_font_sizes/font_size = 12 +text = "0" +horizontal_alignment = 1 + +[node name="Bottom" type="Label" parent="Node2D"] +offset_left = 1022.0 +offset_top = 356.0 +offset_right = 1115.0 +offset_bottom = 387.0 +theme = ExtResource("7_rtyuw") +theme_override_colors/font_color = Color(0.63, 0.63, 0.63, 1) +theme_override_font_sizes/font_size = 12 +text = "0" +horizontal_alignment = 1 + +[node name="Stonks" type="Line2D" parent="Node2D"] + +[connection signal="timeout" from="Timer" to="Node2D/Sprite2D" method="_on_timer_timeout"] diff --git a/stonks.gd b/stonks.gd new file mode 100644 index 0000000..a853edf --- /dev/null +++ b/stonks.gd @@ -0,0 +1,15 @@ +extends Node2D + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass + + +func _on_timer_timeout() -> void: + pass # Replace with function body. diff --git a/templeos_font.ttf b/templeos_font.ttf new file mode 100644 index 0000000..517ad2a Binary files /dev/null and b/templeos_font.ttf differ diff --git a/templeos_font.ttf.import b/templeos_font.ttf.import new file mode 100644 index 0000000..bcfd2cb --- /dev/null +++ b/templeos_font.ttf.import @@ -0,0 +1,34 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://3e6fuwt5giyn" +path="res://.godot/imported/templeos_font.ttf-3df095bd9bdc9ad857a60b3667a243a3.fontdata" + +[deps] + +source_file="res://templeos_font.ttf" +dest_files=["res://.godot/imported/templeos_font.ttf-3df095bd9bdc9ad857a60b3667a243a3.fontdata"] + +[params] + +Rendering=null +antialiasing=1 +generate_mipmaps=false +disable_embedded_bitmaps=true +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +allow_system_fallback=true +force_autohinter=false +hinting=1 +subpixel_positioning=1 +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[] +language_support={} +script_support={} +opentype_features={} diff --git a/text.tres b/text.tres new file mode 100644 index 0000000..33c1755 --- /dev/null +++ b/text.tres @@ -0,0 +1,8 @@ +[gd_resource type="Theme" load_steps=2 format=3 uid="uid://dx1tiwi1lo7om"] + +[ext_resource type="FontFile" uid="uid://3e6fuwt5giyn" path="res://templeos_font.ttf" id="1_3hk8o"] + +[resource] +Label/colors/font_color = Color(0, 0, 0, 1) +Label/font_sizes/font_size = 30 +Label/fonts/font = ExtResource("1_3hk8o") -- cgit v1.2.3 From 4f5d964c6890f3281e8673905ab0158dca0ebcf8 Mon Sep 17 00:00:00 2001 From: Jacob Janzen Date: Fri, 15 Nov 2024 19:55:15 -0600 Subject: complete stock mostly --- Stock Ticker.tscn | 101 ++++++++++++++++++++++++++++-------------------------- buy_button.gd | 11 ------ buy_n_sell.gd | 25 ++++++++++++++ stonks.gd | 41 ++++++++++++++++++++-- text.tres | 2 +- 5 files changed, 118 insertions(+), 62 deletions(-) delete mode 100644 buy_button.gd create mode 100644 buy_n_sell.gd diff --git a/Stock Ticker.tscn b/Stock Ticker.tscn index 3cc6378..ad5bfc3 100644 --- a/Stock Ticker.tscn +++ b/Stock Ticker.tscn @@ -1,13 +1,13 @@ -[gd_scene load_steps=9 format=3 uid="uid://by18nc16h76y0"] +[gd_scene load_steps=9 format=3 uid="uid://g2veoq55y14i"] [ext_resource type="Texture2D" uid="uid://c6ed1ks2h58s7" path="res://UI-Background-Colour.png" id="1_1j58d"] [ext_resource type="Texture2D" uid="uid://dcsaf0afsn76" path="res://BuyButton.png" id="2_8qhml"] [ext_resource type="Texture2D" uid="uid://ckd5ppryxuuum" path="res://BuyButtonPressed.png" id="3_4kqfi"] -[ext_resource type="Script" path="res://buy_button.gd" id="4_lfir0"] +[ext_resource type="Script" path="res://buy_n_sell.gd" id="4_312bm"] [ext_resource type="Texture2D" uid="uid://du8xy83ve1lm7" path="res://SellButton.png" id="5_salj8"] [ext_resource type="Texture2D" uid="uid://qgsvhv16ghwf" path="res://SellButtonPressed.png" id="6_ifhss"] [ext_resource type="Script" path="res://stonks.gd" id="7_ecbtd"] -[ext_resource type="Theme" uid="uid://dx1tiwi1lo7om" path="res://text.tres" id="7_rtyuw"] +[ext_resource type="Theme" uid="uid://cte81ypvmrsrv" path="res://text.tres" id="7_rtyuw"] [node name="Node2D" type="Node2D"] @@ -17,69 +17,35 @@ position = Vector2(576.25, 323.75) scale = Vector2(1153.5, 648.5) texture = ExtResource("1_1j58d") -[node name="BuyButton" type="TextureButton" parent="."] -offset_left = 54.0 -offset_top = 475.0 -offset_right = 409.0 -offset_bottom = 604.0 -texture_normal = ExtResource("2_8qhml") -texture_pressed = ExtResource("3_4kqfi") -script = ExtResource("4_lfir0") - -[node name="TextureButton" type="TextureButton" parent="."] -offset_left = 441.0 -offset_top = 477.0 -offset_right = 796.0 -offset_bottom = 606.0 -texture_normal = ExtResource("5_salj8") -texture_pressed = ExtResource("6_ifhss") - -[node name="Price Label" type="Label" parent="."] -offset_left = 387.0 -offset_top = 387.0 -offset_right = 1112.0 -offset_bottom = 452.0 -theme = ExtResource("7_rtyuw") -text = "Price: -$" - -[node name="Shares Held Label" type="Label" parent="."] -offset_left = 6.0 -offset_top = 390.0 -offset_right = 336.0 -offset_bottom = 421.0 -theme = ExtResource("7_rtyuw") -text = "Shares -Held:" - [node name="Timer" type="Timer" parent="."] +autostart = true -[node name="Node2D" type="Node2D" parent="."] +[node name="Stonks" type="Node2D" parent="."] script = ExtResource("7_ecbtd") -[node name="Sprite2D" type="Sprite2D" parent="Node2D"] +[node name="Sprite2D" type="Sprite2D" parent="Stonks"] position = Vector2(582, 205) scale = Vector2(1062.25, 337) texture = ExtResource("1_1j58d") -[node name="TopLine" type="Line2D" parent="Node2D"] +[node name="TopLine" type="Line2D" parent="Stonks"] points = PackedVector2Array(50, 60, 1000, 60) width = 1.0 default_color = Color(0.458824, 0.458824, 0.458824, 1) -[node name="MidLine" type="Line2D" parent="Node2D"] +[node name="MidLine" type="Line2D" parent="Stonks"] position = Vector2(0, 1) points = PackedVector2Array(50, 208, 1000, 208) width = 1.0 default_color = Color(0.458824, 0.458824, 0.458824, 1) -[node name="BottomLine" type="Line2D" parent="Node2D"] +[node name="BottomLine" type="Line2D" parent="Stonks"] position = Vector2(0, -1) points = PackedVector2Array(50, 356, 1000, 356) width = 1.0 default_color = Color(0.46, 0.46, 0.46, 1) -[node name="Top" type="Label" parent="Node2D"] +[node name="Top" type="Label" parent="Stonks"] offset_left = 1021.0 offset_top = 58.0 offset_right = 1114.0 @@ -90,7 +56,7 @@ theme_override_font_sizes/font_size = 12 text = "0" horizontal_alignment = 1 -[node name="Middle" type="Label" parent="Node2D"] +[node name="Middle" type="Label" parent="Stonks"] offset_left = 1022.0 offset_top = 208.0 offset_right = 1115.0 @@ -101,7 +67,7 @@ theme_override_font_sizes/font_size = 12 text = "0" horizontal_alignment = 1 -[node name="Bottom" type="Label" parent="Node2D"] +[node name="Bottom" type="Label" parent="Stonks"] offset_left = 1022.0 offset_top = 356.0 offset_right = 1115.0 @@ -112,6 +78,45 @@ theme_override_font_sizes/font_size = 12 text = "0" horizontal_alignment = 1 -[node name="Stonks" type="Line2D" parent="Node2D"] +[node name="Stonks" type="Line2D" parent="Stonks"] + +[node name="Price Label" type="Label" parent="Stonks"] +offset_left = 387.0 +offset_top = 387.0 +offset_right = 1112.0 +offset_bottom = 452.0 +theme = ExtResource("7_rtyuw") +text = "Price: +$" + +[node name="BuyNSell" type="Node2D" parent="."] +script = ExtResource("4_312bm") + +[node name="BuyButton" type="TextureButton" parent="BuyNSell"] +offset_left = 54.0 +offset_top = 475.0 +offset_right = 409.0 +offset_bottom = 604.0 +texture_normal = ExtResource("2_8qhml") +texture_pressed = ExtResource("3_4kqfi") + +[node name="SellButton" type="TextureButton" parent="BuyNSell"] +offset_left = 441.0 +offset_top = 477.0 +offset_right = 796.0 +offset_bottom = 606.0 +texture_normal = ExtResource("5_salj8") +texture_pressed = ExtResource("6_ifhss") + +[node name="Shares Held Label" type="Label" parent="BuyNSell"] +offset_left = 6.0 +offset_top = 390.0 +offset_right = 336.0 +offset_bottom = 455.0 +theme = ExtResource("7_rtyuw") +text = "Shares +Held:" -[connection signal="timeout" from="Timer" to="Node2D/Sprite2D" method="_on_timer_timeout"] +[connection signal="timeout" from="Timer" to="Stonks" method="_on_timer_timeout"] +[connection signal="button_up" from="BuyNSell/BuyButton" to="BuyNSell" method="_on_buy_button_button_up"] +[connection signal="button_up" from="BuyNSell/SellButton" to="BuyNSell" method="_on_sell_button_button_up"] diff --git a/buy_button.gd b/buy_button.gd deleted file mode 100644 index 474dd4c..0000000 --- a/buy_button.gd +++ /dev/null @@ -1,11 +0,0 @@ -extends TextureButton - - -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - pass # Replace with function body. - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - pass diff --git a/buy_n_sell.gd b/buy_n_sell.gd new file mode 100644 index 0000000..be0e777 --- /dev/null +++ b/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/stonks.gd b/stonks.gd index a853edf..9b7b845 100644 --- a/stonks.gd +++ b/stonks.gd @@ -1,9 +1,22 @@ extends Node2D +var price_history = [] +var max_prices = 15 +var max_up_multiplier = 2 +var max_down_multiplier = 2 +var bailout_counter = 0 +var bailout_time = 1 + +var bailout_price = 5 +var start_val = 5 +var prev_price = start_val # Called when the node enters the scene tree for the first time. func _ready() -> void: - pass # Replace with function body. + print(start_val) + var label = $"Price Label" + 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. @@ -12,4 +25,28 @@ func _process(delta: float) -> void: func _on_timer_timeout() -> void: - pass # Replace with function body. + var new_price = prev_price + + if prev_price <= 0: + if bailout_counter < bailout_time: + new_price = 0 + bailout_counter += 1 + else: + new_price = bailout_price + bailout_counter = 0 + elif randf() < 0.5: + new_price += 1 * max_up_multiplier * randf() + else: + new_price -= 1 * max_down_multiplier * randf() + + if new_price < 0: new_price = 0 + + if len(price_history) >= max_prices: + price_history.pop_front() + price_history.push_back(new_price) + prev_price = new_price + + var label = $"Price Label" + label.text = "Price:\n$%f" % new_price + + print(new_price) diff --git a/text.tres b/text.tres index 33c1755..a724622 100644 --- a/text.tres +++ b/text.tres @@ -1,4 +1,4 @@ -[gd_resource type="Theme" load_steps=2 format=3 uid="uid://dx1tiwi1lo7om"] +[gd_resource type="Theme" load_steps=2 format=3 uid="uid://cte81ypvmrsrv"] [ext_resource type="FontFile" uid="uid://3e6fuwt5giyn" path="res://templeos_font.ttf" id="1_3hk8o"] -- cgit v1.2.3 From 524bcdf6570b517d75d4b1617e7c09172fe3cde2 Mon Sep 17 00:00:00 2001 From: Jacob Janzen Date: Fri, 15 Nov 2024 19:59:53 -0600 Subject: refactor --- BuyButton.png | Bin 1344 -> 0 bytes BuyButton.png.import | 34 ------ BuyButtonPressed.png | Bin 1357 -> 0 bytes BuyButtonPressed.png.import | 34 ------ SellButton.png | Bin 1462 -> 0 bytes SellButton.png.import | 34 ------ SellButtonPressed.png | Bin 1475 -> 0 bytes SellButtonPressed.png.import | 34 ------ Stock Ticker.tscn | 122 --------------------- UI-Background-Colour.png | Bin 546 -> 0 bytes UI-Background-Colour.png.import | 34 ------ UI/templeos_font.ttf | Bin 0 -> 84460 bytes UI/templeos_font.ttf.import | 34 ++++++ UI/text.tres | 8 ++ buy_n_sell.gd | 25 ----- scenes/buy_n_sell.gd | 25 +++++ scenes/stockticker/BuyButton.png | Bin 0 -> 1344 bytes scenes/stockticker/BuyButton.png.import | 34 ++++++ scenes/stockticker/BuyButtonPressed.png | Bin 0 -> 1357 bytes scenes/stockticker/BuyButtonPressed.png.import | 34 ++++++ scenes/stockticker/SellButton.png | Bin 0 -> 1462 bytes scenes/stockticker/SellButton.png.import | 34 ++++++ scenes/stockticker/SellButtonPressed.png | Bin 0 -> 1475 bytes scenes/stockticker/SellButtonPressed.png.import | 34 ++++++ scenes/stockticker/Stock Ticker.tscn | 122 +++++++++++++++++++++ scenes/stockticker/UI-Background-Colour.png | Bin 0 -> 546 bytes scenes/stockticker/UI-Background-Colour.png.import | 34 ++++++ scenes/stockticker/stonks.gd | 52 +++++++++ stonks.gd | 52 --------- templeos_font.ttf | Bin 84460 -> 0 bytes templeos_font.ttf.import | 34 ------ text.tres | 8 -- 32 files changed, 411 insertions(+), 411 deletions(-) delete mode 100644 BuyButton.png delete mode 100644 BuyButton.png.import delete mode 100644 BuyButtonPressed.png delete mode 100644 BuyButtonPressed.png.import delete mode 100644 SellButton.png delete mode 100644 SellButton.png.import delete mode 100644 SellButtonPressed.png delete mode 100644 SellButtonPressed.png.import delete mode 100644 Stock Ticker.tscn delete mode 100644 UI-Background-Colour.png delete mode 100644 UI-Background-Colour.png.import create mode 100644 UI/templeos_font.ttf create mode 100644 UI/templeos_font.ttf.import create mode 100644 UI/text.tres delete mode 100644 buy_n_sell.gd create mode 100644 scenes/buy_n_sell.gd create mode 100644 scenes/stockticker/BuyButton.png create mode 100644 scenes/stockticker/BuyButton.png.import create mode 100644 scenes/stockticker/BuyButtonPressed.png create mode 100644 scenes/stockticker/BuyButtonPressed.png.import create mode 100644 scenes/stockticker/SellButton.png create mode 100644 scenes/stockticker/SellButton.png.import create mode 100644 scenes/stockticker/SellButtonPressed.png create mode 100644 scenes/stockticker/SellButtonPressed.png.import create mode 100644 scenes/stockticker/Stock Ticker.tscn create mode 100644 scenes/stockticker/UI-Background-Colour.png create mode 100644 scenes/stockticker/UI-Background-Colour.png.import create mode 100644 scenes/stockticker/stonks.gd delete mode 100644 stonks.gd delete mode 100644 templeos_font.ttf delete mode 100644 templeos_font.ttf.import delete mode 100644 text.tres diff --git a/BuyButton.png b/BuyButton.png deleted file mode 100644 index 8b35891..0000000 Binary files a/BuyButton.png and /dev/null differ diff --git a/BuyButton.png.import b/BuyButton.png.import deleted file mode 100644 index 0aab002..0000000 --- a/BuyButton.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://dcsaf0afsn76" -path="res://.godot/imported/BuyButton.png-1c1b0b8028f98a92082f37a9e5446c45.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://BuyButton.png" -dest_files=["res://.godot/imported/BuyButton.png-1c1b0b8028f98a92082f37a9e5446c45.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=1 diff --git a/BuyButtonPressed.png b/BuyButtonPressed.png deleted file mode 100644 index c028e5a..0000000 Binary files a/BuyButtonPressed.png and /dev/null differ diff --git a/BuyButtonPressed.png.import b/BuyButtonPressed.png.import deleted file mode 100644 index fc7c10e..0000000 --- a/BuyButtonPressed.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://ckd5ppryxuuum" -path="res://.godot/imported/BuyButtonPressed.png-52bdb0fc073bf2229b077e5e2c770886.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://BuyButtonPressed.png" -dest_files=["res://.godot/imported/BuyButtonPressed.png-52bdb0fc073bf2229b077e5e2c770886.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=1 diff --git a/SellButton.png b/SellButton.png deleted file mode 100644 index 55818d4..0000000 Binary files a/SellButton.png and /dev/null differ diff --git a/SellButton.png.import b/SellButton.png.import deleted file mode 100644 index 45ff4e1..0000000 --- a/SellButton.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://du8xy83ve1lm7" -path="res://.godot/imported/SellButton.png-a940d0a74daec8a650b2d33b6c2a6925.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://SellButton.png" -dest_files=["res://.godot/imported/SellButton.png-a940d0a74daec8a650b2d33b6c2a6925.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=1 diff --git a/SellButtonPressed.png b/SellButtonPressed.png deleted file mode 100644 index 3a3b2ee..0000000 Binary files a/SellButtonPressed.png and /dev/null differ diff --git a/SellButtonPressed.png.import b/SellButtonPressed.png.import deleted file mode 100644 index de8adba..0000000 --- a/SellButtonPressed.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://qgsvhv16ghwf" -path="res://.godot/imported/SellButtonPressed.png-b273be20baf4b6e42e2e343931e3265f.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://SellButtonPressed.png" -dest_files=["res://.godot/imported/SellButtonPressed.png-b273be20baf4b6e42e2e343931e3265f.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=1 diff --git a/Stock Ticker.tscn b/Stock Ticker.tscn deleted file mode 100644 index ad5bfc3..0000000 --- a/Stock Ticker.tscn +++ /dev/null @@ -1,122 +0,0 @@ -[gd_scene load_steps=9 format=3 uid="uid://g2veoq55y14i"] - -[ext_resource type="Texture2D" uid="uid://c6ed1ks2h58s7" path="res://UI-Background-Colour.png" id="1_1j58d"] -[ext_resource type="Texture2D" uid="uid://dcsaf0afsn76" path="res://BuyButton.png" id="2_8qhml"] -[ext_resource type="Texture2D" uid="uid://ckd5ppryxuuum" path="res://BuyButtonPressed.png" id="3_4kqfi"] -[ext_resource type="Script" path="res://buy_n_sell.gd" id="4_312bm"] -[ext_resource type="Texture2D" uid="uid://du8xy83ve1lm7" path="res://SellButton.png" id="5_salj8"] -[ext_resource type="Texture2D" uid="uid://qgsvhv16ghwf" path="res://SellButtonPressed.png" id="6_ifhss"] -[ext_resource type="Script" path="res://stonks.gd" id="7_ecbtd"] -[ext_resource type="Theme" uid="uid://cte81ypvmrsrv" path="res://text.tres" id="7_rtyuw"] - -[node name="Node2D" type="Node2D"] - -[node name="Background" type="Sprite2D" parent="."] -modulate = Color(0.796078, 0.796078, 0.796078, 1) -position = Vector2(576.25, 323.75) -scale = Vector2(1153.5, 648.5) -texture = ExtResource("1_1j58d") - -[node name="Timer" type="Timer" parent="."] -autostart = true - -[node name="Stonks" type="Node2D" parent="."] -script = ExtResource("7_ecbtd") - -[node name="Sprite2D" type="Sprite2D" parent="Stonks"] -position = Vector2(582, 205) -scale = Vector2(1062.25, 337) -texture = ExtResource("1_1j58d") - -[node name="TopLine" type="Line2D" parent="Stonks"] -points = PackedVector2Array(50, 60, 1000, 60) -width = 1.0 -default_color = Color(0.458824, 0.458824, 0.458824, 1) - -[node name="MidLine" type="Line2D" parent="Stonks"] -position = Vector2(0, 1) -points = PackedVector2Array(50, 208, 1000, 208) -width = 1.0 -default_color = Color(0.458824, 0.458824, 0.458824, 1) - -[node name="BottomLine" type="Line2D" parent="Stonks"] -position = Vector2(0, -1) -points = PackedVector2Array(50, 356, 1000, 356) -width = 1.0 -default_color = Color(0.46, 0.46, 0.46, 1) - -[node name="Top" type="Label" parent="Stonks"] -offset_left = 1021.0 -offset_top = 58.0 -offset_right = 1114.0 -offset_bottom = 89.0 -theme = ExtResource("7_rtyuw") -theme_override_colors/font_color = Color(0.63, 0.63, 0.63, 1) -theme_override_font_sizes/font_size = 12 -text = "0" -horizontal_alignment = 1 - -[node name="Middle" type="Label" parent="Stonks"] -offset_left = 1022.0 -offset_top = 208.0 -offset_right = 1115.0 -offset_bottom = 239.0 -theme = ExtResource("7_rtyuw") -theme_override_colors/font_color = Color(0.63, 0.63, 0.63, 1) -theme_override_font_sizes/font_size = 12 -text = "0" -horizontal_alignment = 1 - -[node name="Bottom" type="Label" parent="Stonks"] -offset_left = 1022.0 -offset_top = 356.0 -offset_right = 1115.0 -offset_bottom = 387.0 -theme = ExtResource("7_rtyuw") -theme_override_colors/font_color = Color(0.63, 0.63, 0.63, 1) -theme_override_font_sizes/font_size = 12 -text = "0" -horizontal_alignment = 1 - -[node name="Stonks" type="Line2D" parent="Stonks"] - -[node name="Price Label" type="Label" parent="Stonks"] -offset_left = 387.0 -offset_top = 387.0 -offset_right = 1112.0 -offset_bottom = 452.0 -theme = ExtResource("7_rtyuw") -text = "Price: -$" - -[node name="BuyNSell" type="Node2D" parent="."] -script = ExtResource("4_312bm") - -[node name="BuyButton" type="TextureButton" parent="BuyNSell"] -offset_left = 54.0 -offset_top = 475.0 -offset_right = 409.0 -offset_bottom = 604.0 -texture_normal = ExtResource("2_8qhml") -texture_pressed = ExtResource("3_4kqfi") - -[node name="SellButton" type="TextureButton" parent="BuyNSell"] -offset_left = 441.0 -offset_top = 477.0 -offset_right = 796.0 -offset_bottom = 606.0 -texture_normal = ExtResource("5_salj8") -texture_pressed = ExtResource("6_ifhss") - -[node name="Shares Held Label" type="Label" parent="BuyNSell"] -offset_left = 6.0 -offset_top = 390.0 -offset_right = 336.0 -offset_bottom = 455.0 -theme = ExtResource("7_rtyuw") -text = "Shares -Held:" - -[connection signal="timeout" from="Timer" to="Stonks" method="_on_timer_timeout"] -[connection signal="button_up" from="BuyNSell/BuyButton" to="BuyNSell" method="_on_buy_button_button_up"] -[connection signal="button_up" from="BuyNSell/SellButton" to="BuyNSell" method="_on_sell_button_button_up"] diff --git a/UI-Background-Colour.png b/UI-Background-Colour.png deleted file mode 100644 index ddec89e..0000000 Binary files a/UI-Background-Colour.png and /dev/null differ diff --git a/UI-Background-Colour.png.import b/UI-Background-Colour.png.import deleted file mode 100644 index 82fde74..0000000 --- a/UI-Background-Colour.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://c6ed1ks2h58s7" -path="res://.godot/imported/UI-Background-Colour.png-bb6018e92357421b80f76ef27985e968.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://UI-Background-Colour.png" -dest_files=["res://.godot/imported/UI-Background-Colour.png-bb6018e92357421b80f76ef27985e968.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=1 diff --git a/UI/templeos_font.ttf b/UI/templeos_font.ttf new file mode 100644 index 0000000..517ad2a Binary files /dev/null and b/UI/templeos_font.ttf differ diff --git a/UI/templeos_font.ttf.import b/UI/templeos_font.ttf.import new file mode 100644 index 0000000..4367876 --- /dev/null +++ b/UI/templeos_font.ttf.import @@ -0,0 +1,34 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://dexlelugh10is" +path="res://.godot/imported/templeos_font.ttf-31870174b86b680d08fac45957776bd3.fontdata" + +[deps] + +source_file="res://UI/templeos_font.ttf" +dest_files=["res://.godot/imported/templeos_font.ttf-31870174b86b680d08fac45957776bd3.fontdata"] + +[params] + +Rendering=null +antialiasing=1 +generate_mipmaps=false +disable_embedded_bitmaps=true +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +allow_system_fallback=true +force_autohinter=false +hinting=1 +subpixel_positioning=1 +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[] +language_support={} +script_support={} +opentype_features={} diff --git a/UI/text.tres b/UI/text.tres new file mode 100644 index 0000000..3e61750 --- /dev/null +++ b/UI/text.tres @@ -0,0 +1,8 @@ +[gd_resource type="Theme" load_steps=2 format=3 uid="uid://ve18rbkeiwti"] + +[ext_resource type="FontFile" uid="uid://dexlelugh10is" path="res://UI/templeos_font.ttf" id="1_vl4vs"] + +[resource] +Label/colors/font_color = Color(0, 0, 0, 1) +Label/font_sizes/font_size = 30 +Label/fonts/font = ExtResource("1_vl4vs") diff --git a/buy_n_sell.gd b/buy_n_sell.gd deleted file mode 100644 index be0e777..0000000 --- a/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/buy_n_sell.gd b/scenes/buy_n_sell.gd new file mode 100644 index 0000000..be0e777 --- /dev/null +++ b/scenes/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/BuyButton.png b/scenes/stockticker/BuyButton.png new file mode 100644 index 0000000..8b35891 Binary files /dev/null and b/scenes/stockticker/BuyButton.png differ diff --git a/scenes/stockticker/BuyButton.png.import b/scenes/stockticker/BuyButton.png.import new file mode 100644 index 0000000..fca69fa --- /dev/null +++ b/scenes/stockticker/BuyButton.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://vie3nmimge1t" +path="res://.godot/imported/BuyButton.png-edf9857fa46aeca6354e57c5c5fa4250.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scenes/stockticker/BuyButton.png" +dest_files=["res://.godot/imported/BuyButton.png-edf9857fa46aeca6354e57c5c5fa4250.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/scenes/stockticker/BuyButtonPressed.png b/scenes/stockticker/BuyButtonPressed.png new file mode 100644 index 0000000..c028e5a Binary files /dev/null and b/scenes/stockticker/BuyButtonPressed.png differ diff --git a/scenes/stockticker/BuyButtonPressed.png.import b/scenes/stockticker/BuyButtonPressed.png.import new file mode 100644 index 0000000..6a676e6 --- /dev/null +++ b/scenes/stockticker/BuyButtonPressed.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dvidbk3clx6dn" +path="res://.godot/imported/BuyButtonPressed.png-d376e992e63d9760db484195b2fac916.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scenes/stockticker/BuyButtonPressed.png" +dest_files=["res://.godot/imported/BuyButtonPressed.png-d376e992e63d9760db484195b2fac916.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/scenes/stockticker/SellButton.png b/scenes/stockticker/SellButton.png new file mode 100644 index 0000000..55818d4 Binary files /dev/null and b/scenes/stockticker/SellButton.png differ diff --git a/scenes/stockticker/SellButton.png.import b/scenes/stockticker/SellButton.png.import new file mode 100644 index 0000000..fd466fd --- /dev/null +++ b/scenes/stockticker/SellButton.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dw8wpd47me7wu" +path="res://.godot/imported/SellButton.png-2e342f0eff8cadc862043eaf743fb942.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scenes/stockticker/SellButton.png" +dest_files=["res://.godot/imported/SellButton.png-2e342f0eff8cadc862043eaf743fb942.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/scenes/stockticker/SellButtonPressed.png b/scenes/stockticker/SellButtonPressed.png new file mode 100644 index 0000000..3a3b2ee Binary files /dev/null and b/scenes/stockticker/SellButtonPressed.png differ diff --git a/scenes/stockticker/SellButtonPressed.png.import b/scenes/stockticker/SellButtonPressed.png.import new file mode 100644 index 0000000..9011600 --- /dev/null +++ b/scenes/stockticker/SellButtonPressed.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b773rtpy6rtx5" +path="res://.godot/imported/SellButtonPressed.png-e8a6d05fa42b79b6b606b25427b1ccae.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scenes/stockticker/SellButtonPressed.png" +dest_files=["res://.godot/imported/SellButtonPressed.png-e8a6d05fa42b79b6b606b25427b1ccae.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/scenes/stockticker/Stock Ticker.tscn b/scenes/stockticker/Stock Ticker.tscn new file mode 100644 index 0000000..122bdfc --- /dev/null +++ b/scenes/stockticker/Stock Ticker.tscn @@ -0,0 +1,122 @@ +[gd_scene load_steps=9 format=3 uid="uid://g2veoq55y14i"] + +[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="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"] +[ext_resource type="Texture2D" uid="uid://b773rtpy6rtx5" path="res://scenes/stockticker/SellButtonPressed.png" id="8_essj7"] + +[node name="Node2D" type="Node2D"] + +[node name="Background" type="Sprite2D" parent="."] +modulate = Color(0.796078, 0.796078, 0.796078, 1) +position = Vector2(576.25, 323.75) +scale = Vector2(1153.5, 648.5) +texture = ExtResource("1_wbfee") + +[node name="Timer" type="Timer" parent="."] +autostart = true + +[node name="Stonks" type="Node2D" parent="."] +script = ExtResource("2_pan4m") + +[node name="Sprite2D" 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 +default_color = Color(0.458824, 0.458824, 0.458824, 1) + +[node name="MidLine" type="Line2D" parent="Stonks"] +position = Vector2(0, 1) +points = PackedVector2Array(50, 208, 1000, 208) +width = 1.0 +default_color = Color(0.458824, 0.458824, 0.458824, 1) + +[node name="BottomLine" type="Line2D" parent="Stonks"] +position = Vector2(0, -1) +points = PackedVector2Array(50, 356, 1000, 356) +width = 1.0 +default_color = Color(0.46, 0.46, 0.46, 1) + +[node name="Top" type="Label" parent="Stonks"] +offset_left = 1021.0 +offset_top = 58.0 +offset_right = 1114.0 +offset_bottom = 89.0 +theme = ExtResource("3_dv3dr") +theme_override_colors/font_color = Color(0.63, 0.63, 0.63, 1) +theme_override_font_sizes/font_size = 12 +text = "0" +horizontal_alignment = 1 + +[node name="Middle" type="Label" parent="Stonks"] +offset_left = 1022.0 +offset_top = 208.0 +offset_right = 1115.0 +offset_bottom = 239.0 +theme = ExtResource("3_dv3dr") +theme_override_colors/font_color = Color(0.63, 0.63, 0.63, 1) +theme_override_font_sizes/font_size = 12 +text = "0" +horizontal_alignment = 1 + +[node name="Bottom" type="Label" parent="Stonks"] +offset_left = 1022.0 +offset_top = 356.0 +offset_right = 1115.0 +offset_bottom = 387.0 +theme = ExtResource("3_dv3dr") +theme_override_colors/font_color = Color(0.63, 0.63, 0.63, 1) +theme_override_font_sizes/font_size = 12 +text = "0" +horizontal_alignment = 1 + +[node name="Stonks" type="Line2D" parent="Stonks"] + +[node name="Price Label" type="Label" parent="Stonks"] +offset_left = 387.0 +offset_top = 387.0 +offset_right = 1112.0 +offset_bottom = 452.0 +theme = ExtResource("3_dv3dr") +text = "Price: +$" + +[node name="BuyNSell" type="Node2D" parent="."] +script = ExtResource("4_l8sru") + +[node name="BuyButton" type="TextureButton" parent="BuyNSell"] +offset_left = 54.0 +offset_top = 475.0 +offset_right = 409.0 +offset_bottom = 604.0 +texture_normal = ExtResource("5_mpf30") +texture_pressed = ExtResource("6_styy2") + +[node name="SellButton" type="TextureButton" parent="BuyNSell"] +offset_left = 441.0 +offset_top = 477.0 +offset_right = 796.0 +offset_bottom = 606.0 +texture_normal = ExtResource("7_h6hir") +texture_pressed = ExtResource("8_essj7") + +[node name="Shares Held Label" type="Label" parent="BuyNSell"] +offset_left = 6.0 +offset_top = 390.0 +offset_right = 336.0 +offset_bottom = 455.0 +theme = ExtResource("3_dv3dr") +text = "Shares +Held:" + +[connection signal="timeout" from="Timer" to="Stonks" method="_on_timer_timeout"] +[connection signal="button_up" from="BuyNSell/BuyButton" to="BuyNSell" method="_on_buy_button_button_up"] +[connection signal="button_up" from="BuyNSell/SellButton" to="BuyNSell" method="_on_sell_button_button_up"] diff --git a/scenes/stockticker/UI-Background-Colour.png b/scenes/stockticker/UI-Background-Colour.png new file mode 100644 index 0000000..ddec89e Binary files /dev/null and b/scenes/stockticker/UI-Background-Colour.png differ diff --git a/scenes/stockticker/UI-Background-Colour.png.import b/scenes/stockticker/UI-Background-Colour.png.import new file mode 100644 index 0000000..379a5be --- /dev/null +++ b/scenes/stockticker/UI-Background-Colour.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://voruypgyi77e" +path="res://.godot/imported/UI-Background-Colour.png-923b8102e8ca62798feecb1dd2a3a275.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scenes/stockticker/UI-Background-Colour.png" +dest_files=["res://.godot/imported/UI-Background-Colour.png-923b8102e8ca62798feecb1dd2a3a275.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/scenes/stockticker/stonks.gd b/scenes/stockticker/stonks.gd new file mode 100644 index 0000000..9b7b845 --- /dev/null +++ b/scenes/stockticker/stonks.gd @@ -0,0 +1,52 @@ +extends Node2D + +var price_history = [] +var max_prices = 15 +var max_up_multiplier = 2 +var max_down_multiplier = 2 +var bailout_counter = 0 +var bailout_time = 1 + +var bailout_price = 5 +var start_val = 5 +var prev_price = start_val + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + print(start_val) + var label = $"Price Label" + 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 + + +func _on_timer_timeout() -> void: + var new_price = prev_price + + if prev_price <= 0: + if bailout_counter < bailout_time: + new_price = 0 + bailout_counter += 1 + else: + new_price = bailout_price + bailout_counter = 0 + elif randf() < 0.5: + new_price += 1 * max_up_multiplier * randf() + else: + new_price -= 1 * max_down_multiplier * randf() + + if new_price < 0: new_price = 0 + + if len(price_history) >= max_prices: + price_history.pop_front() + price_history.push_back(new_price) + prev_price = new_price + + var label = $"Price Label" + label.text = "Price:\n$%f" % new_price + + print(new_price) diff --git a/stonks.gd b/stonks.gd deleted file mode 100644 index 9b7b845..0000000 --- a/stonks.gd +++ /dev/null @@ -1,52 +0,0 @@ -extends Node2D - -var price_history = [] -var max_prices = 15 -var max_up_multiplier = 2 -var max_down_multiplier = 2 -var bailout_counter = 0 -var bailout_time = 1 - -var bailout_price = 5 -var start_val = 5 -var prev_price = start_val - -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - print(start_val) - var label = $"Price Label" - 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 - - -func _on_timer_timeout() -> void: - var new_price = prev_price - - if prev_price <= 0: - if bailout_counter < bailout_time: - new_price = 0 - bailout_counter += 1 - else: - new_price = bailout_price - bailout_counter = 0 - elif randf() < 0.5: - new_price += 1 * max_up_multiplier * randf() - else: - new_price -= 1 * max_down_multiplier * randf() - - if new_price < 0: new_price = 0 - - if len(price_history) >= max_prices: - price_history.pop_front() - price_history.push_back(new_price) - prev_price = new_price - - var label = $"Price Label" - label.text = "Price:\n$%f" % new_price - - print(new_price) diff --git a/templeos_font.ttf b/templeos_font.ttf deleted file mode 100644 index 517ad2a..0000000 Binary files a/templeos_font.ttf and /dev/null differ diff --git a/templeos_font.ttf.import b/templeos_font.ttf.import deleted file mode 100644 index bcfd2cb..0000000 --- a/templeos_font.ttf.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="font_data_dynamic" -type="FontFile" -uid="uid://3e6fuwt5giyn" -path="res://.godot/imported/templeos_font.ttf-3df095bd9bdc9ad857a60b3667a243a3.fontdata" - -[deps] - -source_file="res://templeos_font.ttf" -dest_files=["res://.godot/imported/templeos_font.ttf-3df095bd9bdc9ad857a60b3667a243a3.fontdata"] - -[params] - -Rendering=null -antialiasing=1 -generate_mipmaps=false -disable_embedded_bitmaps=true -multichannel_signed_distance_field=false -msdf_pixel_range=8 -msdf_size=48 -allow_system_fallback=true -force_autohinter=false -hinting=1 -subpixel_positioning=1 -oversampling=0.0 -Fallbacks=null -fallbacks=[] -Compress=null -compress=true -preload=[] -language_support={} -script_support={} -opentype_features={} diff --git a/text.tres b/text.tres deleted file mode 100644 index a724622..0000000 --- a/text.tres +++ /dev/null @@ -1,8 +0,0 @@ -[gd_resource type="Theme" load_steps=2 format=3 uid="uid://cte81ypvmrsrv"] - -[ext_resource type="FontFile" uid="uid://3e6fuwt5giyn" path="res://templeos_font.ttf" id="1_3hk8o"] - -[resource] -Label/colors/font_color = Color(0, 0, 0, 1) -Label/font_sizes/font_size = 30 -Label/fonts/font = ExtResource("1_3hk8o") -- cgit v1.2.3 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 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