Initialization of the player, now reads the Levels initial gravity and direction. Also re-worked the way switches work.

recode0.2
Jorge Vásquez Pérez 2 years ago
parent d4e97136b3
commit 88968b3871

@ -1,10 +1,15 @@
extends Node2D
@export var dir: int
@export var ini_dir: int
@export var ini_grav_vec: Vector2
#var asp : AudioStreamPlayer
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
#asp = $AudioStreamPlayer
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

@ -3,19 +3,22 @@
[ext_resource type="PackedScene" uid="uid://dn0lboldm331y" path="res://scenes/modules/platform_02.tscn" id="1_cbvrq"]
[ext_resource type="Script" path="res://scenes/levels/Level.gd" id="1_qbkcb"]
[ext_resource type="PackedScene" uid="uid://cuefds30ddne1" path="res://scenes/modules/platform_00.tscn" id="2_jkfr1"]
[ext_resource type="Script" path="res://scripts/null.gd" id="3_m83jh"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_7hfyn"]
[ext_resource type="Script" path="res://scripts/switch.gd" id="4_0mgws"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_0f50m"]
size = Vector2(7318, 557)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_7hfyn"]
[node name="Level" type="Node2D"]
position = Vector2(0, 96)
script = ExtResource("1_qbkcb")
dir = 1
ini_dir = 1
ini_grav_vec = Vector2(0, 1)
metadata/_edit_horizontal_guides_ = [-298.0, 601.0, -324.0]
[node name="SpawnPoint" type="Node2D" parent="."]
position = Vector2(0, -100)
[node name="Platforms" type="CanvasGroup" parent="."]
@ -62,36 +65,35 @@ position = Vector2(2492, 59)
[node name="Platform_32" parent="Platforms" instance=ExtResource("1_cbvrq")]
position = Vector2(3287, 59)
[node name="Checkpoints" type="CanvasGroup" parent="."]
[node name="End" type="Area2D" parent="Checkpoints"]
position = Vector2(3755, 128)
scale = Vector2(16.672, 1)
script = ExtResource("3_m83jh")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Checkpoints/End"]
shape = SubResource("RectangleShape2D_7hfyn")
[node name="Abysses" type="CanvasGroup" parent="."]
[node name="Switches" type="CanvasGroup" parent="."]
[node name="Abyss" type="Area2D" parent="Abysses"]
[node name="Abyss" type="Area2D" parent="Switches"]
position = Vector2(28, -394)
script = ExtResource("4_0mgws")
type = 1
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Abysses/Abyss"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Switches/Abyss"]
position = Vector2(951, 1182)
shape = SubResource("RectangleShape2D_0f50m")
[node name="Abyss2" type="Area2D" parent="Abysses"]
position = Vector2(0, -2964)
[node name="Abyss2" type="Area2D" parent="Switches"]
position = Vector2(0, -1885)
script = ExtResource("4_0mgws")
type = 1
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Abysses/Abyss2"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Switches/Abyss2"]
position = Vector2(951, 1182)
shape = SubResource("RectangleShape2D_0f50m")
[node name="Switches" type="CanvasGroup" parent="."]
[node name="End" type="Area2D" parent="Switches"]
position = Vector2(3755, 128)
scale = Vector2(16.672, 1)
script = ExtResource("4_0mgws")
metadata/_edit_group_ = true
[node name="Direction" type="Node2D" parent="Switches"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Switches/End"]
shape = SubResource("RectangleShape2D_7hfyn")
[node name="Gravity" type="Node2D" parent="Switches"]
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]

@ -19,11 +19,21 @@ func load_plyr():
G.add_child( plyr )
P = $Game/Player
init_plyr()
func init_lvl():
#connect signals
var switches = $Game/Level/Switches.get_children()
for s in switches:
s.body_entered.connect( _on_switch_body_entered.bind(s.type))
# $player.combat_trigger.connect(start_combat)
pass
func init_plyr():
P.set_gravity_vector( Vector2(0,1) )
#P.init()
P.set_direction( L.ini_dir )
P.set_gravity_vector( L.ini_grav_vec )
P.position = L.get_node("SpawnPoint").position
# Called when the node enters the scene tree for the first time.
func _ready():
@ -34,8 +44,13 @@ func _ready():
load_lvl(curr_lvl)
load_plyr()
func _on_switch_body_entered(body,type):
if type == 0: #end switch
pass
elif type == 1: #abyss switch
P.fall()
elif type == 2: #gravity switch
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):

@ -6,7 +6,7 @@ const ANGULAR_ACCELERATION = 7.5;
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
var gravity_vector: Vector2
var direction: int = 1
var direction: int
var World: Node2D
var ap: AnimationPlayer
var asp: AudioStreamPlayer
@ -81,9 +81,10 @@ func _physics_process(delta):
move_and_slide()
func _on_activate_camera():
cam.make_current()
#func _on_activate_camera():
#print("is this being used?")
#cam.make_current()
func _on_fall():
func fall():
asp.stream = fall_sound
asp.play()

@ -1,11 +1,9 @@
extends Node
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

@ -0,0 +1,11 @@
extends Area2D
@export var type: int # 0, end 1 abyss, 2 gravity
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
Loading…
Cancel
Save