本文整理汇总了Python中map.Map.nearShapes方法的典型用法代码示例。如果您正苦于以下问题:Python Map.nearShapes方法的具体用法?Python Map.nearShapes怎么用?Python Map.nearShapes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map.Map
的用法示例。
在下文中一共展示了Map.nearShapes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: usage
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import nearShapes [as 别名]
#.........这里部分代码省略.........
logging.debug("joystick Button "+str(i+1)+" pressed.")
if(i in self.cur_pad_map['ask']):
self.player.shape.tryAsk()
elif(i in self.cur_pad_map['swirl_right']):
self.player.shape.trySwirlRight()
elif(i in self.cur_pad_map['swirl_left']):
self.player.shape.trySwirlLeft()
elif(i in self.cur_pad_map['give']):
self.player.shape.tryGive()
elif(i in self.cur_pad_map['doswirl_up']):
self.player.shape.activateSwirl(True)
elif(i in self.cur_pad_map['doswirl_dn']):
self.player.shape.activateSwirl(False)
elif(i in self.cur_pad_map['reset']):
self.player.shape.reset()
elif(i in self.cur_pad_map['quit']):
logging.info("That was RANDOM SEED {0}. Hope you had fun.".format(self.crazySeed))
logging.debug("Quitting program.")
pygame.quit()
sys.exit()
# multi-button combinations
if(self.pacjoy.get_button(self.cur_button_map['Lshoulder']) and self.pacjoy.get_button(self.cur_button_map['Rshoulder'])
and self.pacjoy.get_button(self.cur_button_map['Lcenter']) and self.pacjoy.get_button(self.cur_button_map['Rcenter'])):
self.doMenu()
if event.type == pygame.JOYBUTTONUP:
#logging.debug("Joystick button released.")
for i in range( self.num_buttons ):
if(not self.pacjoy.get_button(i) and self.button_status[i]):
self.button_status[i] = False
#logging.debug("Button "+str(i+1)+" released.")
# end of : input_mode == INPUT_JOYSTICK
if(INPUT_KEYBOARD in self.input_mode):
if event.type == KEYDOWN:
self.player.notIdle(ticks)
# Find which key was pressed
if event.key == self.cur_kb_map['top']: # "top" button
self.player.shape.tryGive()
elif event.key == self.cur_kb_map['left']: # "left" button
self.player.shape.trySwirlLeft()
elif event.key == self.cur_kb_map['bottom']: # "bottom" button
self.player.shape.tryAsk()
elif event.key == self.cur_kb_map['right']: # "right" button
self.player.shape.trySwirlRight()
elif event.key == self.cur_kb_map['Lshoulder']: # "left shoulder" button
self.player.shape.activateSwirl(False)
elif event.key == self.cur_kb_map['Rshoulder']: # "right shoulder" button
self.player.shape.activateSwirl(True)
elif event.key == K_f: # toggle fullscreen
self.toggleFullscreen()
elif event.key == K_DOWN:
self.player.shape.startMove(DIR_DOWN)
elif event.key == K_UP:
self.player.shape.startMove(DIR_UP)
elif event.key == K_RIGHT:
self.player.shape.startMove(DIR_RIGHT)
elif event.key == K_LEFT:
self.player.shape.startMove(DIR_LEFT)
elif event.key == K_t: # NOTE: "teleport" effect - FOR DEBUG ONLY ??
self.player.shape.reset()
elif event.key == K_SPACE:
# DEBUG - activate autonomosity
nearby_shapes = self.map.nearShapes(self.player.shape.getCenter(), self.map.character_size * 1.5, self.player.shape)
if len(nearby_shapes) > 0:
#logging.debug("Shapes near to S#{0}: {1}".format(self.id, nearby_shapes))
receiver = nearby_shapes[0]
receiver.autonomous = not receiver.autonomous
logging.debug("toggling autonomy for shape #{0}, now {1}".format(receiver.id, receiver.autonomous))
else:
logging.debug("no nearby shapes")
elif event.key == K_BACKQUOTE:
self.doMenu()
if event.type == KEYUP:
if event.key == K_DOWN:
self.player.shape.stopMove(DIR_DOWN)
elif event.key == K_UP:
self.player.shape.stopMove(DIR_UP)
elif event.key == K_RIGHT:
self.player.shape.stopMove(DIR_RIGHT)
elif event.key == K_LEFT:
self.player.shape.stopMove(DIR_LEFT)
# end of (INPUT_KEYBOARD)
# end for (events)
# movement should be smooth, so not tied to event triggers
if(INPUT_JOYSTICK in self.input_mode and \
('analog_axis_y' in self.cur_pad_map.keys() and 'analog_axis_x' in self.cur_pad_map.keys())):
fbAxis = round(self.pacjoy.get_axis(self.cur_pad_map['analog_axis_y']), 3)
if(abs(fbAxis) > JOYSTICK_NOISE_LEVEL):
self.player.shape.move(0, fbAxis * self.player.shape.linearSpeed)
lrAxis = round(self.pacjoy.get_axis(self.cur_pad_map['analog_axis_x']), 3)
if(abs(lrAxis) > JOYSTICK_NOISE_LEVEL):
self.player.shape.move(lrAxis * self.player.shape.linearSpeed, 0)
# after processing any pending user events, check for idle condition
self.player.checkIdle(ticks)