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