Use spotlights instead of ghost. Move minoes in tetromino

This commit is contained in:
adrienmalin
2019-01-01 04:06:00 +01:00
parent 556f9fca24
commit 84abafae58
32 changed files with 79 additions and 215 deletions

View File

@ -54,7 +54,6 @@ var score = 0
func _ready():
randomize()
print(NB_LINES)
for y in range(NB_LINES):
exploding_lines.append(ExplodingLine.instance())
add_child(exploding_lines[y])
@ -87,7 +86,6 @@ func new_piece():
current_piece = next_piece
current_piece.translation = START_POSITION
current_piece.emit_trail(true)
update_ghost_piece()
autoshift_action = ""
next_piece = random_piece()
next_piece.translation = NEXT_POSITION
@ -162,27 +160,16 @@ func possible_positions(initial_positions, movement):
func move(movement):
if current_piece.move(movement):
$LockDelay.start()
if movement.x:
update_ghost_piece()
return true
else:
return false
func rotate(direction):
if current_piece.rotate(direction):
update_ghost_piece()
$LockDelay.start()
return true
else:
return false
func update_ghost_piece():
var new_positions = current_piece.positions()
var positions
while(new_positions):
positions = new_positions
new_positions = possible_positions(positions, movements["soft_drop"])
$GhostPiece.apply_positions(positions)
func _on_DropTimer_timeout():
move(movements["soft_drop"])
@ -211,7 +198,6 @@ func line_clear():
set_cell_item(x, y2, 0, get_cell_item(x, y2+1, 0))
lines_cleared += 1
exploding_lines[y].restart()
update_ghost_piece()
if lines_cleared or current_piece.t_spin:
var s = SCORES[lines_cleared][current_piece.t_spin]
score += 100 * s
@ -245,9 +231,8 @@ func hold():
else:
held_piece = current_piece
new_piece()
update_ghost_piece()
held_piece.translation = HOLD_POSITION
held_piece.emit_trail(false)
held_piece.translation = HOLD_POSITION
current_piece_held = true
func resume():

View File

@ -1,11 +1,10 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=7 format=2]
[ext_resource path="res://Mino/MinoLibrary.tres" type="MeshLibrary" id=1]
[ext_resource path="res://Tetrominos/Mino/MinoLibrary.tres" type="MeshLibrary" id=1]
[ext_resource path="res://GridMap/GridMap.gd" type="Script" id=2]
[ext_resource path="res://GridMap/GridBack.tscn" type="PackedScene" id=3]
[ext_resource path="res://GridMap/BackMaterial.tres" type="Material" id=4]
[ext_resource path="res://Tetrominos/GhostPiece.tscn" type="PackedScene" id=5]
[ext_resource path="res://midi/MidiPlayer.tscn" type="PackedScene" id=6]
[ext_resource path="res://midi/MidiPlayer.tscn" type="PackedScene" id=5]
[sub_resource type="CubeMesh" id=1]
@ -16,7 +15,7 @@ subdivide_width = 0
subdivide_height = 0
subdivide_depth = 0
[node name="GridMap" type="GridMap" index="0"]
[node name="GridMap" type="GridMap"]
theme = ExtResource( 1 )
cell_size = Vector3( 1, 1, 1 )
@ -28,13 +27,13 @@ cell_scale = 1.0
collision_layer = 1
collision_mask = 1
data = {
"cells": PoolIntArray( 13, 0, 0, 65543, 0, 0 )
"cells": PoolIntArray( )
}
script = ExtResource( 2 )
_sections_unfolded = [ "Cell", "Transform" ]
__meta__ = {
"_editor_clip_": 1,
"_editor_floor_": Vector3( 0, 1, 0 )
"_editor_floor_": Vector3( 0, -1, 0 )
}
[node name="DropTimer" type="Timer" parent="." index="0"]
@ -80,12 +79,7 @@ mesh = SubResource( 1 )
transform = Transform( 7, 0, 0, 0, 7, 0, 0, 0, 0.1, 14, 16, -1 )
mesh = SubResource( 1 )
[node name="GhostPiece" parent="." index="7" instance=ExtResource( 5 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 5, 20, 0 )
_sections_unfolded = [ "Pause", "Transform" ]
[node name="MidiPlayer" parent="." index="8" instance=ExtResource( 6 )]
[node name="MidiPlayer" parent="." index="7" instance=ExtResource( 5 )]
file = "res://midi/Tetris - Song A.mid"
volume_db = -24