本文整理匯總了Python中rect.Rect.set_name方法的典型用法代碼示例。如果您正苦於以下問題:Python Rect.set_name方法的具體用法?Python Rect.set_name怎麽用?Python Rect.set_name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rect.Rect
的用法示例。
在下文中一共展示了Rect.set_name方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: dredgeRiverSingle
# 需要導入模塊: from rect import Rect [as 別名]
# 或者: from rect.Rect import set_name [as 別名]
def dredgeRiverSingle(nature,direction,CX,CY):
rivert=[]
# This is the start coordinate of the river, perpendicular to the
# axis of the river. N/S rivers choose positions on the E/W axis,
# and vice-versa
axis_size = CX if direction else CY
line_pos=random.randint(0, axis_size)
#river width, no more than half the map
river_size=min(random.randint(3,120), axis_size//2)
for i in range(0,axis_size):
if direction:
element=Rect(Point(i,line_pos),Point(i,line_pos+river_size))
else:
element=Rect(Point(line_pos,i),Point(line_pos+river_size,i))
element.set_name('RIVER')
rivert.append(element)
prev=0;
for f in rivert:
prev=prev+random.randint(-1,1)
f.move(direction+2,prev) # in rect, 1=up, 2=right
nature.extend(rivert)
示例2: digCave
# 需要導入模塊: from rect import Rect [as 別名]
# 或者: from rect.Rect import set_name [as 別名]
def digCave(nature):
caves = RESOURCES.count('CAVE')
print('Digging %d cave%s' % ( caves, 's' if caves > 1 else ''))
for p in range(0,RESOURCES.count('CAVE')):
CX = config['CITY_SIZE_X']
CY = config['CITY_SIZE_Y']
CX2 = config['CITY_SIZE_X']//2
CY2 = config['CITY_SIZE_Y']//2
CX3 = config['CITY_SIZE_X']//3
CY3 = config['CITY_SIZE_Y']//3
p=Point(CX2,CY2)
MPS=200
mps=30
if(random.randint(0,1)==0):
p1=Point(random.randint(0,CX3),random.randint(0,CY))
else:
p1=Point(random.randint(0,CX),random.randint(0,CY3))
p2=Point(random.randint(p1.x+mps,p1.x+MPS), random.randint(p1.y+mps,p1.y+MPS))
place=Rect(p1,p2)
place.set_name('CAVE')
nature.append(place)
示例3: print
# 需要導入模塊: from rect import Rect [as 別名]
# 或者: from rect.Rect import set_name [as 別名]
print('*'),
for place in nature:
for place2 in nature:
if(not (id(place)==id(place2))):
if(place.overlaps(place2)):
place.move(random.randint(0,4),random.randint(20,30))
print('[10/10]')
print('Building river')
for p in range(0,RESOURCES.count('RIVERX')):
rivert=[]
liney=random.randint(0,CITY_SIZE_Y)
river_size=random.randint(3,120)
for i in range(0,CITY_SIZE_X):
element=Rect(Point(i,liney),Point(i,liney+river_size))
element.set_name('RIVER')
rivert.append(element)
prev=0;
for f in rivert:
prev=prev+random.randint(-1,1)
f.move(1,prev)
nature.extend(rivert)
for p in range(0,RESOURCES.count('RIVERY')):
rivert=[]
linex=random.randint(0,CITY_SIZE_X)
river_size=random.randint(3,120)
for i in range(0,CITY_SIZE_Y):
element=Rect(Point(linex,i),Point(linex+river_size,i))
element.set_name('RIVER')