diff options
author | jacob janzen <53062115+JacobJanzen@users.noreply.github.com> | 2024-11-15 19:55:44 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-15 19:55:44 -0600 |
commit | 33a6215be1c05efe3628509a1e0bb53f40b2a3ca (patch) | |
tree | 8c29790ef9c808b2e3b825d3c9a56125b0b10cda | |
parent | 7a468e63650bd5f10e8402f416ea988883844f89 (diff) | |
parent | 4f5d964c6890f3281e8673905ab0158dca0ebcf8 (diff) |
Merge pull request #1 from cssa-game-jam-2024/stock-ticker-mvp
Stock ticker mvp
-rw-r--r-- | ButtonBase.xcf | bin | 0 -> 11607 bytes | |||
-rw-r--r-- | ButtonBasePressed.xcf | bin | 0 -> 14164 bytes | |||
-rw-r--r-- | BuyButton.png | bin | 0 -> 1344 bytes | |||
-rw-r--r-- | BuyButton.png.import | 34 | ||||
-rw-r--r-- | BuyButtonPressed.png | bin | 0 -> 1357 bytes | |||
-rw-r--r-- | BuyButtonPressed.png.import | 34 | ||||
-rw-r--r-- | SellButton.png | bin | 0 -> 1462 bytes | |||
-rw-r--r-- | SellButton.png.import | 34 | ||||
-rw-r--r-- | SellButtonPressed.png | bin | 0 -> 1475 bytes | |||
-rw-r--r-- | SellButtonPressed.png.import | 34 | ||||
-rw-r--r-- | Stock Ticker.tscn | 122 | ||||
-rw-r--r-- | UI-Background-Colour.png | bin | 0 -> 546 bytes | |||
-rw-r--r-- | UI-Background-Colour.png.import | 34 | ||||
-rw-r--r-- | UI-Background-Colour.xcf | bin | 0 -> 687 bytes | |||
-rw-r--r-- | buy_n_sell.gd | 25 | ||||
-rw-r--r-- | stonks.gd | 52 | ||||
-rw-r--r-- | templeos_font.ttf | bin | 0 -> 84460 bytes | |||
-rw-r--r-- | templeos_font.ttf.import | 34 | ||||
-rw-r--r-- | text.tres | 8 |
19 files changed, 411 insertions, 0 deletions
diff --git a/ButtonBase.xcf b/ButtonBase.xcf Binary files differnew file mode 100644 index 0000000..4c3e2f4 --- /dev/null +++ b/ButtonBase.xcf diff --git a/ButtonBasePressed.xcf b/ButtonBasePressed.xcf Binary files differnew file mode 100644 index 0000000..1740221 --- /dev/null +++ b/ButtonBasePressed.xcf diff --git a/BuyButton.png b/BuyButton.png Binary files differnew file mode 100644 index 0000000..8b35891 --- /dev/null +++ b/BuyButton.png 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 Binary files differnew file mode 100644 index 0000000..c028e5a --- /dev/null +++ b/BuyButtonPressed.png 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 Binary files differnew file mode 100644 index 0000000..55818d4 --- /dev/null +++ b/SellButton.png 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 Binary files differnew file mode 100644 index 0000000..3a3b2ee --- /dev/null +++ b/SellButtonPressed.png 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..ad5bfc3 --- /dev/null +++ b/Stock Ticker.tscn @@ -0,0 +1,122 @@ +[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 Binary files differnew file mode 100644 index 0000000..ddec89e --- /dev/null +++ b/UI-Background-Colour.png 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 Binary files differnew file mode 100644 index 0000000..7704326 --- /dev/null +++ b/UI-Background-Colour.xcf 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 new file mode 100644 index 0000000..9b7b845 --- /dev/null +++ b/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/templeos_font.ttf b/templeos_font.ttf Binary files differnew file mode 100644 index 0000000..517ad2a --- /dev/null +++ b/templeos_font.ttf 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..a724622 --- /dev/null +++ b/text.tres @@ -0,0 +1,8 @@ +[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") |