mirror of
https://github.com/HarmonyHoney/tiny_crate.git
synced 2026-01-23 02:34:53 +00:00
Background loading!! Stages are now filled in after stage select is loaded (:
General cleanup & Actor.is_select_process = false enable to process during stage select (-;
This commit is contained in:
parent
71390ec0e5
commit
d581a9d056
10 changed files with 62 additions and 63 deletions
|
|
@ -38,6 +38,8 @@ var time_since_floor := 0
|
|||
# ignore this actor's solidity
|
||||
var ignore_actor : Actor
|
||||
|
||||
export var is_select_process := false
|
||||
|
||||
func _enter_tree():
|
||||
if Engine.editor_hint: return
|
||||
Shared.actors.append(self)
|
||||
|
|
@ -46,9 +48,11 @@ func _exit_tree():
|
|||
if Engine.editor_hint: return
|
||||
Shared.actors.erase(self)
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
position = position.floor()
|
||||
|
||||
if Engine.editor_hint or (Shared.is_level_select and !is_select_process):
|
||||
set_physics_process(false)
|
||||
|
||||
func _physics_process(delta):
|
||||
if Engine.editor_hint:
|
||||
|
|
|
|||
|
|
@ -17,11 +17,8 @@ var shake_dist = 0
|
|||
|
||||
var scene_slam = preload("res://src/fx/Slam.tscn")
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
if Engine.editor_hint or Shared.is_level_select:
|
||||
set_physics_process(false)
|
||||
return
|
||||
if Engine.editor_hint or Shared.is_level_select: return
|
||||
|
||||
spr_pos = node_sprite.position
|
||||
|
||||
|
|
@ -29,6 +26,11 @@ func _ready():
|
|||
is_on_floor = true
|
||||
shake_dist = 1
|
||||
|
||||
func _physics_process(delta):
|
||||
if Engine.editor_hint: return
|
||||
|
||||
is_push = false
|
||||
|
||||
func hit_floor():
|
||||
speed.x = 0
|
||||
node_audio.pitch_scale = 1 + rand_range(-0.2, 0.2)
|
||||
|
|
@ -43,13 +45,6 @@ func hit_floor():
|
|||
inst.position = center()
|
||||
get_parent().add_child(inst)
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _physics_process(delta):
|
||||
if Engine.editor_hint:
|
||||
return
|
||||
|
||||
is_push = false
|
||||
|
||||
# push box
|
||||
func push(dir : int):
|
||||
if is_push:
|
||||
|
|
|
|||
|
|
@ -12,10 +12,8 @@ export var star_speed := 6
|
|||
export var star_orbit := 10
|
||||
var star_rot = 0
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
if Engine.editor_hint:
|
||||
return
|
||||
if Engine.editor_hint: return
|
||||
|
||||
# create dust
|
||||
for i in dust_count - 1:
|
||||
|
|
@ -30,10 +28,8 @@ func _ready():
|
|||
for i in star_count - 1:
|
||||
node_stars.add_child($Stars/Star.duplicate())
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _physics_process(delta):
|
||||
if Engine.editor_hint:
|
||||
return
|
||||
if Engine.editor_hint: return
|
||||
|
||||
# move dust
|
||||
for i in node_dust.get_children():
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ script = ExtResource( 2 )
|
|||
hitbox_x = 6
|
||||
hitbox_y = 6
|
||||
tag = "exit"
|
||||
is_select_process = true
|
||||
dust_speed = 0.1
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
|
|
|
|||
|
|
@ -8,13 +8,8 @@ var is_done := false
|
|||
onready var node_sprite : Sprite = $Sprite
|
||||
onready var node_audio : AudioStreamPlayer2D = $Audio
|
||||
|
||||
func _ready():
|
||||
if Engine.editor_hint:
|
||||
return
|
||||
|
||||
func _physics_process(delta):
|
||||
if Engine.editor_hint:
|
||||
return
|
||||
if Engine.editor_hint: return
|
||||
|
||||
if is_done:
|
||||
pass
|
||||
|
|
@ -27,6 +22,4 @@ func _physics_process(delta):
|
|||
node_audio.play()
|
||||
else:
|
||||
is_hit = is_area_solid_actor(position.x, position.y)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ var is_push = false
|
|||
var push_clock = 0.0
|
||||
var push_fade = 0.0
|
||||
|
||||
var scene_box = preload("res://src/actor/Box.tscn")
|
||||
var scene_explosion = preload("res://src/fx/Explosion.tscn")
|
||||
var scene_explosion2 = preload("res://src/fx/Explosion2.tscn")
|
||||
|
||||
|
|
@ -52,15 +51,16 @@ var btnp_pick = false
|
|||
export var is_attract_mode = false
|
||||
|
||||
func _enter_tree():
|
||||
if Engine.editor_hint: return
|
||||
if Engine.editor_hint or Shared.is_level_select: return
|
||||
|
||||
Shared.player = self
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
if Engine.editor_hint or Shared.is_level_select:
|
||||
set_physics_process(false)
|
||||
return
|
||||
if Engine.editor_hint: return
|
||||
|
||||
node_sprite.flip_h = randf() > 0.5
|
||||
|
||||
if Shared.is_level_select: return
|
||||
|
||||
#btnx_array size
|
||||
for i in 8:
|
||||
|
|
@ -80,10 +80,8 @@ func just_moved():
|
|||
ignore_actor.ignore_actor = null
|
||||
ignore_actor = null
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _physics_process(delta):
|
||||
if Engine.editor_hint:
|
||||
return
|
||||
if Engine.editor_hint: return
|
||||
|
||||
# input
|
||||
if !is_attract_mode:
|
||||
|
|
@ -274,10 +272,3 @@ func try_anim(arg : String):
|
|||
node_anim.play(arg)
|
||||
# update the animationPlayer immediately
|
||||
node_anim.advance(0)
|
||||
|
||||
# spawn box
|
||||
func debug_box(arg = null):
|
||||
var box = scene_box.instance()
|
||||
box.position = arg if arg is Vector2 else Vector2(position.x, position.y - 8)
|
||||
get_parent().add_child(box)
|
||||
print("(box) spawned at: " + str(box.position))
|
||||
|
|
|
|||
|
|
@ -11,15 +11,12 @@ onready var node_sprite : Sprite = $Sprite
|
|||
onready var node_audio : AudioStreamPlayer2D = $AudioStreamPlayer2D
|
||||
|
||||
func _ready():
|
||||
if Engine.editor_hint:
|
||||
return
|
||||
if Engine.editor_hint: return
|
||||
|
||||
add_to_group("switch_" + color)
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
if Engine.editor_hint:
|
||||
return
|
||||
if Engine.editor_hint: return
|
||||
|
||||
is_last = is_on
|
||||
is_on = is_area_solid_actor(position.x, position.y)
|
||||
|
|
|
|||
|
|
@ -11,14 +11,12 @@ onready var node_sprite : Sprite = $Sprite
|
|||
var is_switch = false
|
||||
|
||||
func _ready():
|
||||
if Engine.editor_hint:
|
||||
return
|
||||
if Engine.editor_hint: return
|
||||
|
||||
add_to_group("switch_block_" + color)
|
||||
|
||||
func _physics_process(delta):
|
||||
if Engine.editor_hint:
|
||||
return
|
||||
if Engine.editor_hint: return
|
||||
|
||||
if is_switch and !is_solid and !is_area_solid_actor(position.x, position.y):
|
||||
is_solid = true
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ var a_step := -1 # attract step
|
|||
var at := 0 # attract timer
|
||||
var loop := 1
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
box.append($Box0)
|
||||
box.append($Box1)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,10 @@ onready var score_list := $Control/Scores/List
|
|||
onready var score_note := $Control/Scores/HBoxContainer/Note
|
||||
onready var score_clock := $Control/Scores/HBoxContainer/Clock
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
var load_list := []
|
||||
var loader : ResourceInteractiveLoader
|
||||
var port_count = 0
|
||||
|
||||
func _ready():
|
||||
# make screens
|
||||
screen = $Control/Screen.duplicate()
|
||||
|
|
@ -63,12 +66,19 @@ func _ready():
|
|||
|
||||
screens.add_child(new)
|
||||
overlays.append(new.get_node("Overlay"))
|
||||
view_scene(new.get_node("Vis/ViewportContainer/Viewport"), Shared.map_path + Shared.maps[i])
|
||||
view_scene(new.get_node("Vis/ViewportContainer/Viewport"), Shared.map_path + Shared.maps[i] + ".tscn")
|
||||
|
||||
Leaderboard.connect("new_score", self, "new_score")
|
||||
SilentWolf.Scores.connect("sw_scores_received", self, "new_score")
|
||||
scroll(Shared.current_map)
|
||||
show_scoreboard()
|
||||
|
||||
load_list.sort_custom(self, "sort_load_list")
|
||||
|
||||
func sort_load_list(a, b):
|
||||
if abs(a[0] - cursor) < abs(b[0] - cursor):
|
||||
return true
|
||||
return false
|
||||
|
||||
func _input(event):
|
||||
if !is_input:
|
||||
|
|
@ -94,24 +104,39 @@ func _input(event):
|
|||
scroll(btnx + (btny * columns))
|
||||
node_audio_scroll.pitch_scale = 1 + rand_range(-0.1, 0.5)
|
||||
node_audio_scroll.play()
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
input_count = max(0, input_count - 1)
|
||||
for i in last_refresh.keys():
|
||||
last_refresh[i] = max(0, last_refresh[i] - delta)
|
||||
|
||||
# load stages
|
||||
if loader == null and load_list.size() > 0:
|
||||
loader = ResourceLoader.load_interactive(load_list[0][1])
|
||||
|
||||
if loader != null:
|
||||
var ticks = OS.get_ticks_msec()
|
||||
var tick_limit = delta * 77
|
||||
|
||||
while OS.get_ticks_msec() < ticks + tick_limit:
|
||||
var error = loader.poll()
|
||||
if error == ERR_FILE_EOF:
|
||||
var map = loader.get_resource().instance()
|
||||
loader = null
|
||||
load_list.pop_front()[2].add_child(map)
|
||||
break
|
||||
elif error != OK:
|
||||
# failed
|
||||
loader = null
|
||||
break
|
||||
|
||||
# view a scene inside the viewport by path
|
||||
func view_scene(port, path):
|
||||
for i in port.get_children():
|
||||
i.queue_free()
|
||||
|
||||
if ResourceLoader.exists(path + ".tscn"):
|
||||
var m = load(path + ".tscn").instance()
|
||||
port.add_child(m)
|
||||
for i in Shared.actors:
|
||||
if !i.tag == "exit":
|
||||
i.set_physics_process(false) # dont process actors
|
||||
|
||||
load_list.append([port_count, path, port])
|
||||
port_count += 1
|
||||
|
||||
func scroll(arg = 0):
|
||||
overlays[cursor].visible = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue