Rewriting ships: Added some player interface and started rewriting star system
This commit is contained in:
parent
6957169ba5
commit
4172b336c1
20 changed files with 300 additions and 139 deletions
|
|
@ -1,4 +1,4 @@
|
|||
extends Node2D
|
||||
extends Node
|
||||
|
||||
class_name ProjectileContainer
|
||||
|
||||
|
|
@ -6,3 +6,6 @@ static var instance : ProjectileContainer
|
|||
|
||||
func _ready():
|
||||
instance = self
|
||||
|
||||
func _exit_tree():
|
||||
instance = null
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
extends Node
|
||||
|
||||
@export var star : PackedScene
|
||||
@export var stars_amount = 1000
|
||||
@export var compress_space_amount = 0.5
|
||||
|
||||
func _ready():
|
||||
var compress_multiplier = 1-compress_space_amount
|
||||
|
||||
var map_width_halved = get_tree().current_scene.map_width * compress_multiplier
|
||||
var map_height_halved = get_tree().current_scene.map_height * compress_multiplier
|
||||
for i in range(stars_amount):
|
||||
var star_inst = star.instantiate()
|
||||
var x = randi_range(-map_width_halved, map_width_halved)
|
||||
var y = randi_range(-map_height_halved, map_height_halved)
|
||||
var distance = randi_range(0,get_child_count()-1)
|
||||
get_children()[distance].add_child(star_inst)
|
||||
star_inst.position = Vector2(x, y)
|
||||
28
scripts/misc/stars_generator.gd
Normal file
28
scripts/misc/stars_generator.gd
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
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
|
||||
@export var stars_amount = 1000
|
||||
## 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()
|
||||
|
||||
func _ready():
|
||||
var compress_multiplier = 1.0 - compress_space_amount
|
||||
var parallax_layers = get_children()
|
||||
var width_halved = star_system.width / 2
|
||||
var height_halved = star_system.height / 2
|
||||
for i in range(stars_amount):
|
||||
var star_inst = star.instantiate()
|
||||
var x = randi_range(-width_halved, width_halved) * compress_multiplier
|
||||
var y = randi_range(-height_halved, height_halved) * compress_multiplier
|
||||
# Decides parallax layer which star belongs to
|
||||
var distance = randi_range(0, get_child_count() - 1)
|
||||
parallax_layers[distance].add_child(star_inst)
|
||||
var position = Vector2(x, y)
|
||||
star_inst.position = position
|
||||
print(position)
|
||||
Loading…
Add table
Add a link
Reference in a new issue