From 67342c82ccf31a48a2ef8894ceedda2aa92be7ec Mon Sep 17 00:00:00 2001 From: Ruslan Ignatov Date: Sat, 29 Nov 2025 21:19:30 +0300 Subject: [PATCH] Added background --- game/passage.gd | 12 +++++-- game/passage.tscn | 48 +++++++++++++++++++++++++++- images/particles.png | 2 +- images/passage/background.png | 3 ++ images/passage/background.png.import | 40 +++++++++++++++++++++++ 5 files changed, 100 insertions(+), 5 deletions(-) create mode 100644 images/passage/background.png create mode 100644 images/passage/background.png.import diff --git a/game/passage.gd b/game/passage.gd index 0e5da40..8d9a62c 100644 --- a/game/passage.gd +++ b/game/passage.gd @@ -5,11 +5,17 @@ extends Node2D signal player_died -const PLAYER := preload("res://game/entities/ships/player/player_ship.tscn") - - @onready var enemy_swamp_controller : EnemySwampController = $EnemySwampController @onready var enemy_timer : Timer = $EnemyTimer +@onready var paralax_1 : Parallax2D = $Background/Parallax1 +@onready var paralax_2 : Parallax2D = $Background/Parallax2 +@onready var paralax_3 : Parallax2D = $Background/Parallax3 + + +func _ready() -> void: + paralax_1.scroll_offset.x = randf_range(1, paralax_1.repeat_size.x) + paralax_2.scroll_offset.x = randf_range(1, paralax_2.repeat_size.x) + paralax_3.scroll_offset.x = randf_range(1, paralax_3.repeat_size.x) func _on_enemy_timer_timeout() -> void: diff --git a/game/passage.tscn b/game/passage.tscn index e6e9226..d5a68a9 100644 --- a/game/passage.tscn +++ b/game/passage.tscn @@ -1,11 +1,24 @@ -[gd_scene load_steps=5 format=3 uid="uid://dgc0087kvarx6"] +[gd_scene load_steps=9 format=3 uid="uid://dgc0087kvarx6"] [ext_resource type="Script" uid="uid://c6gpm3edyr4nu" path="res://game/passage.gd" id="1_ltkyg"] [ext_resource type="PackedScene" uid="uid://cpn5x0ijgl7ei" path="res://game/controllers/enemy_swamp_controller.tscn" id="2_72vqi"] [ext_resource type="PackedScene" uid="uid://br074cqcnul3d" path="res://game/entities/ships/player/player_ship.tscn" id="3_r3x05"] +[ext_resource type="Texture2D" uid="uid://mvcnpsfsyiq6" path="res://images/passage/background.png" id="4_cuj01"] [sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_ltkyg"] +[sub_resource type="AtlasTexture" id="AtlasTexture_yetnv"] +atlas = ExtResource("4_cuj01") +region = Rect2(0, 0, 3200, 360) + +[sub_resource type="AtlasTexture" id="AtlasTexture_cuj01"] +atlas = ExtResource("4_cuj01") +region = Rect2(0, 360, 3200, 360) + +[sub_resource type="AtlasTexture" id="AtlasTexture_u0ams"] +atlas = ExtResource("4_cuj01") +region = Rect2(0, 720, 3200, 360) + [node name="Passage" type="Node2D"] script = ExtResource("1_ltkyg") @@ -46,5 +59,38 @@ wait_time = 3.0 one_shot = true autostart = true +[node name="Background" type="Node2D" parent="."] +z_index = -100 + +[node name="Parallax1" type="Parallax2D" parent="Background"] +scroll_offset = Vector2(0, 180) +repeat_size = Vector2(3200, 0) +autoscroll = Vector2(-1, 0) +follow_viewport = false +ignore_camera_scroll = true + +[node name="Sprite2D" type="Sprite2D" parent="Background/Parallax1"] +texture = SubResource("AtlasTexture_yetnv") + +[node name="Parallax2" type="Parallax2D" parent="Background"] +scroll_offset = Vector2(0, 180) +repeat_size = Vector2(3200, 0) +autoscroll = Vector2(-5, 0) +follow_viewport = false +ignore_camera_scroll = true + +[node name="Sprite2D" type="Sprite2D" parent="Background/Parallax2"] +texture = SubResource("AtlasTexture_cuj01") + +[node name="Parallax3" type="Parallax2D" parent="Background"] +scroll_offset = Vector2(0, 180) +repeat_size = Vector2(3200, 0) +autoscroll = Vector2(-10, 0) +follow_viewport = false +ignore_camera_scroll = true + +[node name="Sprite2D" type="Sprite2D" parent="Background/Parallax3"] +texture = SubResource("AtlasTexture_u0ams") + [connection signal="destroyed" from="PlayerShip" to="." method="_on_player_ship_destroyed"] [connection signal="timeout" from="EnemyTimer" to="." method="_on_enemy_timer_timeout"] diff --git a/images/particles.png b/images/particles.png index b30b50d..e65dabb 100644 --- a/images/particles.png +++ b/images/particles.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:aad5ce75165075035f960b01714caba4b319297665e516f1b1f65f2bf2d9102c +oid sha256:89f7eb8a3bb713c072fc890e4f982f0cda3daa3c69fe2f1be6d8f33a8f4f0cb6 size 260 diff --git a/images/passage/background.png b/images/passage/background.png new file mode 100644 index 0000000..c5021bd --- /dev/null +++ b/images/passage/background.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe67a49229ab7e7431d5e70cdc9da0cd446497610bcb5a3406f89e03a702074e +size 8566 diff --git a/images/passage/background.png.import b/images/passage/background.png.import new file mode 100644 index 0000000..55ac4e8 --- /dev/null +++ b/images/passage/background.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://mvcnpsfsyiq6" +path="res://.godot/imported/background.png-baa9109f75488375644438f924a247f5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://images/passage/background.png" +dest_files=["res://.godot/imported/background.png-baa9109f75488375644438f924a247f5.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