mirror of
https://github.com/Steffo99/particle-clash.git
synced 2024-11-21 23:24:18 +00:00
Everything works, time for some polish
This commit is contained in:
parent
85bc924680
commit
63703a8b99
6 changed files with 187 additions and 160 deletions
302
src/Main.gd
302
src/Main.gd
|
@ -22,155 +22,162 @@ func _on_RightColorPicker_color_changed(color: Color):
|
||||||
|
|
||||||
|
|
||||||
const SHAPES = [
|
const SHAPES = [
|
||||||
# # Good intro level
|
# Tutorial
|
||||||
# [
|
[
|
||||||
# " RRBB ",
|
"RWRR",
|
||||||
# "RRBRBB",
|
"RWWW",
|
||||||
# "RBRBRB",
|
"YBBY",
|
||||||
# "BRBRBR",
|
"YBBY",
|
||||||
# "BBRBRR",
|
],
|
||||||
# " BBRR "
|
# Good intro level
|
||||||
# ],
|
[
|
||||||
# # With a trick
|
" RRBB ",
|
||||||
# [
|
"RRBRBB",
|
||||||
# " RBBR ",
|
"RBRBRB",
|
||||||
# "RBRRBR",
|
"BRBRBR",
|
||||||
# "BRWWRB",
|
"BBRBRR",
|
||||||
# "BRWWRB",
|
" BBRR "
|
||||||
# "RBRRBR",
|
],
|
||||||
# " RBBR "
|
# With a trick
|
||||||
# ],
|
[
|
||||||
# # The Gap
|
" RBBR ",
|
||||||
# [
|
"RBRRBR",
|
||||||
# " RRBB ",
|
"BRWWRB",
|
||||||
# "RBBRRB",
|
"BRWWRB",
|
||||||
# "BRRBBR",
|
"RBRRBR",
|
||||||
# "RBB RB",
|
" RBBR "
|
||||||
# "BRRBBR",
|
],
|
||||||
# " BBRR "
|
# The Gap
|
||||||
# ],
|
[
|
||||||
# # Larger
|
" RRBB ",
|
||||||
# [
|
"RBBRRB",
|
||||||
# " GGBB ",
|
"BRRBBR",
|
||||||
# " GRRYYB ",
|
"RBB RB",
|
||||||
# "GRRRYYYB",
|
"BRRBBR",
|
||||||
# "GRRRYYYB",
|
" BBRR "
|
||||||
# "YBBBGGGR",
|
],
|
||||||
# "YBBBGGGR",
|
# Larger
|
||||||
# " YBBGGR ",
|
[
|
||||||
# " YYRR "
|
" GGBB ",
|
||||||
# ],
|
" GRRYYB ",
|
||||||
# # Donut
|
"GRRRYYYB",
|
||||||
# [
|
"GRRRYYYB",
|
||||||
# " RBBR ",
|
"YBBBGGGR",
|
||||||
# " RBRRBR ",
|
"YBBBGGGR",
|
||||||
# "RBRBBRBR",
|
" YBBGGR ",
|
||||||
# "BRB BRB",
|
" YYRR "
|
||||||
# "BRB BRB",
|
],
|
||||||
# "RBRBBRBR",
|
# Donut
|
||||||
# " RBRRBR ",
|
[
|
||||||
# " RBBR "
|
" RBBR ",
|
||||||
# ],
|
" RBRRBR ",
|
||||||
# # Huge
|
"RBRBBRBR",
|
||||||
# [
|
"BRB BRB",
|
||||||
# " BBBRRR ",
|
"BRB BRB",
|
||||||
# " 22222222 ",
|
"RBRBBRBR",
|
||||||
# "R22222222B",
|
" RBRRBR ",
|
||||||
# "R222 2222B",
|
" RBBR "
|
||||||
# "R222222 2B",
|
],
|
||||||
# "B2 222222R",
|
# Huge
|
||||||
# "B2222 222R",
|
[
|
||||||
# "B22222222R",
|
" BBBRRR ",
|
||||||
# " 22222222 ",
|
" 22222222 ",
|
||||||
# " RRRBBB "
|
"R22222222B",
|
||||||
# ]
|
"R222 2222B",
|
||||||
|
"R222222 2B",
|
||||||
|
"B2 222222R",
|
||||||
|
"B2222 222R",
|
||||||
|
"B22222222R",
|
||||||
|
" 22222222 ",
|
||||||
|
" RRRBBB "
|
||||||
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
const RANDOM_SHAPES = [
|
const RANDOM_SHAPES = [
|
||||||
# # Smol 2
|
# Smol 2
|
||||||
# [
|
[
|
||||||
# " 2222 ",
|
" 2222 ",
|
||||||
# "222222",
|
"222222",
|
||||||
# "222222",
|
"222222",
|
||||||
# "222222",
|
"222222",
|
||||||
# "222222",
|
"222222",
|
||||||
# " 2222 ",
|
" 2222 ",
|
||||||
# ],
|
],
|
||||||
# # Smol 3
|
# Smol 3
|
||||||
# [
|
[
|
||||||
# " 3333 ",
|
" 3333 ",
|
||||||
# "333333",
|
"333333",
|
||||||
# "333333",
|
"333333",
|
||||||
# "333333",
|
"333333",
|
||||||
# "333333",
|
"333333",
|
||||||
# " 3333 ",
|
" 3333 ",
|
||||||
# ],
|
],
|
||||||
# # Smol 4
|
# Smol 4
|
||||||
# [
|
[
|
||||||
# " 4444 ",
|
" 4444 ",
|
||||||
# "444444",
|
"444444",
|
||||||
# "444444",
|
"444444",
|
||||||
# "444444",
|
"444444",
|
||||||
# "444444",
|
"444444",
|
||||||
# " 4444 ",
|
" 4444 ",
|
||||||
# ],
|
],
|
||||||
# # Larger 3
|
# Larger 3
|
||||||
# [
|
[
|
||||||
# " 3333 ",
|
" 3333 ",
|
||||||
# " 333333 ",
|
" 333333 ",
|
||||||
# "33333333",
|
"33333333",
|
||||||
# "33333333",
|
"33333333",
|
||||||
# "33333333",
|
"33333333",
|
||||||
# "33333333",
|
"33333333",
|
||||||
# " 333333 ",
|
" 333333 ",
|
||||||
# " 3333 "
|
" 3333 "
|
||||||
# ],
|
],
|
||||||
# # Larger 4
|
# Larger 4
|
||||||
# [
|
[
|
||||||
# " 4444 ",
|
" 4444 ",
|
||||||
# " 444444 ",
|
" 444444 ",
|
||||||
# "44444444",
|
"44444444",
|
||||||
# "44444444",
|
"44444444",
|
||||||
# "44444444",
|
"44444444",
|
||||||
# "44444444",
|
"44444444",
|
||||||
# " 444444 ",
|
" 444444 ",
|
||||||
# " 4444 "
|
" 4444 "
|
||||||
# ],
|
],
|
||||||
# # Larger 5
|
# Larger 5
|
||||||
# [
|
[
|
||||||
# " 5555 ",
|
" 5555 ",
|
||||||
# " 555555 ",
|
" 555555 ",
|
||||||
# "55555555",
|
"55555555",
|
||||||
# "55555555",
|
"55555555",
|
||||||
# "55555555",
|
"55555555",
|
||||||
# "55555555",
|
"55555555",
|
||||||
# " 555555 ",
|
" 555555 ",
|
||||||
# " 5555 "
|
" 5555 "
|
||||||
# ],
|
],
|
||||||
# # Donut 3
|
# Donut 3
|
||||||
# [
|
[
|
||||||
# " 3333 ",
|
" 3333 ",
|
||||||
# " 333333 ",
|
" 333333 ",
|
||||||
# "33333333",
|
"33333333",
|
||||||
# "333 333",
|
"333 333",
|
||||||
# "333 333",
|
"333 333",
|
||||||
# "33333333",
|
"33333333",
|
||||||
# " 333333 ",
|
" 333333 ",
|
||||||
# " 3333 "
|
" 3333 "
|
||||||
# ],
|
],
|
||||||
# # Huge mix
|
# Huge mix
|
||||||
# [
|
[
|
||||||
# " 2222 ",
|
" 2222 ",
|
||||||
# " 233332 ",
|
" 233332 ",
|
||||||
# " 23555532 ",
|
" 23555532 ",
|
||||||
# "2355555532",
|
"2355555532",
|
||||||
# "2355555532",
|
"2355555532",
|
||||||
# "2355555532",
|
"2355555532",
|
||||||
# "2355555532",
|
"2355555532",
|
||||||
# " 23555532 ",
|
" 23555532 ",
|
||||||
# " 233332 ",
|
" 233332 ",
|
||||||
# " 2222 "
|
" 2222 "
|
||||||
# ],
|
],
|
||||||
# Huge 3
|
# Huge 3
|
||||||
[
|
[
|
||||||
" 3333 ",
|
" 3333 ",
|
||||||
|
@ -193,6 +200,8 @@ func _on_Button_button_up():
|
||||||
|
|
||||||
|
|
||||||
func init_round():
|
func init_round():
|
||||||
|
$Gameplay/Minimap.visible = false
|
||||||
|
|
||||||
var shape = SHAPES.pop_front()
|
var shape = SHAPES.pop_front()
|
||||||
if shape == null:
|
if shape == null:
|
||||||
shape = RANDOM_SHAPES[rng.randi_range(0, len(RANDOM_SHAPES)) - 1]
|
shape = RANDOM_SHAPES[rng.randi_range(0, len(RANDOM_SHAPES)) - 1]
|
||||||
|
@ -208,6 +217,7 @@ func init_round():
|
||||||
|
|
||||||
func start_round():
|
func start_round():
|
||||||
$Gameplay/Timer.start()
|
$Gameplay/Timer.start()
|
||||||
|
$Gameplay/Minimap.visible = true
|
||||||
$Gameplay/LeftPlayArea.can_act = true
|
$Gameplay/LeftPlayArea.can_act = true
|
||||||
$Gameplay/RightPlayArea.can_act = true
|
$Gameplay/RightPlayArea.can_act = true
|
||||||
|
|
||||||
|
|
|
@ -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/Menu.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://src/scenes/Gameplay.tscn" type="PackedScene" id=2]
|
[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/Main.gd" type="Script" id=5]
|
||||||
[ext_resource path="res://src/scenes/Results.tscn" type="PackedScene" id=6]
|
[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]
|
[sub_resource type="Animation" id=2]
|
||||||
resource_name = "FadeIn"
|
resource_name = "FadeIn"
|
||||||
step = 0.0166667
|
step = 0.0166667
|
||||||
|
@ -260,6 +266,12 @@ bus = "Right"
|
||||||
[node name="SoundOk" parent="Gameplay/RightPlayArea/Tiles/Cursor" index="1"]
|
[node name="SoundOk" parent="Gameplay/RightPlayArea/Tiles/Cursor" index="1"]
|
||||||
bus = "Right"
|
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="."]
|
[node name="Transitions" type="Control" parent="."]
|
||||||
margin_right = 1600.0
|
margin_right = 1600.0
|
||||||
margin_bottom = 900.0
|
margin_bottom = 900.0
|
||||||
|
|
|
@ -3,5 +3,11 @@ extends Node2D
|
||||||
|
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
var timer = $Timer
|
var timer = $Timer
|
||||||
$Minimap/Left.position.x = (1 - timer.time_left / timer.wait_time) * (get_viewport().size.x / 2)
|
var left = $Minimap/Left
|
||||||
$Minimap/Right.position.x = get_viewport().size.x - (1 - timer.time_left / timer.wait_time) * (get_viewport().size.x / 2)
|
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
|
||||||
|
|
|
@ -52,6 +52,7 @@ stream = ExtResource( 8 )
|
||||||
bus = "Music"
|
bus = "Music"
|
||||||
|
|
||||||
[node name="Minimap" type="Node2D" parent="."]
|
[node name="Minimap" type="Node2D" parent="."]
|
||||||
|
visible = false
|
||||||
position = Vector2( 0, 16 )
|
position = Vector2( 0, 16 )
|
||||||
|
|
||||||
[node name="Left" type="Sprite" parent="Minimap"]
|
[node name="Left" type="Sprite" parent="Minimap"]
|
||||||
|
|
|
@ -5,6 +5,7 @@ var can_act = false
|
||||||
|
|
||||||
|
|
||||||
func tiles_init(shape, sd):
|
func tiles_init(shape, sd):
|
||||||
|
print("Initializing tiles for %s..." % player)
|
||||||
$Tiles.set_shape(shape, sd)
|
$Tiles.set_shape(shape, sd)
|
||||||
check_matches()
|
check_matches()
|
||||||
|
|
||||||
|
@ -40,7 +41,6 @@ func cursor_init():
|
||||||
while x < len(shape[y]):
|
while x < len(shape[y]):
|
||||||
var new_pos = Vector2(x, y)
|
var new_pos = Vector2(x, y)
|
||||||
if not cursor_would_collide(new_pos):
|
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)
|
set_cursor_pos(new_pos)
|
||||||
return
|
return
|
||||||
x += 1
|
x += 1
|
||||||
|
|
|
@ -20,10 +20,8 @@ var size
|
||||||
var atoms = []
|
var atoms = []
|
||||||
|
|
||||||
|
|
||||||
var rng
|
|
||||||
|
|
||||||
|
|
||||||
func set_shape(val, sd):
|
func set_shape(val, sd):
|
||||||
|
var new_shape = [] + val
|
||||||
var new_size = len(val)
|
var new_size = len(val)
|
||||||
var rescale_to = clamp(6 / float(new_size), 0, 1)
|
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():
|
for atom in $Atoms.get_children():
|
||||||
atom.queue_free()
|
atom.queue_free()
|
||||||
|
|
||||||
rng = RandomNumberGenerator.new()
|
var rng = RandomNumberGenerator.new()
|
||||||
rng.set_seed(sd)
|
rng.set_seed(sd)
|
||||||
|
|
||||||
atoms = []
|
atoms = []
|
||||||
var offset = new_size / 2
|
var offset = new_size / 2
|
||||||
var y = - offset
|
var y = - offset
|
||||||
for row in val:
|
for row in new_shape:
|
||||||
var atoms_row = []
|
var atoms_row = []
|
||||||
var x = - offset
|
var x = - offset
|
||||||
for col in row:
|
for col in row:
|
||||||
|
@ -45,11 +43,11 @@ func set_shape(val, sd):
|
||||||
set_cell(x, y, 0)
|
set_cell(x, y, 0)
|
||||||
var atom = ATOM.instance()
|
var atom = ATOM.instance()
|
||||||
var random_amount = int(col)
|
var random_amount = int(col)
|
||||||
if random_amount > 0:
|
if random_amount > 1:
|
||||||
var keys = COLORS.keys()
|
var keys = COLORS.keys()
|
||||||
col = keys[rng.randi() % min(len(keys), random_amount)]
|
var index = rng.randi() % min(len(keys), random_amount)
|
||||||
val[y+offset][x+offset] = col
|
new_shape[y+offset][x+offset] = keys[index]
|
||||||
atom.self_modulate = COLORS[col]
|
atom.self_modulate = COLORS[new_shape[y+offset][x+offset]]
|
||||||
atom.position = Vector2(x * TILE_SIZE + TILE_OFFSET, y * TILE_SIZE + TILE_OFFSET)
|
atom.position = Vector2(x * TILE_SIZE + TILE_OFFSET, y * TILE_SIZE + TILE_OFFSET)
|
||||||
$Atoms.add_child(atom)
|
$Atoms.add_child(atom)
|
||||||
atoms_row.append(atom)
|
atoms_row.append(atom)
|
||||||
|
@ -60,5 +58,5 @@ func set_shape(val, sd):
|
||||||
y += 1
|
y += 1
|
||||||
|
|
||||||
size = new_size
|
size = new_size
|
||||||
shape = val
|
shape = new_shape
|
||||||
scale = Vector2(rescale_to, rescale_to)
|
scale = Vector2(rescale_to, rescale_to)
|
||||||
|
|
Loading…
Reference in a new issue