Kept goiong, but not quite happy.
This commit is contained in:
+11
-3
@@ -1,5 +1,5 @@
|
||||
extends Control
|
||||
|
||||
extends CanvasLayer
|
||||
var mainScene
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
@@ -16,5 +16,13 @@ func _on_quit():
|
||||
get_tree().quit()
|
||||
|
||||
func _on_play():
|
||||
get_tree().change_scene_to_file("res://scenes/main.tscn")
|
||||
$".".hide()
|
||||
var w = get_node("/root/World");
|
||||
|
||||
if !w:
|
||||
get_tree().change_scene_to_file( "res://scenes/main.tscn" )
|
||||
else:
|
||||
w.load_level()
|
||||
w.player_spawn()
|
||||
w.show()
|
||||
|
||||
|
||||
+5
-3
@@ -1,5 +1,5 @@
|
||||
extends Control
|
||||
|
||||
extends CanvasLayer
|
||||
var start = preload("res://scenes/UI/Start.tscn").instantiate()
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
@@ -16,5 +16,7 @@ func _on_quit():
|
||||
get_tree().quit()
|
||||
|
||||
func load_start_menu():
|
||||
get_tree().change_scene_to_file("res://scenes/UI/Start.tscn")
|
||||
$".".hide()
|
||||
get_tree().get_root().add_child( start )
|
||||
#get_tree().change_scene_to_file("res://scenes/UI/Start.tscn")
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
extends CanvasLayer
|
||||
var mainScene
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
#$CenterContainer/VBoxContainer/Button05.button_up.connect( _on_quit )
|
||||
#$CenterContainer/VBoxContainer/Button01.button_up.connect( _on_play )
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
|
||||
func _on_quit():
|
||||
get_tree().quit()
|
||||
|
||||
func _on_play():
|
||||
$".".hide()
|
||||
var w = get_node("/root/World");
|
||||
|
||||
if !w:
|
||||
get_tree().change_scene_to_file( "res://scenes/main.tscn" )
|
||||
else:
|
||||
w.player_spawn()
|
||||
w.show()
|
||||
|
||||
+38
-8
@@ -3,12 +3,17 @@ extends Node2D
|
||||
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
|
||||
var gravity_vector = ProjectSettings.get_setting("physics/2d/default_gravity_vector")
|
||||
var player = load("res://scenes/pDasher.tscn")
|
||||
var level = load("res://scenes/levels/level_1.tscn")
|
||||
var level
|
||||
var direction: int = 1
|
||||
var paused: bool = false
|
||||
var asp: AudioStreamPlayer
|
||||
var switch_gravity_sound = preload("res://audio/switch_gravity.wav")
|
||||
|
||||
var win = preload("res://scenes/UI/Win.tscn").instantiate()
|
||||
var end = preload("res://scenes/UI/End.tscn").instantiate()
|
||||
@export var Levels: Array[Resource] = [ preload("res://scenes/levels/level_0.tscn"), preload("res://scenes/levels/level_1.tscn") ]
|
||||
var level_n: int = 0
|
||||
var pDasher
|
||||
|
||||
|
||||
## WORLD METHODS
|
||||
func switch_gravity():
|
||||
@@ -20,17 +25,40 @@ func switch_direction():
|
||||
|
||||
## NAVIGATION
|
||||
func player_fail():
|
||||
get_tree().change_scene_to_file("res://scenes/UI/End.tscn")
|
||||
$".".hide()
|
||||
#$pDasher.queue_free()
|
||||
|
||||
#ONLY IF NOT THERE ALREADY
|
||||
|
||||
if !$"."/End :
|
||||
get_tree().get_root().add_child( end )
|
||||
else:
|
||||
$"."/End.show()
|
||||
#get_tree().change_scene_to_file("res://scenes/UI/End.tscn")
|
||||
|
||||
func player_win():
|
||||
get_tree().change_scene_to_file("res://scenes/UI/Win.tscn")
|
||||
level_n += 1
|
||||
load_level()
|
||||
$"." .hide()
|
||||
get_tree().get_root().add_child( win )
|
||||
#get_tree().change_scene_to_file("res://scenes/UI/Win.tscn")
|
||||
|
||||
func player_spawn():
|
||||
pDasher.position = Vector2(0,0 )
|
||||
|
||||
func load_level():
|
||||
if level_n == null:
|
||||
level_n = 0
|
||||
level = Levels[level_n]
|
||||
|
||||
func _ready():
|
||||
|
||||
load_level()
|
||||
|
||||
asp = $AudioStreamPlayer
|
||||
|
||||
#load player and level
|
||||
get_node("/root/World").add_child( player.instantiate() ) #absolute way...
|
||||
get_node("/root/World").add_child( player.instantiate() )
|
||||
get_node("/root/World").add_child( level.instantiate() ) #relative way meaning <ME> or whatever node this script is attached to.
|
||||
|
||||
# manage signals connections
|
||||
@@ -51,7 +79,9 @@ func _ready():
|
||||
for checkpoint in checkpoints:
|
||||
#print( checkpoint )
|
||||
checkpoint.body_entered.connect( _on_checkpoint_body_entered )
|
||||
|
||||
|
||||
pDasher = get_node("/root/World/pDasher")
|
||||
player_spawn()
|
||||
## MAIN
|
||||
#func _process(delta):
|
||||
#pass
|
||||
@@ -70,8 +100,8 @@ func _on_gswitch_body_entered(body):
|
||||
switch_gravity()
|
||||
|
||||
func _on_dswitch_body_entered(body):
|
||||
var dasher = get_node("/root/World/pDasher")
|
||||
dasher.switch_direction()
|
||||
pDasher
|
||||
pDasher.switch_direction()
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user