-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreateBlock.py
81 lines (74 loc) · 1.08 KB
/
createBlock.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# -*- coding: utf-8 -*-
# @Author: wangjb
# @Date: 2018-02-23 16:56:24
# @Last Modified by: wangjb
# @Last Modified time: 2018-03-22 11:38:17
import numpy as np
import random
import copy
t = {
'shape' : [[0,1,0],
[1,1,1]],
'color' : ''
}
l = {
'shape' : [
[1,0],
[1,0],
[1,1]
]
}
j = {
'shape' : [
[0,1],
[0,1],
[1,1]
]
}
o = {
'shape' : [
[1,1],
[1,1]
]
}
z = {
'shape' : [
[1,1,0],
[0,1,1]
]
}
i = {
'shape' : [
[1],
[1],
[1],
[1]
]
}
y = {
'shape' : [
[1,1,1,1]
]
}
shape = [t,l,j,o,z,i,y]
color = [
[193,59,253],
[252,249,41],
[104,243,18],
[239,139,38],
[227,57,192],
[14,25,152],
[117,49,247],
[209,81,68]
]
class createBlock(object):
"""docstring for createBlock"""
def __init__(self):
self.shape = shape
self.color = color
def random_block(self):
num = int(random.random()*6)
self.shape[num]['color'] = color[num]
self.shape[num]['index'] = [0,4]#x y第几列第几行
random_shape = self.shape[num]
return copy.deepcopy(random_shape)