|
@@ -8,6 +8,10 @@ var levelScenes = []
|
|
var levelCurrentNode
|
|
var levelCurrentNode
|
|
var levelIndex = -1
|
|
var levelIndex = -1
|
|
|
|
|
|
|
|
+# Used to test a level in creation
|
|
|
|
+export (String) var levelToLoop
|
|
|
|
+var levelSceneToLoop
|
|
|
|
+
|
|
var playerScene = preload("res://Player.tscn")
|
|
var playerScene = preload("res://Player.tscn")
|
|
var playerActionsLeft = ["p1_left", "p2_left", "p3_left"]
|
|
var playerActionsLeft = ["p1_left", "p2_left", "p3_left"]
|
|
var playerActionsRight = ["p1_right", "p2_right", "p3_right"]
|
|
var playerActionsRight = ["p1_right", "p2_right", "p3_right"]
|
|
@@ -16,6 +20,11 @@ func _ready():
|
|
for k in range(levelNames.size()):
|
|
for k in range(levelNames.size()):
|
|
levelScenes.append(null)
|
|
levelScenes.append(null)
|
|
|
|
|
|
|
|
+ if levelToLoop:
|
|
|
|
+ levelSceneToLoop = load("res://Levels/" + levelToLoop + ".tscn")
|
|
|
|
+ if !levelSceneToLoop:
|
|
|
|
+ push_error("Cant't load level " + levelToLoop)
|
|
|
|
+
|
|
func _unhandled_input(event):
|
|
func _unhandled_input(event):
|
|
if event.is_action("ui_accept") and event.is_pressed():
|
|
if event.is_action("ui_accept") and event.is_pressed():
|
|
if get_tree().has_group("living"):
|
|
if get_tree().has_group("living"):
|
|
@@ -26,25 +35,28 @@ func _unhandled_input(event):
|
|
|
|
|
|
func create_game():
|
|
func create_game():
|
|
# Clear if required
|
|
# Clear if required
|
|
- if (get_tree().has_group("players")):
|
|
|
|
|
|
+ if get_tree().has_group("players"):
|
|
var players = get_tree().get_nodes_in_group("players")
|
|
var players = get_tree().get_nodes_in_group("players")
|
|
for p in players:
|
|
for p in players:
|
|
p.queue_free()
|
|
p.queue_free()
|
|
- if (levelCurrentNode):
|
|
|
|
|
|
+ if levelCurrentNode:
|
|
remove_child(levelCurrentNode)
|
|
remove_child(levelCurrentNode)
|
|
levelCurrentNode.queue_free()
|
|
levelCurrentNode.queue_free()
|
|
|
|
|
|
- # Select level
|
|
|
|
- levelIndex += 1
|
|
|
|
|
|
+ if levelToLoop:
|
|
|
|
+ levelCurrentNode = levelSceneToLoop.instance()
|
|
|
|
+ else:
|
|
|
|
+ # Select next level
|
|
|
|
+ levelIndex += 1
|
|
|
|
+
|
|
|
|
+ if (levelIndex >= levelScenes.size()):
|
|
|
|
+ levelIndex = 0
|
|
|
|
|
|
- if (levelIndex >= levelScenes.size()):
|
|
|
|
- levelIndex = 0
|
|
|
|
|
|
+ if !levelScenes[levelIndex]:
|
|
|
|
+ levelScenes[levelIndex] = load(levelNames[levelIndex])
|
|
|
|
|
|
- if !levelScenes[levelIndex]:
|
|
|
|
- levelScenes[levelIndex] = load(levelNames[levelIndex])
|
|
|
|
|
|
+ levelCurrentNode = levelScenes[levelIndex].instance()
|
|
|
|
|
|
- # Load level
|
|
|
|
- levelCurrentNode = levelScenes[levelIndex].instance()
|
|
|
|
add_child(levelCurrentNode)
|
|
add_child(levelCurrentNode)
|
|
|
|
|
|
# Retrieve player spawn points
|
|
# Retrieve player spawn points
|