midori-school/levels/ui/Cutscenes.gd

115 lines
4.2 KiB
GDScript3
Raw Normal View History

2024-04-23 00:19:53 +02:00
extends Node2D
var level
var player
var music
var bgsound := AudioStreamPlayer.new()
var sfx1 := AudioStreamPlayer.new()
var musictrack
var isboss
2024-12-07 18:48:09 +01:00
var press = false
2024-11-07 21:39:59 +01:00
var bhud = load("res://levels/bottomhud.tscn").instance()
2024-04-23 00:19:53 +02:00
var ishud = true
# Called when the node enters the scene tree for the first time.
func _ready():
2024-08-05 00:33:57 +02:00
Global.live = 1
2024-04-23 00:19:53 +02:00
add_child(bgsound)
add_child(sfx1)
2024-11-07 21:39:59 +01:00
level = load(Global.cutscenes[Global.ccutscene][0]).instance()
2024-08-05 00:33:57 +02:00
musictrack = Global.musictracks[Global.cutscenes[Global.ccutscene][2]]
2024-04-23 00:19:53 +02:00
music = load(musictrack)
2024-11-07 21:39:59 +01:00
call_deferred("_level")
call_deferred("_bhud")
2024-04-23 00:19:53 +02:00
#get_tree().root.add_child.call_deferred(player)
bgsound.stream = music
2024-07-14 23:55:40 +02:00
bgsound.mix_target = 1
2024-05-12 21:54:52 +02:00
bgsound.play(0)
2024-04-23 00:19:53 +02:00
# Called every frame. 'delta' is the elapsed time since the previous frame.
2024-05-12 21:54:52 +02:00
#func _process(delta):
#Global.xm = 0
#Global.ym = 0
#var velocity = Vector2.ZERO
#if Global.live == 1 && !Input.is_key_pressed(KEY_V) && !Input.is_joy_button_pressed(0,JOY_BUTTON_RIGHT_SHOULDER):
# if Input.get_joy_axis(0,JOY_AXIS_LEFT_X) > 0.2 || Input.get_joy_axis(0,JOY_AXIS_LEFT_Y) > 0.2 || Input.get_joy_axis(0,JOY_AXIS_LEFT_X) < -0.2 || Input.get_joy_axis(0,JOY_AXIS_LEFT_Y) < -0.2:
# Global.xm = Input.get_joy_axis(0,JOY_AXIS_LEFT_X)
# Global.ym = Input.get_joy_axis(0,JOY_AXIS_LEFT_Y)
# else:
# if Input.is_action_pressed("ui_left"):
# Global.xm = -1
# if Input.is_action_pressed("ui_right"):
# Global.xm = 1
# if Input.is_action_pressed("ui_up"):
# Global.ym = -1
# if Input.is_action_pressed("ui_down"):
# Global.ym = 1
2024-04-23 00:19:53 +02:00
#velocity = (Vector2.RIGHT.rotated(rotation) * -100 * Global.xm * delta)-Vector2.UP.rotated(rotation) * -100 * Global.ym * delta
func _input(event):
2024-12-07 18:48:09 +01:00
if (Input.is_action_just_pressed("ui_accept") || Input.is_action_just_pressed("mclick")) && !press:
press = true
if (Input.is_action_just_released("ui_accept") || Input.is_action_just_released("mclick")) && press:
2024-05-19 21:12:02 +02:00
if Global.cutscenes[Global.ccutscene][3]:
2024-07-16 02:22:33 +02:00
var ccutscene = Global.ccutscene
Global.ccutscene = null
2024-05-19 21:12:02 +02:00
get_tree().root.remove_child(bhud)
get_tree().root.remove_child(level)
bgsound.stop()
if Global.debug:
2024-11-07 21:39:59 +01:00
get_tree().change_scene("res://levels/ui/scene.tscn")
2024-05-19 21:12:02 +02:00
else:
2024-11-07 21:39:59 +01:00
get_tree().change_scene(Global.cutscenes[ccutscene][1])
2024-05-19 21:12:02 +02:00
else:
Global.ccutscene += 1
get_tree().root.remove_child(level)
2024-11-07 21:39:59 +01:00
level = load(Global.cutscenes[Global.ccutscene][0]).instance()
2024-08-05 00:33:57 +02:00
if musictrack != Global.musictracks[Global.cutscenes[Global.ccutscene][2]]:
2024-05-19 21:12:02 +02:00
bgsound.stop()
2024-08-05 00:33:57 +02:00
musictrack = Global.musictracks[Global.cutscenes[Global.ccutscene][2]]
2024-05-19 21:12:02 +02:00
music = load(musictrack)
bgsound.stream = music
bgsound.play(0)
2024-11-07 21:39:59 +01:00
call_deferred("_level")
2024-12-07 18:48:09 +01:00
press = false
2024-05-12 21:54:52 +02:00
#if (Global.live == 1 && (Input.is_key_pressed(KEY_V) && Input.is_key_pressed(KEY_UP)) ||(Input.is_joy_button_pressed(0,JOY_BUTTON_RIGHT_SHOULDER) && Input.is_joy_button_pressed(0,JOY_BUTTON_DPAD_UP))):
# if Global.debug:
# if Global.dparty[0][0] != null:
# Global.dcpchar = 0
# else:
# if Global.party[0][0] != null:
# Global.cpchar = 0
#elif (Global.live == 1 && (Input.is_key_pressed(KEY_V) && Input.is_key_pressed(KEY_RIGHT)) ||(Input.is_joy_button_pressed(0,JOY_BUTTON_RIGHT_SHOULDER) && Input.is_joy_button_pressed(0,JOY_BUTTON_DPAD_RIGHT))):
# if Global.debug:
# if Global.dparty[1][0] != null:
# Global.dcpchar = 1
# else:
# if Global.party[1][0] != null:
# Global.cpchar = 1
#elif (Global.live == 1 && (Input.is_key_pressed(KEY_V) && Input.is_key_pressed(KEY_DOWN)) ||(Input.is_joy_button_pressed(0,JOY_BUTTON_RIGHT_SHOULDER) && Input.is_joy_button_pressed(0,JOY_BUTTON_DPAD_DOWN))):
# if Global.debug:
# if Global.dparty[2][0] != null:
# Global.dcpchar = 2
# else:
# if Global.party[2][0] != null:
# Global.cpchar = 2
#elif (Global.live == 1 && (Input.is_key_pressed(KEY_V) && Input.is_key_pressed(KEY_LEFT)) ||(Input.is_joy_button_pressed(0,JOY_BUTTON_RIGHT_SHOULDER) && Input.is_joy_button_pressed(0,JOY_BUTTON_DPAD_LEFT))):
# if Global.debug:
# if Global.dparty[3][0] != null:
# Global.dcpchar = 3
# else:
# if Global.party[3][0] != null:
# Global.cpchar = 3
#if Global.bossready:
# Global.bossready = false
# sfx1.stream = load(Global.sfxtracks[1])
# sfx1.play(0)
# bgsound.play(0)
2024-11-07 21:39:59 +01:00
func _level():
get_tree().root.add_child(level)
func _bhud():
get_tree().root.add_child(bhud)