From 485cd463b22e12394cd232812e2c3789ef37ab1c Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sat, 9 Jan 2021 23:30:27 +0100 Subject: Adds a bunch of characters and fixes things --- Levels/Level.gd | 29 ++++++++++++++++++++++------- Levels/Level_0001.tscn | 16 ++++++++++------ 2 files changed, 32 insertions(+), 13 deletions(-) (limited to 'Levels') diff --git a/Levels/Level.gd b/Levels/Level.gd index 57288b2..34463b6 100644 --- a/Levels/Level.gd +++ b/Levels/Level.gd @@ -1,13 +1,6 @@ extends Node2D -export var starting_position = Vector2(0, 0) -export var camera_limit_left = 0 -export var camera_limit_top = 0 -export var camera_limit_right = 0 -export var camera_limit_bottom = 0 - - var idx = 0 var HUD = CanvasLayer.new() @@ -21,6 +14,9 @@ func _ready(): self.HUD.add_child(self.LabelTimer) self.HUD.add_child(self.LevelMap) self.add_child(self.HUD) + + var character = load("res://Characters/" + Network.player.character + ".tscn").instance() + self.set_player(character) func _process(delta): @@ -28,5 +24,24 @@ func _process(delta): self.LabelTimer.text = "%.2fs" % self.timer +func set_player(character: KinematicBody2D): + character.position.x = $Character.position.x + character.position.y = $Character.position.y + for child in $Character.get_children(): + if not child is Camera2D: + $Character.remove_child(child) + $Character.replace_by(character) + + +func respawn_player(): + var instance_level = Global.get_instance_level(self.idx) + instance_level.timer = self.timer # timer continues playing + Global.change_scene_to_instance(instance_level) + + func end_level(): Global.end_level(self) + + +func cancel_level(): + Global.cancel_level() diff --git a/Levels/Level_0001.tscn b/Levels/Level_0001.tscn index 89dba41..bcb4d7b 100644 --- a/Levels/Level_0001.tscn +++ b/Levels/Level_0001.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] -[ext_resource path="res://Assets/platforms.tres" type="TileSet" id=1] -[ext_resource path="res://Character.tscn" type="PackedScene" id=2] +[ext_resource path="res://Assets/Environment/generic_platformer.tres" type="TileSet" id=1] +[ext_resource path="res://Characters/Character.tscn" type="PackedScene" id=2] [ext_resource path="res://Objects/Flag.tscn" type="PackedScene" id=3] [ext_resource path="res://Levels/Level_0001.gd" type="Script" id=4] +[ext_resource path="res://Objects/CheckFall.tscn" type="PackedScene" id=5] [node name="Level_0001" type="Node2D"] script = ExtResource( 4 ) @@ -17,12 +18,11 @@ format = 1 tile_data = PoolIntArray( 327692, 0, 6, 327693, 0, 8, 393228, 0, 65542, 393229, 0, 65545, 458764, 0, 65542, 458765, 0, 65545, 524295, 0, 0, 524296, 0, 1, 524297, 0, 1, 524298, 0, 1, 524299, 0, 1, 524300, 0, 65542, 524301, 0, 65545, 524302, 0, 1, 524303, 0, 1, 524304, 0, 1, 524305, 0, 1, 524306, 0, 1, 524307, 0, 2, 589836, 0, 131078, 589837, 0, 131080, 720918, 0, 0, 720919, 0, 1, 720920, 0, 1, 720921, 0, 1, 720922, 0, 1, 720923, 0, 1, 720924, 0, 1, 720925, 0, 1, 720926, 0, 1, 720927, 0, 1, 720928, 0, 1, 720929, 0, 1, 720930, 0, 1, 720931, 0, 1, 720932, 0, 1, 720933, 0, 1, 720934, 0, 1, 720935, 0, 1, 720936, 0, 1, 720937, 0, 2, 917518, 0, 6, 917519, 0, 8, 917523, 0, 6, 917524, 0, 8, 983054, 0, 65542, 983055, 0, 65545, 983059, 0, 65542, 983060, 0, 65545, 1048590, 0, 65542, 1048591, 0, 65545, 1048595, 0, 65542, 1048596, 0, 65545, 1114126, 0, 65542, 1114127, 0, 65545, 1114131, 0, 65542, 1114132, 0, 65545, 1179662, 0, 65542, 1179663, 0, 65545, 1179667, 0, 65542, 1179668, 0, 65545, 1245198, 0, 65542, 1245199, 0, 65545, 1245203, 0, 65542, 1245204, 0, 65545, 1310734, 0, 65542, 1310735, 0, 65545, 1310739, 0, 65542, 1310740, 0, 65545, 1376270, 0, 65542, 1376271, 0, 65545, 1376275, 0, 65542, 1376276, 0, 65545, 1441806, 0, 65542, 1441807, 0, 65545, 1441811, 0, 65542, 1441812, 0, 65545, 1507342, 0, 65542, 1507343, 0, 65545, 1507347, 0, 65542, 1507348, 0, 65545, 1572878, 0, 65542, 1572879, 0, 65545, 1572883, 0, 65542, 1572884, 0, 65545, 1638414, 0, 65542, 1638415, 0, 65545, 1638419, 0, 65542, 1638420, 0, 65545, 1703950, 0, 131078, 1703951, 0, 131080, 1703955, 0, 131078, 1703956, 0, 131080, 1900544, 0, 0, 1900545, 0, 1, 1900546, 0, 1, 1900547, 0, 1, 1900548, 0, 1, 1900549, 0, 1, 1900550, 0, 1, 1900551, 0, 1, 1900552, 0, 1, 1900553, 0, 1, 1900554, 0, 1, 1900555, 0, 1, 1900556, 0, 1, 1900557, 0, 1, 1900558, 0, 1, 1900559, 0, 1, 1900560, 0, 1, 1900561, 0, 1, 1900562, 0, 1, 1900563, 0, 1, 1900564, 0, 1, 1900565, 0, 2 ) [node name="Flag" parent="." instance=ExtResource( 3 )] -position = Vector2( 602.469, 111.673 ) -collision_layer = 0 +position = Vector2( 640, 144 ) +scale = Vector2( 2, 2 ) [node name="Character" parent="." instance=ExtResource( 2 )] position = Vector2( 144.471, 115.947 ) -collision_mask = 15 [node name="Camera2D" type="Camera2D" parent="Character"] current = true @@ -34,3 +34,7 @@ limit_bottom = 500 drag_margin_h_enabled = true drag_margin_v_enabled = true editor_draw_limits = true + +[node name="CheckFall" parent="." instance=ExtResource( 5 )] +position = Vector2( 320, 520 ) +scale = Vector2( 2, 1 ) -- cgit v1.2.3