diff --git a/Prefabs/lander.tscn b/Prefabs/lander.tscn new file mode 100644 index 0000000..8b5752f --- /dev/null +++ b/Prefabs/lander.tscn @@ -0,0 +1,58 @@ +[gd_scene load_steps=5 format=3 uid="uid://crrbht7mwhgyc"] + +[ext_resource type="Script" uid="uid://cd54ktlkabbla" path="res://ship.gd" id="1_do8h0"] +[ext_resource type="Texture2D" uid="uid://bd5oswedqnenh" path="res://Sprites/LanderArt.png" id="2_do8h0"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_ykrsh"] +size = Vector2(8, 2) + +[sub_resource type="Gradient" id="Gradient_do8h0"] +offsets = PackedFloat32Array(0, 0.0886699, 1) +colors = PackedColorArray(1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0) + +[node name="Lander" type="RigidBody2D" node_paths=PackedStringArray("particles_l", "particles_r")] +gravity_scale = 0.2 +script = ExtResource("1_do8h0") +thrust_power = 500.0 +turn_power = 1000.0 +particles_l = NodePath("Particles/ThrusterLeft") +particles_r = NodePath("Particles/ThrusterRight") + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("2_do8h0") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(-12, 15) +shape = SubResource("RectangleShape2D_ykrsh") + +[node name="CollisionShape2D2" type="CollisionShape2D" parent="."] +position = Vector2(12, 15) +shape = SubResource("RectangleShape2D_ykrsh") + +[node name="Particles" type="Node2D" parent="."] + +[node name="ThrusterLeft" type="CPUParticles2D" parent="Particles"] +position = Vector2(-12, 15) +direction = Vector2(0, 1) +spread = 0.0 +gravity = Vector2(0, 0) +initial_velocity_min = 56.0 +initial_velocity_max = 56.0 +damping_min = 34.4 +damping_max = 60.8 +scale_amount_min = 6.0 +scale_amount_max = 6.0 +color_ramp = SubResource("Gradient_do8h0") + +[node name="ThrusterRight" type="CPUParticles2D" parent="Particles"] +position = Vector2(12, 15) +direction = Vector2(0, 1) +spread = 0.0 +gravity = Vector2(0, 0) +initial_velocity_min = 56.0 +initial_velocity_max = 56.0 +damping_min = 34.4 +damping_max = 60.8 +scale_amount_min = 6.0 +scale_amount_max = 6.0 +color_ramp = SubResource("Gradient_do8h0") diff --git a/Sprites/LanderArt.pdn b/Sprites/LanderArt.pdn new file mode 100644 index 0000000..63a88f4 Binary files /dev/null and b/Sprites/LanderArt.pdn differ diff --git a/Sprites/LanderArt.png b/Sprites/LanderArt.png new file mode 100644 index 0000000..b3e1b63 Binary files /dev/null and b/Sprites/LanderArt.png differ diff --git a/Sprites/LanderArt.png.import b/Sprites/LanderArt.png.import new file mode 100644 index 0000000..67138a6 --- /dev/null +++ b/Sprites/LanderArt.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bd5oswedqnenh" +path="res://.godot/imported/LanderArt.png-f496178f1c14f00dc1c8e97ba4d43656.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/LanderArt.png" +dest_files=["res://.godot/imported/LanderArt.png-f496178f1c14f00dc1c8e97ba4d43656.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/start.pdn b/Sprites/start.pdn new file mode 100644 index 0000000..e08bbfa Binary files /dev/null and b/Sprites/start.pdn differ diff --git a/Sprites/start.png b/Sprites/start.png new file mode 100644 index 0000000..f801098 Binary files /dev/null and b/Sprites/start.png differ diff --git a/Sprites/start.png.import b/Sprites/start.png.import new file mode 100644 index 0000000..829590d --- /dev/null +++ b/Sprites/start.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://evhjxwdbsmlo" +path="res://.godot/imported/start.png-e66cd9e4fa09dd546b814b1a0c2c199c.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/start.png" +dest_files=["res://.godot/imported/start.png-e66cd9e4fa09dd546b814b1a0c2c199c.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/autoscroll.gd b/autoscroll.gd new file mode 100644 index 0000000..7093990 --- /dev/null +++ b/autoscroll.gd @@ -0,0 +1,18 @@ +extends Camera2D + +@export var camera_speed : float = 10 +var active : bool = false + +# 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: + position.x += delta * camera_speed + + +func _on_lander_moved() -> void: + active = true diff --git a/autoscroll.gd.uid b/autoscroll.gd.uid new file mode 100644 index 0000000..d98889f --- /dev/null +++ b/autoscroll.gd.uid @@ -0,0 +1 @@ +uid://bltj2frs6vqwj diff --git a/game.tscn b/game.tscn new file mode 100644 index 0000000..80600d2 --- /dev/null +++ b/game.tscn @@ -0,0 +1,55 @@ +[gd_scene load_steps=8 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="Texture2D" uid="uid://evhjxwdbsmlo" path="res://Sprites/start.png" id="2_e2o6t"] + +[sub_resource type="Gradient" id="Gradient_mwb40"] +offsets = PackedFloat32Array(0.806763, 1) + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_80nbo"] +frequency = 0.1855 +domain_warp_enabled = true +domain_warp_amplitude = 43.465 + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_mwb40"] +width = 6400 +height = 360 +color_ramp = SubResource("Gradient_mwb40") +noise = SubResource("FastNoiseLite_80nbo") + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_feb5d"] +size = Vector2(115, 20) + +[node name="Game" type="Node2D"] + +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="ParallaxBackground" type="ParallaxBackground" parent="CanvasLayer"] + +[node name="ParallaxLayer" type="ParallaxLayer" parent="CanvasLayer/ParallaxBackground"] +motion_scale = Vector2(0.5, 0) + +[node name="TextureRect" type="TextureRect" parent="CanvasLayer/ParallaxBackground/ParallaxLayer"] +offset_right = 40.0 +offset_bottom = 40.0 +texture = SubResource("NoiseTexture2D_mwb40") + +[node name="Camera2D" type="Camera2D" parent="."] +anchor_mode = 0 +script = ExtResource("1_feb5d") + +[node name="Lander" parent="." instance=ExtResource("1_80nbo")] +position = Vector2(95, 324) + +[node name="Start" type="StaticBody2D" parent="."] +position = Vector2(320, 180) + +[node name="Sprite2D" type="Sprite2D" parent="Start"] +texture = ExtResource("2_e2o6t") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Start"] +position = Vector2(-262.5, 170) +shape = SubResource("RectangleShape2D_feb5d") + +[connection signal="moved" from="Lander" to="Camera2D" method="_on_lander_moved"] diff --git a/project.godot b/project.godot index 980d3d8..750f886 100644 --- a/project.godot +++ b/project.godot @@ -11,10 +11,16 @@ config_version=5 [application] config/name="Lunar" -run/main_scene="uid://d2waabvrlsfs8" +run/main_scene="uid://hv07lm2tjwn4" config/features=PackedStringArray("4.4", "GL Compatibility") config/icon="res://icon.svg" +[display] + +window/size/viewport_width=640 +window/size/viewport_height=360 +window/stretch/mode="canvas_items" + [input] thrust={ @@ -38,5 +44,6 @@ turn_right={ [rendering] +textures/canvas_textures/default_texture_filter=0 renderer/rendering_method="gl_compatibility" renderer/rendering_method.mobile="gl_compatibility" diff --git a/ship.gd b/ship.gd index 66302db..15806a2 100644 --- a/ship.gd +++ b/ship.gd @@ -1,7 +1,11 @@ extends RigidBody2D +signal moved + @export var thrust_power : float = 1 @export var turn_power : float = 1 +@export var particles_l : CPUParticles2D +@export var particles_r : CPUParticles2D # Called when the node enters the scene tree for the first time. func _ready() -> void: @@ -10,9 +14,15 @@ func _ready() -> void: # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: + pass + +func _physics_process(delta: float) -> void: var turning : float = Input.get_axis("turn_left","turn_right") * turn_power var thrust : float = Input.get_action_strength("thrust") * thrust_power - + particles_l.emitting = thrust != 0 + particles_r.emitting = thrust != 0 + if Input.is_action_just_pressed("thrust"): + moved.emit() + #pass apply_torque(turning) apply_force(Vector2(-thrust,-thrust) * transform.y ) - diff --git a/test.tscn b/test.tscn index a9ee996..eba0481 100644 --- a/test.tscn +++ b/test.tscn @@ -1,18 +1,15 @@ -[gd_scene load_steps=5 format=3 uid="uid://d2waabvrlsfs8"] +[gd_scene load_steps=4 format=3 uid="uid://d2waabvrlsfs8"] [ext_resource type="Texture2D" uid="uid://lkj8ecm5p4g6" path="res://icon.svg" id="1_8uh7m"] -[ext_resource type="Script" uid="uid://cd54ktlkabbla" path="res://ship.gd" id="2_6uqi0"] +[ext_resource type="PackedScene" uid="uid://crrbht7mwhgyc" path="res://Prefabs/lander.tscn" id="2_8uh7m"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_ppyta"] size = Vector2(128, 26) -[sub_resource type="RectangleShape2D" id="RectangleShape2D_ykrsh"] -size = Vector2(38, 38) - [node name="Node2D" type="Node2D"] [node name="StaticBody2D" type="StaticBody2D" parent="."] -position = Vector2(597, 583) +position = Vector2(407, 23) [node name="Sprite2D" type="Sprite2D" parent="StaticBody2D"] modulate = Color(0, 0, 0, 1) @@ -23,7 +20,7 @@ texture = ExtResource("1_8uh7m") shape = SubResource("RectangleShape2D_ppyta") [node name="StaticBody2D2" type="StaticBody2D" parent="."] -position = Vector2(932, 437) +position = Vector2(409, 110) [node name="Sprite2D" type="Sprite2D" parent="StaticBody2D2"] modulate = Color(0, 0, 0, 1) @@ -45,7 +42,7 @@ texture = ExtResource("1_8uh7m") shape = SubResource("RectangleShape2D_ppyta") [node name="StaticBody2D4" type="StaticBody2D" parent="."] -position = Vector2(796, 107) +position = Vector2(555, 243) [node name="Sprite2D" type="Sprite2D" parent="StaticBody2D4"] modulate = Color(0, 0, 0, 1) @@ -55,16 +52,5 @@ texture = ExtResource("1_8uh7m") [node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D4"] shape = SubResource("RectangleShape2D_ppyta") -[node name="RigidBody2D" type="RigidBody2D" parent="."] -position = Vector2(597, 548) -gravity_scale = 0.2 -script = ExtResource("2_6uqi0") -thrust_power = 500.0 -turn_power = 1000.0 - -[node name="Sprite2D" type="Sprite2D" parent="RigidBody2D"] -scale = Vector2(0.3, 0.3) -texture = ExtResource("1_8uh7m") - -[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"] -shape = SubResource("RectangleShape2D_ykrsh") +[node name="Lander" parent="." instance=ExtResource("2_8uh7m")] +position = Vector2(223, 258)