From 5a7cc356136aed5dfc9b66eaab78fa1d2bdfdfa4 Mon Sep 17 00:00:00 2001 From: ToasterPanic Date: Mon, 1 Dec 2025 20:21:10 -0500 Subject: [PATCH] Medium asteroids, orbit zones, various atmospheric changes --- project.godot | 16 +++++++++++ scenes/asteroid.tscn | 20 +++++++++++--- scenes/game.tscn | 26 +++++++++--------- scripts/asteroid.gd | 15 +++++++++++ scripts/asteroid.gd.uid | 1 + scripts/game.gd | 31 +++++++++++++-------- scripts/global.gd | 21 +++++++++++++++ scripts/global.gd.uid | 1 + scripts/player.gd | 9 +++++-- textures/asteroid_medium.png | Bin 0 -> 467 bytes textures/asteroid_medium.png.import | 40 ++++++++++++++++++++++++++++ 11 files changed, 150 insertions(+), 30 deletions(-) create mode 100644 scripts/asteroid.gd create mode 100644 scripts/asteroid.gd.uid create mode 100644 scripts/global.gd create mode 100644 scripts/global.gd.uid create mode 100644 textures/asteroid_medium.png create mode 100644 textures/asteroid_medium.png.import diff --git a/project.godot b/project.godot index 9ad690c..5bf5327 100644 --- a/project.godot +++ b/project.godot @@ -16,6 +16,10 @@ config/features=PackedStringArray("4.5", "Mobile") boot_splash/bg_color=Color(0, 0, 0, 1) config/icon="res://icon.svg" +[autoload] + +global="*res://scripts/global.gd" + [display] window/size/viewport_width=1600 @@ -83,6 +87,17 @@ boost={ , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":8,"pressure":0.0,"pressed":true,"script":null) ] } +fullscreen={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194342,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +pause={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":6,"pressure":0.0,"pressed":true,"script":null) +] +} [physics] @@ -94,4 +109,5 @@ boost={ textures/canvas_textures/default_texture_filter=0 renderer/rendering_method="mobile" +environment/defaults/default_clear_color=Color(0, 0, 0, 1) 2d/snap/snap_2d_transforms_to_pixel=true diff --git a/scenes/asteroid.tscn b/scenes/asteroid.tscn index a2ca58a..18228f1 100644 --- a/scenes/asteroid.tscn +++ b/scenes/asteroid.tscn @@ -1,16 +1,30 @@ -[gd_scene load_steps=3 format=3 uid="uid://dgng5vdhn6anc"] +[gd_scene load_steps=6 format=3 uid="uid://dgng5vdhn6anc"] [ext_resource type="Texture2D" uid="uid://co67k1hqadpv4" path="res://textures/asteroid_small.png" id="1_akfqu"] +[ext_resource type="Script" uid="uid://cvk1sd0aqqmpq" path="res://scripts/asteroid.gd" id="1_t4se3"] +[ext_resource type="Texture2D" uid="uid://dibsut6ee6qd5" path="res://textures/asteroid_medium.png" id="2_6mo6b"] [sub_resource type="CircleShape2D" id="CircleShape2D_uwrxv"] radius = 16.0 +[sub_resource type="CircleShape2D" id="CircleShape2D_t4se3"] +radius = 29.614185 + [node name="Asteroid" type="RigidBody2D"] mass = 2.5 linear_damp = 4.0 +script = ExtResource("1_t4se3") -[node name="Sprite" type="Sprite2D" parent="."] +[node name="Variants" type="Node2D" parent="."] + +[node name="Small" type="Sprite2D" parent="Variants"] texture = ExtResource("1_akfqu") -[node name="CollisionShape" type="CollisionShape2D" parent="."] +[node name="CollisionShape" type="CollisionShape2D" parent="Variants/Small"] shape = SubResource("CircleShape2D_uwrxv") + +[node name="Mediun" type="Sprite2D" parent="Variants"] +texture = ExtResource("2_6mo6b") + +[node name="CollisionShape" type="CollisionShape2D" parent="Variants/Mediun"] +shape = SubResource("CircleShape2D_t4se3") diff --git a/scenes/game.tscn b/scenes/game.tscn index 29397af..0958b0c 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -1,11 +1,10 @@ -[gd_scene load_steps=10 format=3 uid="uid://bauklhpieuivd"] +[gd_scene load_steps=9 format=3 uid="uid://bauklhpieuivd"] [ext_resource type="Script" uid="uid://d0qswyhwbhdua" path="res://scripts/game.gd" id="1_u5sy4"] [ext_resource type="Texture2D" uid="uid://dtwo7g0ipc4k" path="res://textures/ship_1.png" id="1_uwrxv"] [ext_resource type="Script" uid="uid://bfxfkrkaebxk0" path="res://scripts/player.gd" id="1_yqjtg"] [ext_resource type="AudioStream" uid="uid://brqjxveo53kco" path="res://sounds/boost.mp3" id="2_iywne"] [ext_resource type="AudioStream" uid="uid://5tr30e1tmdp6" path="res://sounds/collision.mp3" id="2_lbhrr"] -[ext_resource type="PackedScene" uid="uid://dgng5vdhn6anc" path="res://scenes/asteroid.tscn" id="3_lnu2h"] [ext_resource type="AudioStream" uid="uid://b1ung55xg31l3" path="res://sounds/boost_finish.mp3" id="3_p57ef"] [sub_resource type="CircleShape2D" id="CircleShape2D_uwrxv"] @@ -51,18 +50,6 @@ debug_color = Color(0.9686392, 0, 0.4696517, 0.41960785) [node name="Unloadables" type="Node2D" parent="."] -[node name="Asteroid" parent="Unloadables" instance=ExtResource("3_lnu2h")] -position = Vector2(-42, -173) - -[node name="Asteroid2" parent="Unloadables" instance=ExtResource("3_lnu2h")] -position = Vector2(227, 37) - -[node name="Asteroid3" parent="Unloadables" instance=ExtResource("3_lnu2h")] -position = Vector2(-216, 134) - -[node name="Asteroid4" parent="Unloadables" instance=ExtResource("3_lnu2h")] -position = Vector2(-192, -427) - [node name="UI" type="CanvasLayer" parent="."] [node name="Control" type="Control" parent="UI"] @@ -79,4 +66,15 @@ offset_right = 40.0 offset_bottom = 24.0 text = "BOOST: 100" +[node name="Distance" type="Label" parent="UI/Control"] +layout_mode = 1 +anchors_preset = 4 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_top = -12.0 +offset_right = 136.0 +offset_bottom = 12.0 +grow_vertical = 2 +text = "DIST: 2048" + [connection signal="body_shape_entered" from="Player/Hitbox" to="Player" method="_on_hitbox_body_shape_entered"] diff --git a/scripts/asteroid.gd b/scripts/asteroid.gd new file mode 100644 index 0000000..ba92660 --- /dev/null +++ b/scripts/asteroid.gd @@ -0,0 +1,15 @@ +extends RigidBody2D + +func _ready() -> void: + var variants = $Variants.get_children() + var variant = variants[randi_range(0, variants.size() - 1)] + + $Variants.remove_child(variant) + + add_child(variant) + + var collision_shape = variant.get_node("CollisionShape") + variant.remove_child(collision_shape) + add_child(collision_shape) + + $Variants.queue_free() diff --git a/scripts/asteroid.gd.uid b/scripts/asteroid.gd.uid new file mode 100644 index 0000000..0b655c9 --- /dev/null +++ b/scripts/asteroid.gd.uid @@ -0,0 +1 @@ +uid://cvk1sd0aqqmpq diff --git a/scripts/game.gd b/scripts/game.gd index 25d300a..db0f563 100644 --- a/scripts/game.gd +++ b/scripts/game.gd @@ -14,6 +14,8 @@ func chunk_to_world(position: Vector2) -> Vector2: func _process(delta: float) -> void: $UI/Control/BoostText.text = "BOOST: " + str($Player.boost) + $UI/Control/Distance.text = "DIST: " + str(floori($Player.position.length())) + chunk_tick_timer -= delta if chunk_tick_timer < 0: @@ -39,19 +41,26 @@ func _process(delta: float) -> void: "time_to_unload": 0, } - var amount = 4 - - var i = 0 - - while i < amount: - var asteroid = asteroid_scene.instantiate() - - asteroid.rotation = randf_range(-5.0, 5.0) - asteroid.position = chunk_to_world(chunk_position) + Vector2(randi_range(0, 1024), randi_range(0, 1024)) + var world_position = chunk_to_world(chunk_position) + var orbit_zone = null + for n in global.orbit_zones: - $Unloadables.add_child(asteroid) + if world_position.length() < n.distance: + continue + orbit_zone = n - i += 1 + for n in orbit_zone.spawns: + var i = 0 + + while i < n.amount_min: + var asteroid = asteroid_scene.instantiate() + + asteroid.rotation = randf_range(-5.0, 5.0) + asteroid.position = chunk_to_world(chunk_position) + Vector2(randi_range(0, 1024), randi_range(0, 1024)) + + $Unloadables.add_child(asteroid) + + i += 1 y_mod += 1 diff --git a/scripts/global.gd b/scripts/global.gd new file mode 100644 index 0000000..0d831ba --- /dev/null +++ b/scripts/global.gd @@ -0,0 +1,21 @@ +extends Node + +var orbit_zones = [ + { + "name": "Test Zone", + "distance": 0, + "spawns": [ + { + "type": "asteroid", + "chance_percent": 100, + "amount_min": 4, + "amount_max": 5, + } + ] + }, + { + "name": "Test Zone 2", + "distance": 2048 * 1.5, + "spawns": [] + } +] diff --git a/scripts/global.gd.uid b/scripts/global.gd.uid new file mode 100644 index 0000000..eb92109 --- /dev/null +++ b/scripts/global.gd.uid @@ -0,0 +1 @@ +uid://bh7d7yrshcjqg diff --git a/scripts/player.gd b/scripts/player.gd index 407bbd8..2333a08 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -14,6 +14,9 @@ func _process(delta: float) -> void: if Input.is_action_pressed("boost"): boost -= delta * 40 + if camera_shake_power < 2: + camera_shake_power = 2 + if boost <= 0: boost = 0 boosting = false @@ -41,18 +44,20 @@ func _process(delta: float) -> void: func _physics_process(delta: float) -> void: var axis = Input.get_axis("turn_left", "turn_right") + var movement_axis = Input.get_axis("forward", "backward") angular_velocity = deg_to_rad(180 * axis) var final_speed = 512 if boosting: + movement_axis = -1 final_speed = 1024 # Slow down on collision and gradually speed up - if time_since_last_collision < 1: final_speed *= (time_since_last_collision + 0.15) * 2 + if time_since_last_collision < 0.85: final_speed *= (time_since_last_collision + 0.15) - var new_velocity = transform.y * Input.get_axis("forward", "backward") * final_speed + var new_velocity = transform.y * movement_axis * final_speed if (new_velocity.length() > linear_velocity.length() - 12): linear_velocity = new_velocity diff --git a/textures/asteroid_medium.png b/textures/asteroid_medium.png new file mode 100644 index 0000000000000000000000000000000000000000..9a94ad23f6b5d1943907977b72d09d5beb33898a GIT binary patch literal 467 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D%zdp%toLn`LH zoqcgrvjUIHN5B97r@uX&>ZaW|fuY;;Ty(UrnYYVQXRpTmzKI9VeYVLz*zYXz-<+@2 z-I;R&tFuT6WB5>PS|deinW;D($j0Vi`=`+ zT7QT6eo&3R4)YqZ`Bhd2v=SMj7^J2#D$7}xAAOQ*P|7pwxA%b@_LQi(3Hz9%n$zwz zTroJ<%D6Jg>0@rel~d=WD@48>>+JK+RLGy+@br=9oimIgATwqeFz6a|@N;edqKFM!r!Ts7V3K`>;lZ;q4!jzf4by)f@MTw7#2q6!!Rz(hIn6qg^gp_@ zS7`k6(&<{nx`31U0@H;S#tg=cn7`&TcG^92XP>ff%N^GJ`jr#-EdDt@sjYFBwb{%a zb#(n5pN)H%EtL0fa^5D{Inyf3a(Y=qMe^k%c`Kw0j5eBG(-Dqv42-^|QT4TB+EG)^ zohP>zlx+R9`KYH)gz4nqTM^}R1Ur|UEO*ce+8t_kqeXw(#3kjYeqRm-#u9_4tDnm{ Hr-UW|NQcBO literal 0 HcmV?d00001 diff --git a/textures/asteroid_medium.png.import b/textures/asteroid_medium.png.import new file mode 100644 index 0000000..4ccf79e --- /dev/null +++ b/textures/asteroid_medium.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dibsut6ee6qd5" +path="res://.godot/imported/asteroid_medium.png-2f424bbaac58810b8d103ec74fa6bc89.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://textures/asteroid_medium.png" +dest_files=["res://.godot/imported/asteroid_medium.png-2f424bbaac58810b8d103ec74fa6bc89.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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