From 0e4a55d7bd97bae5569e2a3594f921783c8c05cc Mon Sep 17 00:00:00 2001 From: Tabby <41929769+tabby-cat-nya@users.noreply.github.com> Date: Sat, 28 Jun 2025 13:09:15 +1000 Subject: [PATCH] cute lil prototype --- Prefabs/obstacle.tscn | 18 +++++++++ Prefabs/spare_battery.tscn | 12 ++++++ Prefabs/spinny.gd | 11 +++++ Prefabs/spinny.gd.uid | 1 + Sprites/batteryBar.pdn | Bin 0 -> 4046 bytes Sprites/batteryEmpty.png | Bin 0 -> 353 bytes Sprites/batteryEmpty.png.import | 34 ++++++++++++++++ Sprites/batteryOutline.png | Bin 0 -> 410 bytes Sprites/batteryOutline.png.import | 34 ++++++++++++++++ Sprites/batteryfull.png | Bin 0 -> 403 bytes Sprites/batteryfull.png.import | 34 ++++++++++++++++ Sprites/testObstacle.png | Bin 0 -> 392 bytes Sprites/testObstacle.png.import | 34 ++++++++++++++++ battery_manager.gd | 32 +++++++++++++++ battery_manager.gd.uid | 1 + game.tscn | 65 +++++++++++++++++++++++++++++- project.godot | 2 +- test_obstacle_spawner.gd | 28 +++++++++++++ test_obstacle_spawner.gd.uid | 1 + 19 files changed, 305 insertions(+), 2 deletions(-) create mode 100644 Prefabs/obstacle.tscn create mode 100644 Prefabs/spare_battery.tscn create mode 100644 Prefabs/spinny.gd create mode 100644 Prefabs/spinny.gd.uid create mode 100644 Sprites/batteryBar.pdn create mode 100644 Sprites/batteryEmpty.png create mode 100644 Sprites/batteryEmpty.png.import create mode 100644 Sprites/batteryOutline.png create mode 100644 Sprites/batteryOutline.png.import create mode 100644 Sprites/batteryfull.png create mode 100644 Sprites/batteryfull.png.import create mode 100644 Sprites/testObstacle.png create mode 100644 Sprites/testObstacle.png.import create mode 100644 battery_manager.gd create mode 100644 battery_manager.gd.uid create mode 100644 test_obstacle_spawner.gd create mode 100644 test_obstacle_spawner.gd.uid diff --git a/Prefabs/obstacle.tscn b/Prefabs/obstacle.tscn new file mode 100644 index 0000000..c875c3f --- /dev/null +++ b/Prefabs/obstacle.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=4 format=3 uid="uid://jb677rdhbj83"] + +[ext_resource type="Script" uid="uid://cnapenyo7b610" path="res://Prefabs/spinny.gd" id="1_htne5"] +[ext_resource type="Texture2D" uid="uid://x8huf40a6dhq" path="res://Sprites/testObstacle.png" id="1_ifkp4"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_vef74"] +size = Vector2(64, 64) + +[node name="Obstacle" type="RigidBody2D"] +gravity_scale = 0.0 +angular_damp_mode = 1 +script = ExtResource("1_htne5") + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("1_ifkp4") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("RectangleShape2D_vef74") diff --git a/Prefabs/spare_battery.tscn b/Prefabs/spare_battery.tscn new file mode 100644 index 0000000..6c7721e --- /dev/null +++ b/Prefabs/spare_battery.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=3 format=3 uid="uid://cfdsa5scvso6m"] + +[ext_resource type="Texture2D" uid="uid://1uqioi3jaw62" path="res://Sprites/batteryOutline.png" id="1_extsq"] +[ext_resource type="Texture2D" uid="uid://1gx13iy21l2a" path="res://Sprites/batteryfull.png" id="2_n31ms"] + +[node name="Battery2" type="TextureProgressBar"] +max_value = 16.0 +value = 16.0 +fill_mode = 3 +texture_under = ExtResource("1_extsq") +texture_progress = ExtResource("2_n31ms") +tint_progress = Color(0, 1, 0, 1) diff --git a/Prefabs/spinny.gd b/Prefabs/spinny.gd new file mode 100644 index 0000000..2e5c9e7 --- /dev/null +++ b/Prefabs/spinny.gd @@ -0,0 +1,11 @@ +extends RigidBody2D + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + angular_velocity = randf_range(1,3) + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass diff --git a/Prefabs/spinny.gd.uid b/Prefabs/spinny.gd.uid new file mode 100644 index 0000000..9715e81 --- /dev/null +++ b/Prefabs/spinny.gd.uid @@ -0,0 +1 @@ +uid://cnapenyo7b610 diff --git a/Sprites/batteryBar.pdn b/Sprites/batteryBar.pdn new file mode 100644 index 0000000000000000000000000000000000000000..05a70cfd6e6faa56d76d1b7b46c4fcc3df4dfe3d GIT binary patch literal 4046 zcmd^BO>7%g5Z-P4w`tmj{!nNex;0gcl+s1LD95khpL|LcLM-j>NH25#oS^kPsIRfP^@}0SO7IQV(V3tsUEGOA8XGthLW? z-p@C0X1+JG3+cJh^Z{n7UN&+yStb0IR(2}M@JKYwSBR!o9O#dQd0lQ0%T9(z!@MnT zlJa%UsVu>WW*W(GA~F)4h)l-DqmlT?$YdfsJ*Bv|W7ejpoQhl9;OmB(3~Ni`d~qv! zHLIEeJaZ+fl95#GQn`>4@+d5u#Y6);!i~97F`5%BJFbisaG+=uq!CdNQrow;HYb(~ z5)Nji%(hfi(!v%>sm&Xvyi9xLnb~=1ctS{QC|f0}N8c*V=sPeuzXglac3#|$4VpJ` z^=w_gp3!S1sd`5c=;DkZnxa?`K%XEi;E-tV%0-k@st8KyJl&G5T>*j0ixdKPie3-T zpGCR39`siQ#S_v(BfkUM(0*!X2G`A)D4=|07YvUE_&IOiOfE4Grx4mW+xawZg=NLr zjOH#~xhhc~-7ZN*aY?M)SdOJK!ggv=C{)x%QJtAlbH$vXW+$_=DM4!Ft2eX7OhLF) z62wH**clwBs>Ru&l*m}sSyfe&$uK`WJvH14@NkPc(+mqghIs-H{^Qek0GfpbSu>op z>C6!)l9nBLh;K1xFL8$Wl&d?gMUn<_9ZS}S_yu=E*OaTIv1nF_ku+Rg_aprAE>u%- zYs7E@Fwv{oY0a*iHYo=@*7_-@10J2ZUHZP_+QiBeM=ryeat^84jE`Y@de{@4(ASXo z*EHKfQ$nG`rG^blBTWl_Wt(!!)ODgba2@POmKem+ln5MpN!DEgaMpTkWu>{a7;J*@hC*nO4)54`hWY(2!vt}F z5*tB!e%TiR_dSA3ygy7u67^I`!@r4Fm1P4Q3>-R7wzXRkM^;ByqN@Sqe0mCpc&!XI zFq(jZ2+4?6MyF9H$#5*pQ-EYx%Ffg`jDovZU6OKX$<3GIaY69XCi@ro6@44%>(UZO zEr(!exUD5NiDehH0Jf(Dif>a1)B&1@**{x=N4fwL2#D8oyaR9ofGFTZ3lQvR0@9Kx z(8A*Z|Iq?I+66p@z{mCi!@*t_xF7E-UM220HYc!o6`J0@lhAh6ij--Qc5?iWwF0%A z>`dsQ=G5dmP3yE=)Gf14EJq`D&~~j`vO@alWEXfAvWc5tsl)6UYT5Cok}y?q)w+!<)v z3kE=7F#vSI8_?m-LepNrgWyNxe`giu<=_UeqC8*sUFftyg0d@m6ZYVoY1L%CDWVb7 zkaMUL4SAMdkUU)_JzzscEfc@3$VL<0) zFZMN3#%IVi^7Pk35DN)d+^5;1tW;IYbd7S*tjmh#G&t&tyjdnJEmHgC!+~WFoazid zr7jIO`l1!^z?P}ED%X<9VevWWe* z1JaKqf60phE9u4XBU7J8ZRAx5?v?6P#^PK>wioD!SEx*G5z8WFnC4g($^Xu-vx3yu z=t+F`$=3~w%s}t6NCb3g+aWB*m(F20yXOvig$u^vIeYf~kk{)~*4H0>6MZi`^622YT|~{rvFruO9@M`GHSH k_X1q(1h{+Y(GmYg_aA@Q^TGYcm-*lB`I&>_+GX7HH|oZMh5!Hn literal 0 HcmV?d00001 diff --git a/Sprites/batteryEmpty.png b/Sprites/batteryEmpty.png new file mode 100644 index 0000000000000000000000000000000000000000..e8be8fa8513ce6cc900b042db6ceee303dadfeb6 GIT binary patch literal 353 zcmeAS@N?(olHy`uVBq!ia0vp^AhrMp8<5nmf9C+C7>k44ofy`glX(f`u%tWsIx;Y9 z?C1WI$O`0h7I;J!GcfQS24TkI`72U@f)XXJ5hcO-X(i=}MX3w{iJ5sNdVa1U3Z{C7 zdKS`|uT}unY)g&sO!M^AV&DLBSQ(@kSs56CEH5CIhO$Af(O_f-i!%Y)hKx)M0zf(n zh%?(+z~WgzHV7mDF-Sj*MzfTGnSo&fI|B<)g@KW=0pkLQsURJ!3m_&<0kT1W31|)z zSY?o<1&{^RWoTdkl3m@PC>%V`LIcPY@N{tu(FjhKU|pPWfq{*UfoTE*qd({K7LYnm LS3j3^P6Nn{1`*#dk*Tn`*L0Ay-kU$_iNF_i@Q1^;Jwy4}DF$m1;Vh%9Dc;5!V$jK}j= zqyPmaN?apKg7ec#$`gxH83GbB^GfvmTtgI0^$hhaq%&Ww0IJ!R8sVAd>8ZuQ0pzeU zNHMZ9FalX1Go_(ykZUyrK(-+x6N3PdjsoJ$b{4RB7LW}B2|x_e52Mj6WdQnj z0y_f>P=$e!u>s=(h^ZhQtP3C}O#!k&fC*?06If-Cr3H`$)n#a40FqtZpeP(X&q4#p z)bw<54ABTqPB_B!fz!x=af-WPYmP(Nn{1`*#dk*T>t<74`hZOx?BgOm`Z~Dg8wr--EQCo4nJ@ErzW#^d=b zQhzyvgh39K^6(gMhW>M}Gi0LiXyP!tZHXQ2UP zDtWp%hG+yQCmdl~p?ZRWB|t5d#gWOtK+D2{^&+EdQ%?_r$UnwLjk!A-Ksr5L{an^L HB{Ts51sqE> literal 0 HcmV?d00001 diff --git a/Sprites/batteryfull.png.import b/Sprites/batteryfull.png.import new file mode 100644 index 0000000..156edc4 --- /dev/null +++ b/Sprites/batteryfull.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://1gx13iy21l2a" +path="res://.godot/imported/batteryfull.png-5f915430beb8a01d35ced1f546406e16.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/batteryfull.png" +dest_files=["res://.godot/imported/batteryfull.png-5f915430beb8a01d35ced1f546406e16.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/Sprites/testObstacle.png b/Sprites/testObstacle.png new file mode 100644 index 0000000000000000000000000000000000000000..da65bb8e8746524bd041c30366d0e079b5d4bf89 GIT binary patch literal 392 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0J3?w7mbKU|e#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;R0X`wF|Lf};8XD}1ui5}bI14-?iy0XB4ude`@%$AjKtYKT*NBqf{Irtt z#G+J&fW*wa5g$9tR>gnPb;&D8A0egbT y5oQ)Q(H<>{P=i$oAqQ791+rcVbx1yNfPrCyZvN(Z3s-~u!r void: + extra_batteries = starting_batteries -1 + redraw_extra_batteries() + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + if cb_value <= 0: + extra_batteries -= 1 + cb_value = 16 + redraw_extra_batteries() + var thrust : float = Input.get_action_strength("thrust") + cb_value -= thrust * delta * battery_drain + current_battery.value = cb_value + +func redraw_extra_batteries(): + for i in range(get_children().size()): + if(i != 0): + get_child(i).queue_free() + + for i in range(extra_batteries): + var new_extra = load("res://Prefabs/spare_battery.tscn").instantiate() + add_child(new_extra) diff --git a/battery_manager.gd.uid b/battery_manager.gd.uid new file mode 100644 index 0000000..77c101c --- /dev/null +++ b/battery_manager.gd.uid @@ -0,0 +1 @@ +uid://mwbiu2ajbxlk diff --git a/game.tscn b/game.tscn index 80600d2..40c2771 100644 --- a/game.tscn +++ b/game.tscn @@ -1,8 +1,14 @@ -[gd_scene load_steps=8 format=3 uid="uid://hv07lm2tjwn4"] +[gd_scene load_steps=14 format=3 uid="uid://hv07lm2tjwn4"] [ext_resource type="PackedScene" uid="uid://crrbht7mwhgyc" path="res://Prefabs/lander.tscn" id="1_80nbo"] [ext_resource type="Script" uid="uid://bltj2frs6vqwj" path="res://autoscroll.gd" id="1_feb5d"] +[ext_resource type="Script" uid="uid://mwbiu2ajbxlk" path="res://battery_manager.gd" id="1_ryrav"] [ext_resource type="Texture2D" uid="uid://evhjxwdbsmlo" path="res://Sprites/start.png" id="2_e2o6t"] +[ext_resource type="Texture2D" uid="uid://1uqioi3jaw62" path="res://Sprites/batteryOutline.png" id="2_eow3j"] +[ext_resource type="Texture2D" uid="uid://1gx13iy21l2a" path="res://Sprites/batteryfull.png" id="3_j5wjh"] +[ext_resource type="PackedScene" uid="uid://cfdsa5scvso6m" path="res://Prefabs/spare_battery.tscn" id="4_eow3j"] +[ext_resource type="Script" uid="uid://dd8psfqfobgau" path="res://test_obstacle_spawner.gd" id="6_vef74"] +[ext_resource type="PackedScene" uid="uid://jb677rdhbj83" path="res://Prefabs/obstacle.tscn" id="8_j5wjh"] [sub_resource type="Gradient" id="Gradient_mwb40"] offsets = PackedFloat32Array(0.806763, 1) @@ -35,10 +41,51 @@ offset_right = 40.0 offset_bottom = 40.0 texture = SubResource("NoiseTexture2D_mwb40") +[node name="UI" type="Control" parent="CanvasLayer"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="BatteryHolder" type="HBoxContainer" parent="CanvasLayer/UI" node_paths=PackedStringArray("current_battery")] +layout_mode = 1 +offset_right = 68.0 +offset_bottom = 32.0 +script = ExtResource("1_ryrav") +current_battery = NodePath("Battery") +battery_drain = 4.0 + +[node name="Battery" type="TextureProgressBar" parent="CanvasLayer/UI/BatteryHolder"] +layout_mode = 2 +max_value = 16.0 +value = 16.0 +fill_mode = 3 +texture_under = ExtResource("2_eow3j") +texture_progress = ExtResource("3_j5wjh") +tint_progress = Color(0, 1, 0, 1) + +[node name="Battery2" parent="CanvasLayer/UI/BatteryHolder" instance=ExtResource("4_eow3j")] +layout_mode = 2 + +[node name="Battery3" type="TextureProgressBar" parent="CanvasLayer/UI/BatteryHolder"] +layout_mode = 2 +max_value = 16.0 +value = 16.0 +fill_mode = 3 +texture_under = ExtResource("2_eow3j") +texture_progress = ExtResource("3_j5wjh") +tint_progress = Color(0, 1, 0, 1) + [node name="Camera2D" type="Camera2D" parent="."] anchor_mode = 0 script = ExtResource("1_feb5d") +[node name="TestObstacleSpawner" type="Node2D" parent="Camera2D"] +position = Vector2(673, 0) +script = ExtResource("6_vef74") + [node name="Lander" parent="." instance=ExtResource("1_80nbo")] position = Vector2(95, 324) @@ -52,4 +99,20 @@ texture = ExtResource("2_e2o6t") position = Vector2(-262.5, 170) shape = SubResource("RectangleShape2D_feb5d") +[node name="Obstacle" parent="." instance=ExtResource("8_j5wjh")] +position = Vector2(240, 265) + +[node name="Obstacle2" parent="." instance=ExtResource("8_j5wjh")] +position = Vector2(301, 100) + +[node name="Obstacle3" parent="." instance=ExtResource("8_j5wjh")] +position = Vector2(425, 224) + +[node name="Obstacle4" parent="." instance=ExtResource("8_j5wjh")] +position = Vector2(582, 320) + +[node name="Obstacle5" parent="." instance=ExtResource("8_j5wjh")] +position = Vector2(549, 39) + [connection signal="moved" from="Lander" to="Camera2D" method="_on_lander_moved"] +[connection signal="moved" from="Lander" to="Camera2D/TestObstacleSpawner" method="_on_lander_moved"] diff --git a/project.godot b/project.godot index 750f886..9dfd1d2 100644 --- a/project.godot +++ b/project.godot @@ -13,7 +13,7 @@ config_version=5 config/name="Lunar" run/main_scene="uid://hv07lm2tjwn4" config/features=PackedStringArray("4.4", "GL Compatibility") -config/icon="res://icon.svg" +config/icon="uid://bd5oswedqnenh" [display] diff --git a/test_obstacle_spawner.gd b/test_obstacle_spawner.gd new file mode 100644 index 0000000..29e26d7 --- /dev/null +++ b/test_obstacle_spawner.gd @@ -0,0 +1,28 @@ +extends Node2D + +var active : bool = false +var next_spawn : float = 3 +var spawn_delay : float = 3 + +# 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: + if active: + next_spawn -= delta + if next_spawn <= 0: + spawn_obstacle() + spawn_delay -= spawn_delay * 0.02 + next_spawn = spawn_delay + +func spawn_obstacle(): + var randy = randi_range(0,360) #y pos to spawn the new obstacle at + var new_obstacle : Node2D = load("res://Prefabs/obstacle.tscn").instantiate() + new_obstacle.global_position = Vector2(global_position.x, randy) + get_tree().get_root().add_child(new_obstacle) + +func _on_lander_moved() -> void: + active = true diff --git a/test_obstacle_spawner.gd.uid b/test_obstacle_spawner.gd.uid new file mode 100644 index 0000000..a7fb5f3 --- /dev/null +++ b/test_obstacle_spawner.gd.uid @@ -0,0 +1 @@ +uid://dd8psfqfobgau