From 41dc281b66e1ff60fec72ef3b2c61e47c6e54d2a Mon Sep 17 00:00:00 2001 From: Melon Bread Date: Sun, 12 May 2024 00:47:14 -0400 Subject: [PATCH] Comet spins randomly --- assets/_RAW_/comet.pxo | Bin 0 -> 948 bytes assets/img/comet.png | Bin 0 -> 491 bytes assets/img/comet.png.import | 34 ++++++++++++++++++++++++++++++++++ scenes/comet.gd | 14 ++++++++++++++ scenes/comet.tscn | 12 +++++++++++- scenes/game.tscn | 6 +++++- scripts/ship.gd | 2 +- 7 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 assets/_RAW_/comet.pxo create mode 100644 assets/img/comet.png create mode 100644 assets/img/comet.png.import create mode 100644 scenes/comet.gd diff --git a/assets/_RAW_/comet.pxo b/assets/_RAW_/comet.pxo new file mode 100644 index 0000000000000000000000000000000000000000..6ab61d4c54bb6c86163ee083580dcf132e653569 GIT binary patch literal 948 zcmZ>F4sc^)00IF9hQm$_4DvuuERY)y#4~_c5{Nan>iiEV*pV}tR$XS}cvia#^hVzZ?;oD9;V>$BBf{*L$)w|Jsx7OrH$_J-E zlxAEzZM)?!#sdegZe3dK+-T)qJ4yDh<%fnPQxh1PrtX+(8N5km$5vaWPU(xR`f?t3 z{G^-rFrBnrrkh#aBf>E;V>|yk^=;d}ZBRR{2-IEh6`$c1ZCQwUct;{&Ei znnlb)35^nb9tKPj2POI%6kQxTE(js!?Jv25}*<@R($g>A|yp}cn&n&k5 zsVDENH7cuq|33Zo%rVi*UkUS_7YI*Z#Rg3tbD0>FSXkH|@G~U%aIJy@7RMO^AJ`d$ zB+dvt;S6bd&Y^WsSf^2VpL~bJhs6i%Sb_wONVo40?9@EH#Wjt`M^^E0uV=i*`!mtb z(|cAP7qAS1r9Hfchc6JSU{O1$7||lRP%tHEhkPRcQC1Zu|2Z~E!7Ou5efS{p{(#Ma zPkPe>_Brr{ v=kz4m8Jl#T868`ibZ&#s4GkTzyACtfGB7BBoW(4_AfVM)65GY<4$Q9rJI|Dh literal 0 HcmV?d00001 diff --git a/assets/img/comet.png b/assets/img/comet.png new file mode 100644 index 0000000000000000000000000000000000000000..a4a4d77ea0cf019138fe4c1cbea1609d3868e41b GIT binary patch literal 491 zcmVPx$rAb6VRCt{2o52#oAPhvo@&A7rFXB*|goN4x8{SO|nk<_PwHSjyN-0U#OJa;s zJ9Z{sqXQTXyK0uzzZAe==a64sC*KP4DX}!Mm_M(6qfF-R)%k~TS7RJ1fR&bDJ@FnU z%$z(0Cx|8Xr3EOl_O0JI>O)pbzJzjxln>lKfJ#>C9dH7KU=smS01L1J#4qK0lnY=5 z$g~uuecKgOpM-*&E?k void: + rotaion_direction = randi_range(-1, 1) + rotation_speed = randi_range(50, 250) + +func _physics_process(delta: float) -> void: + rotate(deg_to_rad(rotaion_direction * rotation_speed * delta)) + diff --git a/scenes/comet.tscn b/scenes/comet.tscn index 35cabb2..0241d65 100644 --- a/scenes/comet.tscn +++ b/scenes/comet.tscn @@ -1,3 +1,13 @@ -[gd_scene format=3 uid="uid://bsonrs8vhtly8"] +[gd_scene load_steps=3 format=3 uid="uid://bsonrs8vhtly8"] + +[ext_resource type="Texture2D" uid="uid://54mfrkbp1kcg" path="res://assets/img/comet.png" id="1_6q67h"] +[ext_resource type="Script" path="res://scenes/comet.gd" id="1_33qxe"] [node name="Comet" type="Area2D"] +script = ExtResource("1_33qxe") + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("1_6q67h") + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] +polygon = PackedVector2Array(19, -27, 22, -25, 25, -24, 27, -21, 31, -17, 32, -3, 32, 27, 27, 30, -8, 29, -17, 28, -25, 26, -32, 22, -32, 18, -23, 8, -20, 7, -21, 2, -29, -17, -29, -26, -27, -29, -25, -32, -14, -32, 0, -30) diff --git a/scenes/game.tscn b/scenes/game.tscn index 6059089..bf1e3e2 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=2 format=3 uid="uid://bdarunpk3c2eh"] +[gd_scene load_steps=3 format=3 uid="uid://bdarunpk3c2eh"] [ext_resource type="PackedScene" uid="uid://cbo47ftx0vcro" path="res://scenes/ship.tscn" id="1_esyqo"] +[ext_resource type="PackedScene" uid="uid://bsonrs8vhtly8" path="res://scenes/comet.tscn" id="2_b37uv"] [node name="Game" type="Node2D"] @@ -19,3 +20,6 @@ color = Color(0, 0, 0, 1) [node name="Ship" parent="." instance=ExtResource("1_esyqo")] z_index = 1 position = Vector2(622, 309) + +[node name="Comet" parent="." instance=ExtResource("2_b37uv")] +position = Vector2(276, 249) diff --git a/scripts/ship.gd b/scripts/ship.gd index 6071f06..b005e87 100644 --- a/scripts/ship.gd +++ b/scripts/ship.gd @@ -38,7 +38,7 @@ func fire_gun(pos : Vector2, rot : float) -> void: bullet.position = pos bullet.rotation = rot $Projectiles.add_child(bullet) - $ShootSound.play() + $ShootSounds.play() can_shoot = false $ShotCooldown.start()