本文整理汇总了Python中Robot.Robot.render方法的典型用法代码示例。如果您正苦于以下问题:Python Robot.render方法的具体用法?Python Robot.render怎么用?Python Robot.render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Robot.Robot
的用法示例。
在下文中一共展示了Robot.render方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Simulation
# 需要导入模块: from Robot import Robot [as 别名]
# 或者: from Robot.Robot import render [as 别名]
class Simulation():
def __init__(self):
self.town = Town(maxShops = 10)
self.town.render(DisplayDriver.engine)
self.robot = Robot(random.choice(list(self.town.shopDict)), town = self.town)
self.robot.render(DisplayDriver.engine)
self.consumeText = OnscreenText(pos = [Globals.RESOLUTION[0]-200,0], text = '', size = 20)
self.consumeText.render(DisplayDriver.engine)
self.distanceText = OnscreenText(pos = [Globals.RESOLUTION[0]-200,20], text = '', size = 20)
self.distanceText.render(DisplayDriver.engine)
self.contraintsText = OnscreenText(pos = [Globals.RESOLUTION[0]-200,30], text = '', size = 20)
self.contraintsText.render(DisplayDriver.engine)
def tick(self):
self.robot.tick()
self.distanceText.setText('Distance: %sm' %(int(self.robot.getDistanceTraveled())))
self.consumeText.setText('Fuel Used: %s' %(int(self.robot.getFuelUsed())))
try:
self.contraintsText.setText('Distance/Fuel: %s' %(round(self.robot.getDistanceTraveled()/self.robot.getFuelUsed(), 2)))
except ZeroDivisionError:
pass
示例2: Simulation
# 需要导入模块: from Robot import Robot [as 别名]
# 或者: from Robot.Robot import render [as 别名]
class Simulation():
def __init__(self):
self.town = Town(maxShops = 10)
self.town.render(DisplayDriver.engine)
self.robot = Robot(random.choice(list(self.town.shopDict)), town = self.town)
self.robot.render(DisplayDriver.engine)
def tick(self):
self.robot.tick()
示例3: Simulation
# 需要导入模块: from Robot import Robot [as 别名]
# 或者: from Robot.Robot import render [as 别名]
class Simulation():
def __init__(self):
self.robot = Robot([640/2,640/2])
self.robot.render(DisplayDriver.engine)
#r.setBearing(random.random()*360)
self.robot.velocity = 100
#DisplayDriver.eventManager.bind(MOUSEMOTION,mouseMoved)
DisplayDriver.engine.addTask(r.tick)
def mouseMoved(event):
pos = event.pos
self.robot.setBearing(Point(pos).getBearing(r.getPos()))
示例4: lel
# 需要导入模块: from Robot import Robot [as 别名]
# 或者: from Robot.Robot import render [as 别名]
class lel():
def __init__(self):
self.t = None
self.mouseText = OnscreenText(pos=[0,0], text = '', size = 20)
self.mouseText.render(DisplayDriver.engine)
def new(self, event=None):
if self.t:
self.t.destroy()
self.r.destroy()
self.t = Town(maxShops=15)
self.t.render(DisplayDriver.engine)
self.r = Robot(random.choice(list(self.t.shopDict)), town = self.t)
self.r.calcPath()
self.r.render(DisplayDriver.engine)
def kek(self, event):
self.mouseText.setPos(event.pos)
self.mouseText.setText(str(event.pos))
def tick(self):
self.r.tick()
示例5: __init__
# 需要导入模块: from Robot import Robot [as 别名]
# 或者: from Robot.Robot import render [as 别名]
class Simulation:
def __init__(self, items = {}):
DisplayDriver.eventManager.bind(KEYDOWN, self.takeInput)
DisplayDriver.engine.graphics.setBackground([51,204,51])
itemHandler.init(False)
if not items:
self.items = {}
items = itemHandler.getItemsSorted(0, False)
for i in range(random.randint(3,15)):
item = random.choice(items)
items.remove(item)
self.items[item] = random.randint(1,3)
else:
self.items = items
self.taskId = None
self.generate()
self.start()
def getShoppingList(self):
return self.items
def tick(self):
for i in range(SIMSPEED):
if not self.robot:
return
if self.robot.status == "Finished":
DisplayDriver.engine.removeTask(self.taskId)
self.taskId = None
return
self.robot.tick()
self.distanceText.setText('Distance: %sm' %(int(self.robot.getDistanceTraveled())))
self.consumeText.setText('Fuel Used: %s' %(int(self.robot.getFuelUsed())))
try:
self.contraintsText.setText('Distance/Fuel: %s' %(round(self.robot.getDistanceTraveled()/self.robot.getFuelUsed(), 2)))
except ZeroDivisionError:
pass
def generate(self):
self.town = Town(maxShops = 13)
self.town.render(DisplayDriver.engine)
self.robot = Robot(town = self.town, shoppingList = self.getShoppingList())
self.robot.render(DisplayDriver.engine)
self.consumeText = OnscreenText(pos = [Globals.RESOLUTION[0]-200,0], text = '', size = 20)
self.consumeText.render(DisplayDriver.engine)
self.distanceText = OnscreenText(pos = [Globals.RESOLUTION[0]-200,20], text = '', size = 20)
self.distanceText.render(DisplayDriver.engine)
self.contraintsText = OnscreenText(pos = [Globals.RESOLUTION[0]-200,30], text = '', size = 20)
self.contraintsText.render(DisplayDriver.engine)
def takeInput(self, event):
if event.key == K_a:
self.reset()
def destroy(self):
if self.robot.route:
self.robot.route.destroy()
self.robot.route = None
if self.taskId:
DisplayDriver.engine.removeTask(self.taskId)
self.taskId = None
self.consumeText.removeNode()
self.distanceText.removeNode()
self.robot.destroy()
self.town.destroy()
self.contraintsText.removeNode()
if self.taskId:
DisplayDriver.engine.removeTask(self.taskId)
def reset(self):
if self.robot.route:
self.robot.route.destroy()
self.robot.route = None
while not self.robot.route:
self.destroy()
self.generate()
self.start()
def start(self):
self.taskId = DisplayDriver.engine.addTask(self.tick)