From 37a19d878823a5436884e3513e6ecffb61dd11e0 Mon Sep 17 00:00:00 2001 From: Tabby <41929769+tabby-cat-nya@users.noreply.github.com> Date: Sun, 30 Nov 2025 00:49:23 +1100 Subject: [PATCH] coins~ --- Prefabs/coin.gd | 19 +++ Prefabs/coin.gd.uid | 1 + Prefabs/coin.tscn | 73 +++++++++ Sprites/coinspin.png | Bin 0 -> 592 bytes Sprites/coinspin.png.import | 40 +++++ Sprites/coinspin.pxo | Bin 0 -> 1816 bytes game.tscn | 304 ++++++++++++++++++++++++------------ logic.gd | 16 ++ project.godot | 6 +- readme.md | 3 + ship.gd | 2 + storyteller.gd | 13 ++ storyteller.gd.uid | 1 + storyteller.tscn | 6 + 14 files changed, 379 insertions(+), 105 deletions(-) create mode 100644 Prefabs/coin.gd create mode 100644 Prefabs/coin.gd.uid create mode 100644 Prefabs/coin.tscn create mode 100644 Sprites/coinspin.png create mode 100644 Sprites/coinspin.png.import create mode 100644 Sprites/coinspin.pxo create mode 100644 storyteller.gd create mode 100644 storyteller.gd.uid create mode 100644 storyteller.tscn diff --git a/Prefabs/coin.gd b/Prefabs/coin.gd new file mode 100644 index 0000000..9e2c509 --- /dev/null +++ b/Prefabs/coin.gd @@ -0,0 +1,19 @@ +extends Area2D + + +# 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: + modulate = Storyteller.current_coin_color + + +func _on_body_entered(body: Node2D) -> void: + if body is RigidBody2D: + #body.apply_force((body.global_position - global_position).normalized() *10000) + #body.linear_velocity = (body.global_position - global_position).normalized() *100 + queue_free() + body.got_points.emit() diff --git a/Prefabs/coin.gd.uid b/Prefabs/coin.gd.uid new file mode 100644 index 0000000..dc762cb --- /dev/null +++ b/Prefabs/coin.gd.uid @@ -0,0 +1 @@ +uid://do7o4q625abg3 diff --git a/Prefabs/coin.tscn b/Prefabs/coin.tscn new file mode 100644 index 0000000..1b19065 --- /dev/null +++ b/Prefabs/coin.tscn @@ -0,0 +1,73 @@ +[gd_scene load_steps=11 format=3 uid="uid://b7km814mwwsvv"] + +[ext_resource type="Script" uid="uid://do7o4q625abg3" path="res://Prefabs/coin.gd" id="1_ilgmi"] +[ext_resource type="Texture2D" uid="uid://bnd3eacyt5x70" path="res://Sprites/coinspin.png" id="2_cbfdx"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_oi7sn"] +atlas = ExtResource("2_cbfdx") +region = Rect2(0, 0, 15, 15) + +[sub_resource type="AtlasTexture" id="AtlasTexture_thoqv"] +atlas = ExtResource("2_cbfdx") +region = Rect2(15, 0, 15, 15) + +[sub_resource type="AtlasTexture" id="AtlasTexture_h4ckm"] +atlas = ExtResource("2_cbfdx") +region = Rect2(30, 0, 15, 15) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ewynv"] +atlas = ExtResource("2_cbfdx") +region = Rect2(45, 0, 15, 15) + +[sub_resource type="AtlasTexture" id="AtlasTexture_i2k62"] +atlas = ExtResource("2_cbfdx") +region = Rect2(60, 0, 15, 15) + +[sub_resource type="AtlasTexture" id="AtlasTexture_f2p4i"] +atlas = ExtResource("2_cbfdx") +region = Rect2(75, 0, 15, 15) + +[sub_resource type="SpriteFrames" id="SpriteFrames_4nl6u"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_oi7sn") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_thoqv") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_h4ckm") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ewynv") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_i2k62") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_f2p4i") +}], +"loop": true, +"name": &"new_animation", +"speed": 10.0 +}] + +[sub_resource type="CircleShape2D" id="CircleShape2D_ar03h"] +radius = 6.0 + +[node name="Coin" type="Area2D"] +script = ExtResource("1_ilgmi") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +scale = Vector2(0.8, 0.8) +sprite_frames = SubResource("SpriteFrames_4nl6u") +animation = &"new_animation" +autoplay = "new_animation" +frame_progress = 0.29463264 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +visible = false +shape = SubResource("CircleShape2D_ar03h") + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/Sprites/coinspin.png b/Sprites/coinspin.png new file mode 100644 index 0000000000000000000000000000000000000000..7e3c26efeaa11f31007610b3417f61f34ada7b09 GIT binary patch literal 592 zcmV-W0Q00001b5ch_0Itp) z=>Px%3Q0skR9J=WSizCQAPkflk-Ss7w~Xe<6fbi?E6$0WlU=BBeykT#fT- z^v*4dTzh_==S{v7h_cAmD#>xVS}iAAF)Ww1g!j67#L?Q#L_fu@&3oiz4QRQ^L0L@a z9O;(QqBK|XPH(c-_sCJ0t zoJ+#L4a^A*7GwuF=gPC_0LevXAm5t~cGk(7tHqCUuf!QGRtH%8U7?9+w>sL{Eoeuy z9Ae>}gK$|ET9##)KQec3zPm!}qNbECy9N9un2y#h&&*x>rnN}DxN?66diH4xI%kW2 z^WIM}#@*G*+AeSa;L75?pK{I{F2qW%JUCj{HE^!zpq{yrFVXgZmpqw2GnahtG7y|> zxl4{)&`#91kR!;`e6-N7*K3GpY3M<#3-wrWmb~y=6CtSeG5~H(AiAUF<`BaAcs$Ch zK6oRq(xW`0?>D;V^LhBW0Jn`+&azg;(cb%M^jinG?|kckxU12lLDs4UZOE#-tl&oi e{=eSUV|)Qazygjxnx>Ed0000Tz11AFmLrP*vqFz>Ue%{+)&%DD1Jb%0n zZWcb0ap`FO3;r&Lgq&N7THZ}6%gdPl@BK1q?OWz5jS>ULE@PRhlBT)&hvqS*yuZz| zqV$@3=q9z$sQBcToYMJb5yB}6vtP{GvB7Qg!miU9YxyQPykvRhxi9V=?+W!3p8k%$ zg4{hEH&^-}usUN|Heo5JjOgs9D8<*QU5h?S+?=(sCe z&2O@1NG`Wj?d0sTKHsHTJn|E!u3+w*eQMIDio9(<*+r+{`dhI1`aQO$_K-WNFM@fU zrtEmP?QK}Av%g!-?gb2{HKZHyQc)DcAu~&O~54ZK0*vo$Mwu-wxm3?X&0Y zeue;)sJPzO8CL|1f)-{525BIjnVXoN8V`yP{j{RQ+|*)yL;ak@%G9EG!?}|iIT;i= zTyNJ;Nh{z=FX*?n5U~68_b98=O#hGR*~3O{=_ z=HJZpX^+43$Dum)o>Gu4ey1A2oVs=LZQcV49IiL(MbZ+u(h~a3YA)Ona>x#vEZtjF z(IK>#-8g=3hD6=ERZCr#JZ&zX?Imk}H2UcA8FsU8E>1}5U2}eh_^pNeZ}8vVVV_cL z^JVMdvaSD4K9gErwYu6(@A>7gFP7{-k(^&Vzx>|Q>)&fW_2;2FwY!P^bQIoDHHJBL z>EwgF3)vw4y`VY0;tUch&qjH2)`GbYZMq z<=wgGc+I*KHx?h-^xia8{rlRoO*0>->}LJ9ee(WVw);Qb*-@QjJbRy_E?y^@z?_tv zaDZiX*xFzHJsUL+ayq=ykKM&`Y;jfQ>hC8eDks void: @@ -11,7 +17,17 @@ func _ready() -> void: # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: hp_bar.frame = hp + + combo_level = clampi(floori(float(combo)/10),0,4) + Storyteller.current_coin_color = combo_colors[combo_level] + score_label.text = str(score) func _on_lander_got_hit() -> void: hp -= 1 + combo = 0 + + +func _on_lander_got_points() -> void: + score += combo_level + 1 + combo += 1 diff --git a/project.godot b/project.godot index 9dfd1d2..8795950 100644 --- a/project.godot +++ b/project.godot @@ -12,9 +12,13 @@ config_version=5 config/name="Lunar" run/main_scene="uid://hv07lm2tjwn4" -config/features=PackedStringArray("4.4", "GL Compatibility") +config/features=PackedStringArray("4.5", "GL Compatibility") config/icon="uid://bd5oswedqnenh" +[autoload] + +Storyteller="*res://storyteller.tscn" + [display] window/size/viewport_width=640 diff --git a/readme.md b/readme.md index 6cbfed8..f51066c 100644 --- a/readme.md +++ b/readme.md @@ -6,3 +6,6 @@ - [ ] respawning? - [ ] performace - [ ] score pickups + + +https://www.pixil.art/art/a-spinning-coin-62d75ee92f3d11c diff --git a/ship.gd b/ship.gd index ca38334..f239f3c 100644 --- a/ship.gd +++ b/ship.gd @@ -2,6 +2,8 @@ extends RigidBody2D signal moved signal got_hit +signal got_points + @export var thrust_power : float = 1 @export var turn_power : float = 1 diff --git a/storyteller.gd b/storyteller.gd new file mode 100644 index 0000000..8274b04 --- /dev/null +++ b/storyteller.gd @@ -0,0 +1,13 @@ +extends Node + +@export var current_coin_color : Color = Color.WHITE + + +# 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/storyteller.gd.uid b/storyteller.gd.uid new file mode 100644 index 0000000..2a4b727 --- /dev/null +++ b/storyteller.gd.uid @@ -0,0 +1 @@ +uid://2mwy5nx8gyex diff --git a/storyteller.tscn b/storyteller.tscn new file mode 100644 index 0000000..4102a3e --- /dev/null +++ b/storyteller.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://cosmoon3infqy"] + +[ext_resource type="Script" uid="uid://2mwy5nx8gyex" path="res://storyteller.gd" id="1_vv1jl"] + +[node name="Storyteller" type="Node"] +script = ExtResource("1_vv1jl")