Rewriting star system complete
This commit is contained in:
parent
4172b336c1
commit
350b9853f2
13 changed files with 118 additions and 70 deletions
|
|
@ -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