mirror of
https://github.com/HarmonyHoney/tiny_crate.git
synced 2026-01-23 02:34:53 +00:00
unlock maps by gems collected! 0, 6, 12, 18, 24 for each world (:
This commit is contained in:
parent
917cf8cff4
commit
99a1736e3c
3 changed files with 83 additions and 21 deletions
|
|
@ -7,7 +7,7 @@ var dict = {}
|
|||
func _ready():
|
||||
refresh()
|
||||
|
||||
func play(arg = "menu_cursor", from := 1.0, to := -1.0, pos := 0.0):
|
||||
func play(arg = "menu_scroll", from := 1.0, to := -1.0, pos := 0.0):
|
||||
if arg is String and dict.has(arg):
|
||||
arg = dict[arg]
|
||||
|
||||
|
|
|
|||
|
|
@ -47,19 +47,40 @@ var loading_time := 0.0
|
|||
export var color_gem := Color("ffec27")
|
||||
export var color_new := Color("83769c")
|
||||
|
||||
var map_lock := {}
|
||||
var map_list := []
|
||||
var map_rows := []
|
||||
var map_unlocked := []
|
||||
export(String, MULTILINE) var lock_string := ""
|
||||
|
||||
|
||||
func _ready():
|
||||
Leaderboard.connect("new_score", self, "new_score")
|
||||
SilentWolf.Scores.connect("sw_scores_received", self, "new_score")
|
||||
|
||||
# setup maps & locks
|
||||
for i in lock_string.split("\n"):
|
||||
var s : Array = i.split(" ")
|
||||
var c = int(s.pop_front())
|
||||
map_rows.append(s)
|
||||
for x in s:
|
||||
map_lock[x] = c
|
||||
map_list.append(x)
|
||||
if c - 1 < Shared.count_gems:
|
||||
map_unlocked.append(x)
|
||||
print("map_lock: ", map_lock)
|
||||
print("map_rows: ", map_rows)
|
||||
|
||||
screen.rect_position -= Vector2.ONE * 500
|
||||
|
||||
# make screens
|
||||
screen_pos = []
|
||||
for i in Shared.maps.size():
|
||||
var sy = i / columns
|
||||
var sx = i % columns
|
||||
screen_pos.append((Vector2(sx + (sy % 2) * 0.5, sy) * (screen_size + screen_dist)))
|
||||
screen_list.append(i)
|
||||
var sum = -1
|
||||
for y in map_rows.size():
|
||||
for x in map_rows[y].size():
|
||||
screen_pos.append((Vector2(x + (y % 2) * 0.5, y) * (screen_size + screen_dist)))
|
||||
sum += 1
|
||||
screen_list.append(sum)
|
||||
screen_max = max(0, screen_pos.size() - 1)
|
||||
|
||||
scroll(Shared.map_select)
|
||||
|
|
@ -84,10 +105,12 @@ func _input(event):
|
|||
is_input = false
|
||||
Audio.play("menu_back", 0.9, 1.1)
|
||||
elif event.is_action_pressed("jump"):
|
||||
open_map()
|
||||
Audio.play("menu_pick", 0.9, 1.1)
|
||||
is_input = false
|
||||
is_load = false
|
||||
if open_map():
|
||||
Audio.play("menu_pick", 0.9, 1.1)
|
||||
is_input = false
|
||||
is_load = false
|
||||
else:
|
||||
Audio.play("menu_random", 0.8, 1.2)
|
||||
elif event.is_action_pressed("pause"):
|
||||
show_score = posmod(show_score + 1, 3)
|
||||
print("show_score: ", show_score)
|
||||
|
|
@ -135,10 +158,12 @@ func _physics_process(delta):
|
|||
|
||||
func make_screen(i := 0):
|
||||
var new = screen.duplicate()
|
||||
var map_name = Shared.maps[i]
|
||||
var map_name = map_list[i]
|
||||
var is_locked = Shared.count_gems < map_lock[map_name]
|
||||
|
||||
new.rect_position = screen_pos[i]
|
||||
new.get_node("Overlay/Label").text = map_name
|
||||
new.get_node("Overlay/HBox/Label").text = (str(map_lock[map_name]) + " to unlock") if is_locked else map_name
|
||||
new.get_node("Overlay/HBox/Gem").visible = is_locked
|
||||
|
||||
var s = {}
|
||||
if Shared.save_maps.has(map_name):
|
||||
|
|
@ -151,7 +176,9 @@ func make_screen(i := 0):
|
|||
|
||||
var has_time = s.has("time")
|
||||
new.get_node("Overlay/Time").visible = has_time
|
||||
new.get_node("Overlay/Gem").modulate = color_gem if has_time else color_new
|
||||
var gem = new.get_node("Overlay/Gem")
|
||||
gem.modulate = color_gem if has_time else color_new
|
||||
gem.visible = !is_locked
|
||||
if has_time:
|
||||
new.get_node("Overlay/Time/Label").text = time_to_string(s["time"])
|
||||
|
||||
|
|
@ -164,7 +191,7 @@ func make_screen(i := 0):
|
|||
screens.append(new)
|
||||
overlays.append(new.get_node("Overlay"))
|
||||
screen_static.append(new.get_node("Vis/Static"))
|
||||
view_scene(new.get_node("Vis/ViewportContainer/Viewport"), Shared.map_dir + Shared.maps[i] + ".tscn", i)
|
||||
view_scene(new.get_node("Vis/ViewportContainer/Viewport"), Shared.map_dir + map_list[i] + ".tscn", i)
|
||||
|
||||
# view a scene inside the viewport by path
|
||||
func view_scene(port, path, arg):
|
||||
|
|
@ -175,11 +202,11 @@ func view_scene(port, path, arg):
|
|||
port_count += 1
|
||||
|
||||
func scroll(arg = 0):
|
||||
var o = overlays.size() > cursor
|
||||
var o = cursor < overlays.size()
|
||||
if o: overlays[cursor].visible = true
|
||||
|
||||
cursor = clamp(cursor + arg, 0, screen_max)
|
||||
current_map = Shared.maps[cursor]
|
||||
current_map = map_list[cursor]
|
||||
|
||||
if o: overlays[cursor].visible = !score_node.visible
|
||||
|
||||
|
|
@ -198,7 +225,7 @@ func show_scoreboard(arg := show_score):
|
|||
Shared.is_replay = arg == 1
|
||||
|
||||
score_node.visible = show_score > 0
|
||||
if overlays.size() > cursor:
|
||||
if cursor < overlays.size():
|
||||
overlays[cursor].visible = !score_node.visible
|
||||
refresh_score()
|
||||
|
||||
|
|
@ -253,5 +280,8 @@ func time_to_string(arg := 0.0):
|
|||
return str(time / 60.0).pad_zeros(2).pad_decimals(0) + ":" + str(fposmod(time, 60.0)).pad_zeros(2).pad_decimals(0)
|
||||
|
||||
func open_map():
|
||||
Shared.map_select = cursor
|
||||
Shared.wipe_scene(Shared.map_dir + Shared.maps[cursor] + ".tscn")
|
||||
if current_map in map_unlocked:
|
||||
Shared.map_select = cursor
|
||||
Shared.wipe_scene(Shared.map_dir + current_map + ".tscn")
|
||||
return true
|
||||
return false
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=18 format=2]
|
||||
[gd_scene load_steps=20 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]
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
[ext_resource path="res://src/shader/outline2D_outer.shader" type="Shader" id=6]
|
||||
[ext_resource path="res://src/menu/select.gd" type="Script" id=7]
|
||||
[ext_resource path="res://media/image/diamond16.png" type="Texture" id=8]
|
||||
[ext_resource path="res://media/image/diamond12.png" type="Texture" id=9]
|
||||
[ext_resource path="res://media/image/menu.png" type="Texture" id=10]
|
||||
[ext_resource path="res://media/image/skull.png" type="Texture" id=11]
|
||||
[ext_resource path="res://src/menu/cursor_anim.gd" type="Script" id=13]
|
||||
|
|
@ -17,6 +18,11 @@ shader = ExtResource( 5 )
|
|||
shader_param/mouse_pos = Vector2( 0.01, 0.005 )
|
||||
shader_param/vsync_issues = 0.7
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=10]
|
||||
shader = ExtResource( 6 )
|
||||
shader_param/line_color = Color( 0, 0, 0, 1 )
|
||||
shader_param/line_thickness = 1.0
|
||||
|
||||
[sub_resource type="DynamicFont" id=4]
|
||||
size = 5
|
||||
outline_size = 1
|
||||
|
|
@ -59,6 +65,11 @@ __meta__ = {
|
|||
"_edit_lock_": true
|
||||
}
|
||||
screen_size = Vector2( 136, 96 )
|
||||
lock_string = "00 1-1 1-2 1-3 1-4 1-5 1-6 1-7 1-8
|
||||
06 2-1 2-2 2-3 2-4 2-5 2-6 2-7 2-8
|
||||
12 3-1 3-2 3-3 3-4 3-5 3-6 3-7 3-8
|
||||
18 4-1 4-2 4-3 4-4 4-5 4-6 4-7 4-8
|
||||
24 5-1 5-2 5-3"
|
||||
|
||||
[node name="Control" type="Control" parent="."]
|
||||
margin_right = 320.0
|
||||
|
|
@ -100,9 +111,30 @@ margin_bottom = 96.0
|
|||
margin_right = 136.0
|
||||
margin_bottom = 104.0
|
||||
|
||||
[node name="Label" type="Label" parent="Control/Screen/Overlay"]
|
||||
[node name="HBox" type="HBoxContainer" parent="Control/Screen/Overlay"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
alignment = 1
|
||||
|
||||
[node name="Gem" type="Control" parent="Control/Screen/Overlay/HBox"]
|
||||
margin_left = 48.0
|
||||
margin_top = 44.0
|
||||
margin_right = 64.0
|
||||
margin_bottom = 60.0
|
||||
rect_min_size = Vector2( 16, 16 )
|
||||
size_flags_vertical = 4
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="Control/Screen/Overlay/HBox/Gem"]
|
||||
modulate = Color( 1, 0.92549, 0.152941, 1 )
|
||||
material = SubResource( 10 )
|
||||
position = Vector2( 8, 8 )
|
||||
texture = ExtResource( 9 )
|
||||
|
||||
[node name="Label" type="Label" parent="Control/Screen/Overlay/HBox"]
|
||||
margin_left = 68.0
|
||||
margin_top = 49.0
|
||||
margin_right = 88.0
|
||||
margin_bottom = 54.0
|
||||
grow_horizontal = 2
|
||||
custom_fonts/font = SubResource( 4 )
|
||||
text = "1-1"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue