Rewriting star system complete
This commit is contained in:
parent
4172b336c1
commit
350b9853f2
13 changed files with 118 additions and 70 deletions
|
|
@ -3,7 +3,7 @@
|
|||
[ext_resource type="Script" path="res://scripts/menu/MainMenu.gd" id="1_2wax0"]
|
||||
[ext_resource type="Shader" uid="uid://f6lhks6rp5jw" path="res://shaders/testicles.tres" id="1_on8wy"]
|
||||
[ext_resource type="Gradient" uid="uid://c6bcjydbwm5id" path="res://scenes/SpaceGradient.tres" id="2_7racd"]
|
||||
[ext_resource type="PackedScene" uid="uid://dpggye27ln436" path="res://scenes/Star Systems/Required Scenes/StarsController.tscn" id="4_g7254"]
|
||||
[ext_resource type="PackedScene" uid="uid://dpggye27ln436" path="res://scenes/Star Systems/Required Scenes/star_generator.tscn" id="4_g7254"]
|
||||
[ext_resource type="Script" path="res://scripts/menu/MainMenuButton.gd" id="5_q6x10"]
|
||||
|
||||
[sub_resource type="FastNoiseLite" id="FastNoiseLite_rtgkw"]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=12 format=3 uid="uid://dok3i8u5t1ka4"]
|
||||
[gd_scene load_steps=10 format=3 uid="uid://dok3i8u5t1ka4"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bjkshql8ut6hk" path="res://scenes/Ships/ship.tscn" id="1_6x7bu"]
|
||||
[ext_resource type="Script" path="res://scripts/Ship/player_ship.gd" id="2_oqdd7"]
|
||||
|
|
@ -58,26 +58,6 @@ func _process(_delta):
|
|||
text = unformatted_text.format([ship.shield.capacity, ship.shield.max_capacity])
|
||||
"
|
||||
|
||||
[sub_resource type="Theme" id="Theme_d8vjy"]
|
||||
default_font_size = 48
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_6uw1d"]
|
||||
resource_name = "pause_controller"
|
||||
script/source = "extends Control
|
||||
|
||||
# TODO: implement save
|
||||
|
||||
## Resumes game
|
||||
func _on_resume_button_up():
|
||||
get_tree().current_scene.unpause()
|
||||
|
||||
## Saves profile and exits game
|
||||
func _on_exit_button_up():
|
||||
get_tree().current_scene.unpause()
|
||||
get_tree().change_scene_to_file(\"res://scenes/MainMenu.tscn\")
|
||||
#Game.profile_save(get_tree().current_scene)
|
||||
"
|
||||
|
||||
[node name="PlayerShip" instance=ExtResource("1_6x7bu")]
|
||||
script = ExtResource("2_oqdd7")
|
||||
|
||||
|
|
@ -121,36 +101,8 @@ offset_bottom = 661.0
|
|||
text = "Shield: {0} / {1} units"
|
||||
script = SubResource("GDScript_q1sx2")
|
||||
|
||||
[node name="PauseController" type="Control" parent="ColorableGUI" index="4"]
|
||||
process_mode = 2
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
theme = SubResource("Theme_d8vjy")
|
||||
script = SubResource("GDScript_6uw1d")
|
||||
|
||||
[node name="Resume" type="Button" parent="ColorableGUI/PauseController" index="0"]
|
||||
layout_mode = 0
|
||||
offset_left = 444.0
|
||||
offset_top = 254.0
|
||||
offset_right = 779.0
|
||||
offset_bottom = 329.0
|
||||
text = "Resume game"
|
||||
|
||||
[node name="Exit" type="Button" parent="ColorableGUI/PauseController" index="1"]
|
||||
layout_mode = 0
|
||||
offset_left = 449.0
|
||||
offset_top = 357.0
|
||||
offset_right = 763.0
|
||||
offset_bottom = 432.0
|
||||
text = "Save and exit"
|
||||
|
||||
[node name="NonColorableGUI" type="CanvasLayer" parent="." index="6"]
|
||||
|
||||
[node name="Camera" type="Camera2D" parent="." index="7"]
|
||||
zoom = Vector2(0.5, 0.5)
|
||||
script = ExtResource("5_rclap")
|
||||
|
||||
[connection signal="button_up" from="ColorableGUI/PauseController/Resume" to="ColorableGUI/PauseController" method="_on_resume_button_up"]
|
||||
[connection signal="button_up" from="ColorableGUI/PauseController/Exit" to="ColorableGUI/PauseController" method="_on_exit_button_up"]
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
[ext_resource type="Script" path="res://scripts/Ship/weapons.gd" id="5_ooyny"]
|
||||
|
||||
[node name="Ship" type="Node2D"]
|
||||
process_mode = 1
|
||||
script = ExtResource("2_n14ml")
|
||||
|
||||
[node name="HullHolder" type="Node" parent="."]
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
[ext_resource type="PackedScene" uid="uid://ccrs28h3b2tfy" path="res://scenes/MainShip.tscn" id="1_6fvpc"]
|
||||
[ext_resource type="Script" path="res://scripts/Spaceold.gd" id="1_ppaw3"]
|
||||
[ext_resource type="PackedScene" uid="uid://dpggye27ln436" path="res://scenes/Star Systems/Required Scenes/StarsController.tscn" id="3_jbyyq"]
|
||||
[ext_resource type="PackedScene" uid="uid://dpggye27ln436" path="res://scenes/Star Systems/Required Scenes/star_generator.tscn" id="3_jbyyq"]
|
||||
[ext_resource type="Script" path="res://scripts/misc/ProjectilesContainer.gd" id="4_dtv2c"]
|
||||
[ext_resource type="PackedScene" uid="uid://dbtrc26016xov" path="res://scenes/Base.tscn" id="5_bjt5p"]
|
||||
[ext_resource type="PackedScene" uid="uid://523dme3h6d6c" path="res://scenes/npcships/NPCShipDefault.tscn" id="6_67746"]
|
||||
|
|
|
|||
49
scenes/Star Systems/Required Scenes/pause_controller.tscn
Normal file
49
scenes/Star Systems/Required Scenes/pause_controller.tscn
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://c7is7y341f6wa"]
|
||||
|
||||
[sub_resource type="Theme" id="Theme_d8vjy"]
|
||||
default_font_size = 48
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_6uw1d"]
|
||||
resource_name = "pause_controller"
|
||||
script/source = "extends Control
|
||||
|
||||
# TODO: implement save
|
||||
|
||||
## Resumes game
|
||||
func _on_resume_button_up():
|
||||
get_tree().current_scene.unpause()
|
||||
|
||||
## Saves profile and exits game
|
||||
func _on_exit_button_up():
|
||||
get_tree().current_scene.unpause()
|
||||
get_tree().change_scene_to_file(\"res://scenes/MainMenu.tscn\")
|
||||
#Game.profile_save(get_tree().current_scene)
|
||||
"
|
||||
|
||||
[node name="PauseController" type="Control"]
|
||||
process_mode = 2
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
theme = SubResource("Theme_d8vjy")
|
||||
script = SubResource("GDScript_6uw1d")
|
||||
|
||||
[node name="Resume" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 444.0
|
||||
offset_top = 254.0
|
||||
offset_right = 779.0
|
||||
offset_bottom = 329.0
|
||||
text = "Resume game"
|
||||
|
||||
[node name="Exit" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 449.0
|
||||
offset_top = 357.0
|
||||
offset_right = 763.0
|
||||
offset_bottom = 432.0
|
||||
text = "Save and exit"
|
||||
|
||||
[connection signal="button_up" from="Resume" to="." method="_on_resume_button_up"]
|
||||
[connection signal="button_up" from="Exit" to="." method="_on_exit_button_up"]
|
||||
20
scenes/Star Systems/star_system_debug.tscn
Normal file
20
scenes/Star Systems/star_system_debug.tscn
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://crneq2enhxsw5"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bsnrcw64qr2hr" path="res://scenes/Star Systems/star_system_template.tscn" id="1_2ai1l"]
|
||||
[ext_resource type="PackedScene" uid="uid://dok3i8u5t1ka4" path="res://scenes/Ships/player_ship.tscn" id="7_jyplv"]
|
||||
|
||||
[node name="StarSystem" instance=ExtResource("1_2ai1l")]
|
||||
width = 16384
|
||||
height = 16384
|
||||
|
||||
[node name="Stars" parent="." index="0"]
|
||||
scroll_offset = Vector2(681.667, 317.783)
|
||||
stars_amount = 4000
|
||||
|
||||
[node name="Nebula" parent="Background" index="0" node_paths=PackedStringArray("tracked_node")]
|
||||
tracked_node = NodePath("../../PlayerShip")
|
||||
color_background = Color(0.276474, 0.0962249, 0.200656, 1)
|
||||
|
||||
[node name="PlayerShip" parent="." index="4" instance=ExtResource("7_jyplv")]
|
||||
process_mode = 0
|
||||
position = Vector2(19, 10)
|
||||
|
|
@ -1,24 +1,28 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://bsnrcw64qr2hr"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://bsnrcw64qr2hr"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/star_system.gd" id="1_xx8w2"]
|
||||
[ext_resource type="PackedScene" uid="uid://dpggye27ln436" path="res://scenes/Star Systems/Required Scenes/StarsController.tscn" id="2_iqrn0"]
|
||||
[ext_resource type="PackedScene" uid="uid://dpggye27ln436" path="res://scenes/Star Systems/Required Scenes/star_generator.tscn" id="2_iqrn0"]
|
||||
[ext_resource type="Script" path="res://scripts/misc/ProjectilesContainer.gd" id="3_h5cm3"]
|
||||
[ext_resource type="Material" uid="uid://bawhivm5cr2w" path="res://shaders/materials/nebula_shader.tres" id="4_o0ld7"]
|
||||
[ext_resource type="Script" path="res://scripts/nebula.gd" id="5_la84n"]
|
||||
[ext_resource type="PackedScene" uid="uid://c7is7y341f6wa" path="res://scenes/Star Systems/Required Scenes/pause_controller.tscn" id="6_61vq5"]
|
||||
|
||||
[node name="StarSystem" type="Node"]
|
||||
process_mode = 3
|
||||
script = ExtResource("1_xx8w2")
|
||||
width = 1280
|
||||
height = 720
|
||||
|
||||
[node name="Stars" parent="." instance=ExtResource("2_iqrn0")]
|
||||
|
||||
[node name="ProjectileContainer" type="Node" parent="."]
|
||||
process_mode = 1
|
||||
script = ExtResource("3_h5cm3")
|
||||
|
||||
[node name="Background" type="CanvasLayer" parent="."]
|
||||
process_mode = 1
|
||||
layer = -10
|
||||
|
||||
[node name="Nebula" type="ColorRect" parent="Background"]
|
||||
z_index = -100
|
||||
material = ExtResource("4_o0ld7")
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
|
|
@ -27,3 +31,6 @@ grow_horizontal = 2
|
|||
grow_vertical = 2
|
||||
script = ExtResource("5_la84n")
|
||||
color_background = Color(0.36, 0.18612, 0.1116, 1)
|
||||
|
||||
[node name="PauseController" parent="." instance=ExtResource("6_61vq5")]
|
||||
visible = false
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
[ext_resource type="Shader" path="res://shaders/ship.gdshader" id="2_15op6"]
|
||||
[ext_resource type="Script" path="res://scripts/misc/ProjectilesContainer.gd" id="3_amh71"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ogy53"]
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_qudgt"]
|
||||
resource_local_to_scene = true
|
||||
resource_name = "Shield Material"
|
||||
shader = ExtResource("2_15op6")
|
||||
|
|
@ -19,7 +19,8 @@ shader_parameter/bublic_size = 20.0
|
|||
script = ExtResource("1_du5mm")
|
||||
|
||||
[node name="PlayerShip" parent="." instance=ExtResource("1_b1l1c")]
|
||||
material = SubResource("ShaderMaterial_ogy53")
|
||||
process_mode = 0
|
||||
material = SubResource("ShaderMaterial_qudgt")
|
||||
position = Vector2(608, 352)
|
||||
scale = Vector2(0.5, 0.5)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
extends Node2D
|
||||
# TODO: rewrite to use resource as button info
|
||||
var map_width = 1280
|
||||
var map_height = 720
|
||||
# TODO: probably rewrite menu to make is actual StarSystem, because they have common properties
|
||||
var width = 1280
|
||||
var height = 720
|
||||
var menu_id = 0
|
||||
@onready var b1 = $Control/MenuButton1
|
||||
@onready var b2 = $Control/MenuButton2
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
extends Node
|
||||
|
||||
# TODO: this just doesn't work
|
||||
|
||||
## Star scene
|
||||
@export var star : PackedScene
|
||||
## Affects how many stars will be generated and places on whole system
|
||||
|
|
@ -9,7 +7,7 @@ extends Node
|
|||
## Affects how much space on borders of the star system will be empty
|
||||
@export_range(0, 1) var compress_space_amount = 0.1
|
||||
## Shortcut to get_parent()
|
||||
@onready var star_system: StarSystem = get_parent()
|
||||
@onready var star_system: = get_parent()
|
||||
|
||||
func _ready():
|
||||
var compress_multiplier = 1.0 - compress_space_amount
|
||||
|
|
@ -25,4 +23,3 @@ func _ready():
|
|||
parallax_layers[distance].add_child(star_inst)
|
||||
var position = Vector2(x, y)
|
||||
star_inst.position = position
|
||||
print(position)
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@ extends AnimatedSprite2D
|
|||
|
||||
func _ready():
|
||||
randomize()
|
||||
var Size : float = randf_range(0.5, 2)
|
||||
var size : float = randf_range(0.5, 2)
|
||||
frame = randi_range(0, 7)
|
||||
scale = Vector2(Size, Size)
|
||||
scale = Vector2(size, size)
|
||||
speed_scale = randf_range(0, 2)
|
||||
var Colors = [Color.LIGHT_BLUE, Color.WHITE, Color.LIGHT_GOLDENROD, Color.YELLOW, Color.ORANGE, Color.ORANGE_RED, Color.RED]
|
||||
modulate = Colors[randi_range(0, 6)]
|
||||
print("Star born at",global_position)
|
||||
var colors = [Color.LIGHT_BLUE, Color.WHITE, Color.LIGHT_GOLDENROD, Color.YELLOW, Color.ORANGE, Color.ORANGE_RED, Color.RED]
|
||||
modulate = colors.pick_random()
|
||||
|
|
|
|||
|
|
@ -2,16 +2,37 @@ extends Node
|
|||
|
||||
class_name StarSystem
|
||||
|
||||
## Width of the system. Limits stars generation and camera bounds
|
||||
@export var width: int = 8192
|
||||
## Height of the system. Limits stars generation and camera bounds
|
||||
@export var height: int = 8192
|
||||
|
||||
## Pause controller node reference
|
||||
@onready var pause_controller = $PauseController
|
||||
|
||||
## Player ship reference. May be null.
|
||||
var player_ship: PlayerShip
|
||||
|
||||
func _ready():
|
||||
player_ship = get_node_or_null("PlayerShip")
|
||||
|
||||
# adjust player ship camera if player ship exists
|
||||
if player_ship != null:
|
||||
player_ship.camera.limit_left = -width / 2
|
||||
player_ship.camera.limit_right = -width / 2
|
||||
player_ship.camera.limit_right = width / 2
|
||||
player_ship.camera.limit_top = -height / 2
|
||||
player_ship.camera.limit_bottom = -height / 2
|
||||
player_ship.camera.limit_bottom = height / 2
|
||||
|
||||
## Pause the game. Remember to unpause it when switching scenes!
|
||||
func pause():
|
||||
get_tree().paused = true
|
||||
pause_controller.visible = true
|
||||
|
||||
## Unpause the game.
|
||||
func unpause():
|
||||
get_tree().paused = false
|
||||
pause_controller.visible = false
|
||||
|
||||
func _process(_delta):
|
||||
if Input.is_action_just_released("pause"):
|
||||
unpause() if get_tree().paused else pause()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue