@@ -2,6 +2,7 @@ import { want } from '../../unit/'
2
2
import event from '../../unit/event'
3
3
import states from '../states'
4
4
import { music } from '../../unit/music'
5
+ import { fromJS , List } from 'immutable'
5
6
const down = store => {
6
7
store . commit ( 'key_down' , true )
7
8
if ( store . state . cur !== null ) {
@@ -31,18 +32,17 @@ const down = store => {
31
32
// store.dispatch(actions.moveBlock(next));
32
33
states . auto ( )
33
34
} else {
34
- let matrix = state . matrix
35
+ let matrix = fromJS ( state . matrix )
35
36
const shape = cur . shape
36
- const xy = cur . xy
37
+ const xy = fromJS ( cur . xy )
38
+ console . log ( { matrix, shape, xy } )
37
39
shape . forEach ( ( m , k1 ) =>
38
40
m . forEach ( ( n , k2 ) => {
39
- if ( n && xy [ 0 ] + k1 >= 0 ) {
41
+ if ( n && xy . get ( 0 ) + k1 >= 0 ) {
40
42
// 竖坐标可以为负
41
- let line = matrix [ xy [ 0 ] + k1 ]
42
- // line = line.set(xy[1] + k2, 1);
43
- line [ xy [ 1 ] + k2 ] = 1
44
- matrix [ xy [ 0 ] + k1 ] = line
45
- // matrix = matrix.set(xy[0] + k1, line);
43
+ let line = matrix . get ( xy . get ( 0 ) + k1 )
44
+ line = line . set ( xy . get ( 1 ) + k2 , 1 )
45
+ matrix = matrix . set ( xy . get ( 0 ) + k1 , line )
46
46
}
47
47
} )
48
48
)
0 commit comments