sheet.png & sheet.tres, showing map images on select (-=

This commit is contained in:
Harmony Honey Monroe 2025-02-25 03:58:21 -05:00
parent ee2dfaa0b8
commit f75b735580
10 changed files with 125 additions and 32 deletions

View file

@ -13,7 +13,9 @@ export var color := "red"
var box = preload("res://src/actor/Box.tscn")
func _ready():
if Shared.is_level_select: return
if Shared.is_level_select:
node_anim.advance(0.5)
return
for i in get_tree().get_nodes_in_group("switch_" + color):
i.connect("press", self, "release")

View file

@ -96,6 +96,7 @@ vframes = 8
frame = 15
[node name="Sprite2" type="Sprite" parent="."]
visible = false
position = Vector2( 4, 4 )
z_index = 50
z_as_relative = false

View file

@ -26,9 +26,6 @@ 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

View file

@ -48,6 +48,8 @@ var bus_volume = [10, 10, 10]
var actors := []
var player
var map_dict : Dictionary = load("res://src/stage/sheet.tres").dict
var map_select := 0
var maps := []
var map_name := ""
@ -104,7 +106,7 @@ func _ready():
if !dir.open(save_path) == OK:
dir.make_dir(save_path)
for i in range(save_limit) + ["map"]:
for i in save_limit:
var s = save_path + str(i)
if !dir.open(s) == OK:
dir.make_dir(s)

View file

@ -244,10 +244,14 @@ func make_screen(i := 0):
print("faster ", i, ", blink_label ", blink_label)
Audio.play("menu_bell", 0.5, 1.0)
var sprite = new.get_node("Vis/Sprite")
var dict = Shared.map_dict[map_name]
sprite.region_rect = Rect2(screen_size * Vector2(dict[0], dict[1]), screen_size)
screens_node.add_child(new)
overlays[i] = new.get_node("Vis/Overlay")
screen_static.append(new.get_node("Vis/Static"))
view_scene(new.get_node("Vis/Node2D"), Shared.map_dir + map_list[i] + ".tscn", i)
#view_scene(new.get_node("Vis/Node2D"), Shared.map_dir + map_list[i] + ".tscn", i)
# view a scene inside the viewport by path
func view_scene(port, path, arg):

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=22 format=2]
[gd_scene load_steps=23 format=2]
[ext_resource path="res://media/image/corner.png" type="Texture" id=1]
[ext_resource path="res://media/font/QuinqueFive.ttf" type="DynamicFontData" id=2]
@ -13,6 +13,7 @@
[ext_resource path="res://media/image/skull.png" type="Texture" id=11]
[ext_resource path="res://src/stage/CamBounds.gd" type="Script" id=12]
[ext_resource path="res://src/menu/cursor_anim.gd" type="Script" id=13]
[ext_resource path="res://src/stage/sheet.png" type="Texture" id=14]
[sub_resource type="ShaderMaterial" id=8]
shader = ExtResource( 5 )
@ -93,7 +94,6 @@ margin_top = 40.0
margin_right = 246.0
margin_bottom = 136.0
rect_min_size = Vector2( 136, 96 )
rect_clip_content = true
[node name="Vis" type="VisibilityNotifier2D" parent="Control/Screen"]
rect = Rect2( 0, 0, 136, 96 )
@ -118,6 +118,12 @@ material = SubResource( 8 )
margin_right = 136.0
margin_bottom = 96.0
[node name="Sprite" type="Sprite" parent="Control/Screen/Vis"]
texture = ExtResource( 14 )
centered = false
region_enabled = true
region_rect = Rect2( 0, 0, 136, 96 )
[node name="Overlay" type="Control" parent="Control/Screen/Vis"]
margin_right = 136.0
margin_bottom = 104.0

View file

@ -1,5 +1,7 @@
extends Node2D
export var is_build_sheet := false
onready var color_rect := $CanvasLayer/ColorRect
onready var logo := $CanvasLayer/Center/Control/Logo
@ -7,42 +9,75 @@ onready var viewport := $ViewportContainer/Viewport
onready var view_node := $ViewportContainer/Viewport/Node2D
func _ready():
if is_build_sheet:
color_rect.modulate = Color.black
logo.modulate = Color.white
color_rect.modulate = Color.black
logo.modulate = Color.white
Shared.is_level_select = true
for i in Shared.scene_dict.keys():
var inst = Shared.scene_dict[i].instance()
yield(get_tree(), "idle_frame")
for c in view_node.get_children():
c.queue_free()
Shared.is_level_select = true
Shared.map_dict = {}
var ix = 136
var iy = 96
var vx = 5
var vy = 8
view_node.add_child(inst)
var image_sheet = viewport.get_texture().get_data()
image_sheet.resize(ix * vx, iy * vy)
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:
for i in Shared.maps.size():
var dx = int(i % vx)
var dy = int(floor(i / vx))
var s = str(Shared.maps[i])
Shared.map_dict[s] = [dx,dy,0,0,0,0,0,0]
var dict = Shared.map_dict[s]
var inst = load(Shared.map_dir + s + ".tscn").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
dict[2] = int(cb.position.x)
dict[3] = int(cb.position.y)
var p = inst.get_node("Actors/Player")
if is_instance_valid(p):
p.visible = false
dict[4] = int(p.position.x)
dict[5] = int(p.position.y)
var e = inst.get_node("Actors/Exit")
if is_instance_valid(e):
e.visible = false
dict[6] = int(e.position.x)
dict[7] = int(e.position.y)
yield(get_tree(), "idle_frame")
var image = viewport.get_texture().get_data()
image.flip_y()
image_sheet.blit_rect(image, Rect2(0, 0, ix, iy), Vector2(dx * ix, dy * iy))
image_sheet.save_png("res://src/stage/sheet.png")
var image = viewport.get_texture().get_data()
image.flip_y()
var sd := SaveDict.new()
sd.dict = Shared.map_dict
image.save_png("user://save/map/" + str(i).split("/")[-1].trim_suffix(".tscn") + ".png")
yield(get_tree(), "idle_frame")
ResourceSaver.save("res://src/stage/sheet.tres", sd)
yield(get_tree(), "idle_frame")
color_rect.modulate = Color.white
logo.modulate = Color.black
Music.play()
Audio.play("menu_bell")
yield(get_tree().create_timer(1.5), "timeout")
Shared.wipe_scene(Shared.main_menu_path)

View file

@ -6,6 +6,7 @@
[node name="Splash" type="Node2D"]
script = ExtResource( 3 )
is_build_sheet = true
[node name="CanvasLayer" type="CanvasLayer" parent="."]
layer = 9

BIN
src/stage/sheet.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

45
src/stage/sheet.tres Normal file
View file

@ -0,0 +1,45 @@
[gd_resource type="Resource" load_steps=2 format=2]
[ext_resource path="res://src/class/savedict.gd" type="Script" id=1]
[resource]
script = ExtResource( 1 )
dict = {
"1-1": [ 0, 0, 0, 0, -40, 8, 45, 5 ],
"1-2": [ 1, 0, 0, 0, -48, 24, 45, -19 ],
"1-3": [ 2, 0, -24, -16, -92, 24, -67, -51 ],
"1-4": [ 3, 0, 16, 0, 40, 32, -51, -27 ],
"1-5": [ 4, 0, 32, -24, 34, 16, 53, -67 ],
"1-6": [ 0, 1, 8, -24, -12, -8, -3, -67 ],
"1-7": [ 1, 1, 16, -40, -4, -8, 77, -75 ],
"1-8": [ 2, 1, 0, -48, -4, -8, -3, -83 ],
"2-1": [ 3, 1, 40, -16, -53, -8, 125, -11 ],
"2-2": [ 4, 1, 40, -20, 36, -24, 125, -27 ],
"2-3": [ 0, 2, -14, -24, -84, -8, 125, -51 ],
"2-4": [ 1, 2, 20, -24, 52, 16, 29, -123 ],
"2-5": [ 2, 2, 52, -20, -11, -8, 133, -35 ],
"2-6": [ 3, 2, 8, 8, -27, -24, 57, 49 ],
"2-7": [ 4, 2, 0, -24, -68, -8, -3, -55 ],
"2-8": [ 0, 3, -16, -32, -40, 8, -91, -67 ],
"3-1": [ 1, 3, 8, -8, -28, -8, 61, -35 ],
"3-2": [ 2, 3, -4, -16, -40, -8, 5, -59 ],
"3-3": [ 3, 3, -8, -24, -56, -16, -35, -67 ],
"3-4": [ 4, 3, 16, -8, -64, 16, 149, -35 ],
"3-5": [ 0, 4, -16, -24, -68, -8, 29, -43 ],
"3-6": [ 1, 4, -16, -36, -63, -32, 53, -59 ],
"3-7": [ 2, 4, 16, -44, -52, -32, 95, -67 ],
"3-8": [ 3, 4, 4, -33, -60, -16, 77, -75 ],
"4-1": [ 4, 4, 0, -4, -44, 8, 41, -15 ],
"4-2": [ 0, 5, 0, -52, -9, -8, -3, -99 ],
"4-3": [ 1, 5, 16, -4, 60, 24, -59, -51 ],
"4-4": [ 2, 5, 28, -40, -4, -24, 25, -55 ],
"4-5": [ 3, 5, -8, -28, 5, -24, 49, -63 ],
"4-6": [ 4, 5, 48, -44, 87, -16, -35, -51 ],
"4-7": [ 0, 6, 40, -36, 86, -16, -119, -55 ],
"4-8": [ 1, 6, 40, -44, -8, -16, -47, -79 ],
"5-1": [ 2, 6, 34, -40, -12, -16, 174, -59 ],
"5-2": [ 3, 6, 52, -32, 121, -16, -43, -67 ],
"5-3": [ 4, 6, 48, -48, 33, -64, -39, -47 ],
"5-4": [ 0, 7, 34, -56, 69, -16, -51, -91 ],
"win": [ 1, 7, 0, -24, -13, 8, 89, -39 ]
}