1
Fork 0
mirror of https://github.com/Steffo99/particle-clash.git synced 2024-11-21 15:14:19 +00:00

Everything works, time for some polish

This commit is contained in:
Steffo 2022-10-02 15:05:52 +02:00
parent 85bc924680
commit 63703a8b99
Signed by: steffo
GPG key ID: 6965406171929D01
6 changed files with 187 additions and 160 deletions

View file

@ -22,155 +22,162 @@ func _on_RightColorPicker_color_changed(color: Color):
const SHAPES = [
# # Good intro level
# [
# " RRBB ",
# "RRBRBB",
# "RBRBRB",
# "BRBRBR",
# "BBRBRR",
# " BBRR "
# ],
# # With a trick
# [
# " RBBR ",
# "RBRRBR",
# "BRWWRB",
# "BRWWRB",
# "RBRRBR",
# " RBBR "
# ],
# # The Gap
# [
# " RRBB ",
# "RBBRRB",
# "BRRBBR",
# "RBB RB",
# "BRRBBR",
# " BBRR "
# ],
# # Larger
# [
# " GGBB ",
# " GRRYYB ",
# "GRRRYYYB",
# "GRRRYYYB",
# "YBBBGGGR",
# "YBBBGGGR",
# " YBBGGR ",
# " YYRR "
# ],
# # Donut
# [
# " RBBR ",
# " RBRRBR ",
# "RBRBBRBR",
# "BRB BRB",
# "BRB BRB",
# "RBRBBRBR",
# " RBRRBR ",
# " RBBR "
# ],
# # Huge
# [
# " BBBRRR ",
# " 22222222 ",
# "R22222222B",
# "R222 2222B",
# "R222222 2B",
# "B2 222222R",
# "B2222 222R",
# "B22222222R",
# " 22222222 ",
# " RRRBBB "
# ]
# Tutorial
[
"RWRR",
"RWWW",
"YBBY",
"YBBY",
],
# Good intro level
[
" RRBB ",
"RRBRBB",
"RBRBRB",
"BRBRBR",
"BBRBRR",
" BBRR "
],
# With a trick
[
" RBBR ",
"RBRRBR",
"BRWWRB",
"BRWWRB",
"RBRRBR",
" RBBR "
],
# The Gap
[
" RRBB ",
"RBBRRB",
"BRRBBR",
"RBB RB",
"BRRBBR",
" BBRR "
],
# Larger
[
" GGBB ",
" GRRYYB ",
"GRRRYYYB",
"GRRRYYYB",
"YBBBGGGR",
"YBBBGGGR",
" YBBGGR ",
" YYRR "
],
# Donut
[
" RBBR ",
" RBRRBR ",
"RBRBBRBR",
"BRB BRB",
"BRB BRB",
"RBRBBRBR",
" RBRRBR ",
" RBBR "
],
# Huge
[
" BBBRRR ",
" 22222222 ",
"R22222222B",
"R222 2222B",
"R222222 2B",
"B2 222222R",
"B2222 222R",
"B22222222R",
" 22222222 ",
" RRRBBB "
]
]
const RANDOM_SHAPES = [
# # Smol 2
# [
# " 2222 ",
# "222222",
# "222222",
# "222222",
# "222222",
# " 2222 ",
# ],
# # Smol 3
# [
# " 3333 ",
# "333333",
# "333333",
# "333333",
# "333333",
# " 3333 ",
# ],
# # Smol 4
# [
# " 4444 ",
# "444444",
# "444444",
# "444444",
# "444444",
# " 4444 ",
# ],
# # Larger 3
# [
# " 3333 ",
# " 333333 ",
# "33333333",
# "33333333",
# "33333333",
# "33333333",
# " 333333 ",
# " 3333 "
# ],
# # Larger 4
# [
# " 4444 ",
# " 444444 ",
# "44444444",
# "44444444",
# "44444444",
# "44444444",
# " 444444 ",
# " 4444 "
# ],
# # Larger 5
# [
# " 5555 ",
# " 555555 ",
# "55555555",
# "55555555",
# "55555555",
# "55555555",
# " 555555 ",
# " 5555 "
# ],
# # Donut 3
# [
# " 3333 ",
# " 333333 ",
# "33333333",
# "333 333",
# "333 333",
# "33333333",
# " 333333 ",
# " 3333 "
# ],
# # Huge mix
# [
# " 2222 ",
# " 233332 ",
# " 23555532 ",
# "2355555532",
# "2355555532",
# "2355555532",
# "2355555532",
# " 23555532 ",
# " 233332 ",
# " 2222 "
# ],
# Smol 2
[
" 2222 ",
"222222",
"222222",
"222222",
"222222",
" 2222 ",
],
# Smol 3
[
" 3333 ",
"333333",
"333333",
"333333",
"333333",
" 3333 ",
],
# Smol 4
[
" 4444 ",
"444444",
"444444",
"444444",
"444444",
" 4444 ",
],
# Larger 3
[
" 3333 ",
" 333333 ",
"33333333",
"33333333",
"33333333",
"33333333",
" 333333 ",
" 3333 "
],
# Larger 4
[
" 4444 ",
" 444444 ",
"44444444",
"44444444",
"44444444",
"44444444",
" 444444 ",
" 4444 "
],
# Larger 5
[
" 5555 ",
" 555555 ",
"55555555",
"55555555",
"55555555",
"55555555",
" 555555 ",
" 5555 "
],
# Donut 3
[
" 3333 ",
" 333333 ",
"33333333",
"333 333",
"333 333",
"33333333",
" 333333 ",
" 3333 "
],
# Huge mix
[
" 2222 ",
" 233332 ",
" 23555532 ",
"2355555532",
"2355555532",
"2355555532",
"2355555532",
" 23555532 ",
" 233332 ",
" 2222 "
],
# Huge 3
[
" 3333 ",
@ -193,6 +200,8 @@ func _on_Button_button_up():
func init_round():
$Gameplay/Minimap.visible = false
var shape = SHAPES.pop_front()
if shape == null:
shape = RANDOM_SHAPES[rng.randi_range(0, len(RANDOM_SHAPES)) - 1]
@ -208,6 +217,7 @@ func init_round():
func start_round():
$Gameplay/Timer.start()
$Gameplay/Minimap.visible = true
$Gameplay/LeftPlayArea.can_act = true
$Gameplay/RightPlayArea.can_act = true

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=18 format=2]
[gd_scene load_steps=20 format=2]
[ext_resource path="res://src/scenes/Menu.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/scenes/Gameplay.tscn" type="PackedScene" id=2]
@ -6,6 +6,12 @@
[ext_resource path="res://src/Main.gd" type="Script" id=5]
[ext_resource path="res://src/scenes/Results.tscn" type="PackedScene" id=6]
[sub_resource type="CanvasItemMaterial" id=13]
blend_mode = 1
[sub_resource type="CanvasItemMaterial" id=14]
blend_mode = 1
[sub_resource type="Animation" id=2]
resource_name = "FadeIn"
step = 0.0166667
@ -260,6 +266,12 @@ bus = "Right"
[node name="SoundOk" parent="Gameplay/RightPlayArea/Tiles/Cursor" index="1"]
bus = "Right"
[node name="Left" parent="Gameplay/Minimap" index="0"]
material = SubResource( 13 )
[node name="Right" parent="Gameplay/Minimap" index="1"]
material = SubResource( 14 )
[node name="Transitions" type="Control" parent="."]
margin_right = 1600.0
margin_bottom = 900.0

View file

@ -3,5 +3,11 @@ extends Node2D
func _process(_delta):
var timer = $Timer
$Minimap/Left.position.x = (1 - timer.time_left / timer.wait_time) * (get_viewport().size.x / 2)
$Minimap/Right.position.x = get_viewport().size.x - (1 - timer.time_left / timer.wait_time) * (get_viewport().size.x / 2)
var left = $Minimap/Left
var right = $Minimap/Right
var progress = 1 - timer.time_left / timer.wait_time
var wide = get_viewport().size.x
left.position.x = progress * wide / 2
right.position.x = wide - progress * wide / 2

View file

@ -52,6 +52,7 @@ stream = ExtResource( 8 )
bus = "Music"
[node name="Minimap" type="Node2D" parent="."]
visible = false
position = Vector2( 0, 16 )
[node name="Left" type="Sprite" parent="Minimap"]

View file

@ -5,6 +5,7 @@ var can_act = false
func tiles_init(shape, sd):
print("Initializing tiles for %s..." % player)
$Tiles.set_shape(shape, sd)
check_matches()
@ -40,7 +41,6 @@ func cursor_init():
while x < len(shape[y]):
var new_pos = Vector2(x, y)
if not cursor_would_collide(new_pos):
print("Found location for cursor @ %d, %d" % [new_pos.x, new_pos.y])
set_cursor_pos(new_pos)
return
x += 1

View file

@ -20,10 +20,8 @@ var size
var atoms = []
var rng
func set_shape(val, sd):
var new_shape = [] + val
var new_size = len(val)
var rescale_to = clamp(6 / float(new_size), 0, 1)
@ -31,13 +29,13 @@ func set_shape(val, sd):
for atom in $Atoms.get_children():
atom.queue_free()
rng = RandomNumberGenerator.new()
var rng = RandomNumberGenerator.new()
rng.set_seed(sd)
atoms = []
var offset = new_size / 2
var y = - offset
for row in val:
for row in new_shape:
var atoms_row = []
var x = - offset
for col in row:
@ -45,11 +43,11 @@ func set_shape(val, sd):
set_cell(x, y, 0)
var atom = ATOM.instance()
var random_amount = int(col)
if random_amount > 0:
if random_amount > 1:
var keys = COLORS.keys()
col = keys[rng.randi() % min(len(keys), random_amount)]
val[y+offset][x+offset] = col
atom.self_modulate = COLORS[col]
var index = rng.randi() % min(len(keys), random_amount)
new_shape[y+offset][x+offset] = keys[index]
atom.self_modulate = COLORS[new_shape[y+offset][x+offset]]
atom.position = Vector2(x * TILE_SIZE + TILE_OFFSET, y * TILE_SIZE + TILE_OFFSET)
$Atoms.add_child(atom)
atoms_row.append(atom)
@ -60,5 +58,5 @@ func set_shape(val, sd):
y += 1
size = new_size
shape = val
shape = new_shape
scale = Vector2(rescale_to, rescale_to)