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

Improved things here and there

haha atomic commits in a game jam
come on
This commit is contained in:
Steffo 2022-10-02 04:27:15 +02:00
parent 1fce7cb55b
commit 98aded7b07
Signed by: steffo
GPG key ID: 6965406171929D01
7 changed files with 150 additions and 70 deletions

View file

@ -4,19 +4,86 @@ func _on_LeftColorPicker_color_changed(color: Color):
$Background/Left.modulate = color
$Gameplay/LeftPlayArea.self_modulate = color
$Gameplay/LeftPlayArea/Tiles.self_modulate = color
$Gameplay/LeftPlayArea/Label.self_modulate = color
$Gameplay/Minimap/Left.self_modulate = color
func _on_RightColorPicker_color_changed(color: Color):
$Background/Right.modulate = color
$Gameplay/RightPlayArea.self_modulate = color
$Gameplay/RightPlayArea/Tiles.self_modulate = color
$Gameplay/RightPlayArea/Label.self_modulate = color
$Gameplay/Minimap/Right.self_modulate = color
const SHAPE = [
# Cross
[
" GG ",
" YY ",
" YGGY ",
"RBRWWRBR",
"RBRWWRBR",
" YGGY ",
" YY ",
" GG "
],
# Larger
[
" GGBB ",
" GRRYYB ",
"GRRRYYYB",
"GRRRYYYB",
"YBBBGGGR",
"YBBBGGGR",
" YBBGGR ",
" YYRR "
],
# Donut
[
" RBBR ",
" RBRRBR ",
"RBRBBRBR",
"BRB BRB",
"BRB BRB",
"RBRBBRBR",
" RBRRBR ",
" RBBR "
],
# Good intro level
[
" RRBB ",
"RRBRBB",
"RBRBRB",
"BRBRBR",
"BBRBRR",
" BBRR "
],
# With a trick
[
" RBBR ",
"RBRRBR",
"BRWWRB",
"BRWWRB",
"RBRRBR",
" RBBR "
],
# TODO: Find solution?
[
" RRBB ",
"RBBRRB",
"BRRBBR",
"RBB RB",
"BRRBBR",
" BBRR "
],
]
func _on_Button_button_up():
$Menu.visible = false
$Gameplay.visible = true
$Gameplay/LeftPlayArea.tiles_init()
$Gameplay/LeftPlayArea.tiles_init(SHAPE[0])
$Gameplay/LeftPlayArea.cursor_init()
$Gameplay/RightPlayArea.tiles_init()
$Gameplay/RightPlayArea.tiles_init(SHAPE[0])
$Gameplay/RightPlayArea.cursor_init()
$Gameplay/Timer.start()

View file

@ -5,3 +5,8 @@ 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)
func _on_Timer_timeout():
$LeftPlayArea.can_act = false
$RightPlayArea.can_act = false

View file

@ -14,6 +14,7 @@ position = Vector2( 400, 450 )
player = "p1"
[node name="Tiles" parent="LeftPlayArea" index="1"]
visible = true
self_modulate = Color( 1, 0.701961, 0.701961, 1 )
[node name="RightPlayArea" parent="." instance=ExtResource( 6 )]
@ -22,6 +23,7 @@ position = Vector2( 1200, 450 )
player = "p2"
[node name="Tiles" parent="RightPlayArea" index="1"]
visible = true
self_modulate = Color( 0.701961, 0.701961, 1, 1 )
[node name="Timer" parent="." instance=ExtResource( 7 )]
@ -41,5 +43,7 @@ position = Vector2( 1600, 0 )
scale = Vector2( 0.5, 0.5 )
texture = ExtResource( 2 )
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
[editable path="LeftPlayArea"]
[editable path="RightPlayArea"]

View file

@ -27,28 +27,35 @@ anchor_bottom = 1.0
alignment = 1
[node name="Title" type="Label" parent="VBoxContainer"]
margin_top = 95.0
margin_right = 1600.0
margin_bottom = 153.0
margin_top = 528.0
margin_right = 3200.0
margin_bottom = 586.0
custom_fonts/font = SubResource( 3 )
text = "Atomic Clash"
align = 1
[node name="Title2" type="Label" parent="VBoxContainer"]
margin_top = 590.0
margin_right = 3200.0
margin_bottom = 620.0
text = "Pick your (preferably light) colors!"
align = 1
[node name="Padding" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 157.0
margin_right = 1600.0
margin_bottom = 197.0
margin_top = 624.0
margin_right = 3200.0
margin_bottom = 664.0
rect_min_size = Vector2( 0, 40 )
[node name="Colors" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 201.0
margin_right = 1600.0
margin_bottom = 709.0
margin_top = 668.0
margin_right = 3200.0
margin_bottom = 1176.0
alignment = 1
[node name="Left Player" type="VBoxContainer" parent="VBoxContainer/Colors"]
margin_left = 304.0
margin_right = 724.0
margin_left = 1104.0
margin_right = 1524.0
margin_bottom = 508.0
alignment = 1
@ -58,10 +65,9 @@ margin_bottom = 30.0
text = "Left Player [WASD + Space]"
[node name="ColorPicker" type="ColorPicker" parent="VBoxContainer/Colors/Left Player"]
margin_left = 4.0
margin_top = 38.0
margin_right = 424.0
margin_bottom = 512.0
margin_top = 34.0
margin_right = 420.0
margin_bottom = 508.0
color = Color( 1, 0.7, 0.7, 1 )
edit_alpha = false
hsv_mode = true
@ -69,8 +75,8 @@ presets_enabled = false
presets_visible = false
[node name="Vs" type="VBoxContainer" parent="VBoxContainer/Colors"]
margin_left = 728.0
margin_right = 872.0
margin_left = 1528.0
margin_right = 1672.0
margin_bottom = 508.0
rect_min_size = Vector2( 144, 0 )
alignment = 1
@ -84,8 +90,8 @@ align = 1
valign = 1
[node name="Right Player" type="VBoxContainer" parent="VBoxContainer/Colors"]
margin_left = 876.0
margin_right = 1296.0
margin_left = 1676.0
margin_right = 2096.0
margin_bottom = 508.0
alignment = 1
@ -96,10 +102,9 @@ text = "[↑←↓→ + Enter] Right Player"
align = 2
[node name="ColorPicker" type="ColorPicker" parent="VBoxContainer/Colors/Right Player"]
margin_left = 4.0
margin_top = 38.0
margin_right = 424.0
margin_bottom = 512.0
margin_top = 34.0
margin_right = 420.0
margin_bottom = 508.0
color = Color( 0.7, 0.7, 1, 1 )
edit_alpha = false
hsv_mode = true
@ -107,16 +112,16 @@ presets_enabled = false
presets_visible = false
[node name="Padding2" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 713.0
margin_right = 1600.0
margin_bottom = 753.0
margin_top = 1180.0
margin_right = 3200.0
margin_bottom = 1220.0
rect_min_size = Vector2( 0, 40 )
[node name="Button" type="Button" parent="VBoxContainer"]
margin_left = 720.0
margin_top = 757.0
margin_right = 880.0
margin_bottom = 805.0
margin_left = 1520.0
margin_top = 1224.0
margin_right = 1680.0
margin_bottom = 1272.0
rect_min_size = Vector2( 160, 48 )
size_flags_horizontal = 4
text = "Start!"

View file

@ -1,24 +1,20 @@
extends Sprite
func tiles_init():
$Tiles.set_shape([
" RRBB ",
"RRBRBB",
"RBRBRB",
"BRBRBR",
"BBRBRR",
" BBRR "
])
var can_act = true
func tiles_init(shape):
$Tiles.set_shape(shape)
check_matches()
var cursor_pos setget set_cursor_pos
func set_cursor_pos(val):
var offset = $Tiles.size / 2
var offset = $Tiles.size / 2 - 1
$Tiles/Cursor.position = Vector2( \
(val.x - offset) * $Tiles.TILE_SIZE + 43, \
(val.y - offset) * $Tiles.TILE_SIZE + 43 \
(val.x - offset) * $Tiles.TILE_SIZE, \
(val.y - offset) * $Tiles.TILE_SIZE \
)
cursor_pos = val
@ -53,42 +49,45 @@ func cursor_init():
get_tree().quit()
func cursor_up():
cursor_move(Vector2(cursor_pos.x, cursor_pos.y - 1))
if can_act:
cursor_move(Vector2(cursor_pos.x, cursor_pos.y - 1))
func cursor_right():
cursor_move(Vector2(cursor_pos.x + 1, cursor_pos.y))
if can_act:
cursor_move(Vector2(cursor_pos.x + 1, cursor_pos.y))
func cursor_down():
cursor_move(Vector2(cursor_pos.x, cursor_pos.y + 1))
if can_act:
cursor_move(Vector2(cursor_pos.x, cursor_pos.y + 1))
func cursor_left():
cursor_move(Vector2(cursor_pos.x - 1, cursor_pos.y))
if can_act:
cursor_move(Vector2(cursor_pos.x - 1, cursor_pos.y))
func cursor_move(dest):
if not cursor_would_collide(dest):
set_cursor_pos(dest)
else:
print("Cursor collided @ %d, %d" % [dest.x, dest.y])
func cursor_rotate():
var top_left = $Tiles.atoms[cursor_pos.y][cursor_pos.x]
var top_right = $Tiles.atoms[cursor_pos.y][cursor_pos.x+1]
var bottom_left = $Tiles.atoms[cursor_pos.y+1][cursor_pos.x]
var bottom_right = $Tiles.atoms[cursor_pos.y+1][cursor_pos.x+1]
var tmp = top_left.position
top_left.position = top_right.position
top_right.position = bottom_right.position
bottom_right.position = bottom_left.position
bottom_left.position = tmp
$Tiles.atoms[cursor_pos.y][cursor_pos.x] = bottom_left
$Tiles.atoms[cursor_pos.y][cursor_pos.x+1] = top_left
$Tiles.atoms[cursor_pos.y+1][cursor_pos.x+1] = top_right
$Tiles.atoms[cursor_pos.y+1][cursor_pos.x] = bottom_right
if can_act:
var top_left = $Tiles.atoms[cursor_pos.y][cursor_pos.x]
var top_right = $Tiles.atoms[cursor_pos.y][cursor_pos.x+1]
var bottom_left = $Tiles.atoms[cursor_pos.y+1][cursor_pos.x]
var bottom_right = $Tiles.atoms[cursor_pos.y+1][cursor_pos.x+1]
var tmp = top_left.position
top_left.position = top_right.position
top_right.position = bottom_right.position
bottom_right.position = bottom_left.position
bottom_left.position = tmp
$Tiles.atoms[cursor_pos.y][cursor_pos.x] = bottom_left
$Tiles.atoms[cursor_pos.y][cursor_pos.x+1] = top_left
$Tiles.atoms[cursor_pos.y+1][cursor_pos.x+1] = top_right
$Tiles.atoms[cursor_pos.y+1][cursor_pos.x] = bottom_right
# Optimizable
check_matches()
# Optimizable
check_matches()
func check_matches():

View file

@ -35,7 +35,7 @@ func set_shape(val):
set_cell(x, y, 0)
var atom = ATOM.instance()
atom.self_modulate = COLORS[col]
atom.position = Vector2(x * TILE_SIZE, y * TILE_SIZE)
atom.position = Vector2(x * TILE_SIZE + TILE_SIZE / 2, y * TILE_SIZE + TILE_SIZE / 2)
add_child(atom)
atoms_row.append(atom)
else:

View file

@ -6,7 +6,7 @@
[sub_resource type="TileSet" id=1]
0/name = "grid-tile.png 0"
0/texture = ExtResource( 1 )
0/tex_offset = Vector2( -43, -43 )
0/tex_offset = Vector2( 0, 0 )
0/modulate = Color( 1, 1, 1, 1 )
0/region = Rect2( 0, 0, 85, 85 )
0/tile_mode = 0
@ -20,7 +20,7 @@
0/z_index = 0
[node name="Tiles" type="TileMap"]
position = Vector2( 43, 43 )
visible = false
tile_set = SubResource( 1 )
cell_size = Vector2( 86, 86 )
cell_tile_origin = 1