Initialization of the player, now reads the Levels initial gravity and direction. Also re-worked the way switches work.
This commit is contained in:
+18
-3
@@ -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):
|
||||
|
||||
+5
-4
@@ -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
|
||||
Reference in New Issue
Block a user