mirror of
https://github.com/HarmonyHoney/tiny_crate.git
synced 2026-01-23 02:34:53 +00:00
take screenshots of every level
This commit is contained in:
parent
f22ee3b33a
commit
56ec7561e1
6 changed files with 53 additions and 22 deletions
|
|
@ -13,6 +13,8 @@ export var color := "red"
|
|||
var box = preload("res://src/actor/Box.tscn")
|
||||
|
||||
func _ready():
|
||||
if Shared.is_level_select: return
|
||||
|
||||
for i in get_tree().get_nodes_in_group("switch_" + color):
|
||||
i.connect("press", self, "release")
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ func _ready():
|
|||
rot_speed += rand_range(-rot_speed_diff, rot_speed_diff)
|
||||
if randf() > 0.5:
|
||||
rot_speed = -rot_speed
|
||||
|
||||
for i in 5:
|
||||
_physics_process(1.0/60.0)
|
||||
|
||||
func _physics_process(delta):
|
||||
counter += delta
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ signal press
|
|||
signal release
|
||||
|
||||
func _enter_tree():
|
||||
if Engine.editor_hint: return
|
||||
if Engine.editor_hint or Shared.is_level_select: return
|
||||
add_to_group("switch_" + color)
|
||||
|
||||
func _physics_process(delta):
|
||||
if Engine.editor_hint: return
|
||||
if Engine.editor_hint or Shared.is_level_select: return
|
||||
|
||||
is_last = is_on
|
||||
is_on = is_area_solid_actor(position.x, position.y)
|
||||
|
|
|
|||
|
|
@ -103,7 +103,8 @@ func _ready():
|
|||
var dir = Directory.new()
|
||||
if !dir.open(save_path) == OK:
|
||||
dir.make_dir(save_path)
|
||||
for i in save_limit:
|
||||
|
||||
for i in range(save_limit) + ["map"]:
|
||||
var s = save_path + str(i)
|
||||
if !dir.open(s) == OK:
|
||||
dir.make_dir(s)
|
||||
|
|
@ -122,25 +123,6 @@ func _ready():
|
|||
|
||||
Wipe.connect("finish", self, "wipe_finish")
|
||||
|
||||
func vec_string(p : Vector2):
|
||||
return str(int(p.x)) + "," + str(int(p.y))
|
||||
|
||||
func make_key(p : Vector2, c : TileMap, dict : Dictionary, skip_id := -1):
|
||||
var id = c.get_cellv(p)
|
||||
if id == skip_id:
|
||||
return
|
||||
var coord = c.get_cell_autotile_coord(p.x, p.y)
|
||||
|
||||
var t = c.is_cell_transposed(p.x, p.y)
|
||||
var x = c.is_cell_x_flipped(p.x, p.y)
|
||||
var y = c.is_cell_y_flipped(p.x, p.y)
|
||||
var key = str(id) + " " + str(int(coord.x)) + " " + str(int(t)) + str(int(x)) + str(int(y))
|
||||
|
||||
if !dict.has(key):
|
||||
dict[key] = ""
|
||||
|
||||
dict[key] += vec_string(p) + " "
|
||||
|
||||
func _input(event):
|
||||
var joy = event is InputEventJoypadButton or event is InputEventJoypadMotion
|
||||
if is_gamepad != joy:
|
||||
|
|
|
|||
|
|
@ -1,8 +1,38 @@
|
|||
extends Node2D
|
||||
|
||||
onready var viewport := $ViewportContainer/Viewport
|
||||
onready var view_node := $ViewportContainer/Viewport/Node2D
|
||||
|
||||
func _ready():
|
||||
|
||||
Shared.is_level_select = true
|
||||
for i in Shared.scene_dict.keys():
|
||||
var inst = Shared.scene_dict[i].instance()
|
||||
|
||||
for c in view_node.get_children():
|
||||
c.queue_free()
|
||||
|
||||
view_node.add_child(inst)
|
||||
|
||||
var cb = inst.get_node("CamBounds")
|
||||
if is_instance_valid(cb):
|
||||
inst.position -= cb.position
|
||||
var ps = inst.get_node("Actors/Player/Sprite")
|
||||
if is_instance_valid(ps):
|
||||
ps.material = null
|
||||
|
||||
for f in 2:
|
||||
yield(get_tree(), "idle_frame")
|
||||
|
||||
var image = viewport.get_texture().get_data()
|
||||
image.flip_y()
|
||||
|
||||
image.save_png("user://save/map/" + str(i).split("/")[-1].trim_suffix(".tscn") + ".png")
|
||||
|
||||
|
||||
yield(get_tree(), "idle_frame")
|
||||
Music.play()
|
||||
Audio.play("menu_bell")
|
||||
yield(get_tree().create_timer(1.5), "timeout")
|
||||
Shared.wipe_scene(Shared.main_menu_path)
|
||||
|
||||
|
|
|
|||
|
|
@ -31,3 +31,17 @@ texture = ExtResource( 1 )
|
|||
[node name="CamBounds" type="Node2D" parent="CanvasLayer/Center/Control"]
|
||||
position = Vector2( 114, 64 )
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="ViewportContainer" type="ViewportContainer" parent="."]
|
||||
margin_left = -163.0
|
||||
margin_top = -120.0
|
||||
margin_right = -27.0
|
||||
margin_bottom = -24.0
|
||||
|
||||
[node name="Viewport" type="Viewport" parent="ViewportContainer"]
|
||||
size = Vector2( 136, 96 )
|
||||
handle_input_locally = false
|
||||
render_target_update_mode = 3
|
||||
|
||||
[node name="Node2D" type="Node2D" parent="ViewportContainer/Viewport"]
|
||||
position = Vector2( 68, 48 )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue