本文整理汇总了Python中track.Track.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Track.draw方法的具体用法?Python Track.draw怎么用?Python Track.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类track.Track
的用法示例。
在下文中一共展示了Track.draw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: App
# 需要导入模块: from track import Track [as 别名]
# 或者: from track.Track import draw [as 别名]
class App(Tk):
def __init__(self, ftimer):
Tk.__init__(self)
self.sats = Track()
self.sats.load_local("data.txt") # to be changed
self.sats.add_satellite(7) # achtung, hardcode
menu = UserMenu(parent = self)
self.config(menu = menu)
self.title('SatKit Ground Tracking')
self.timer = ftimer
self.timer.callback_function = self.redraw
self.time_speed = 1 # normal speed
self.var = IntVar()
self.scale = Scale(self, variable = self.var, from_ = 1, to = 3600,
orient = HORIZONTAL, showvalue=0, sliderlength=15,
length=400, command=self.set_time_speed)
self.date = Label(self)
def redraw(self):
self.timer.set_speed(self.time_speed) # bad, should be improven,~event
self.sats.update_satellites(self.time_speed * Time.TIMER_INTERVAL)
#print self.time_speed
# recompute "current" time, later,,,
self.date.config(text = str(self.timer.current_time)[0:21])
self.date.grid(row = 0, column = 1)
self.scale.grid(row = 0, column = 0)
self.sats.anim.grid(row = 1, columnspan = 2)
self.sats.draw()
def set_time_speed(self, secs):
self.time_speed = int(secs)
示例2:
# 需要导入模块: from track import Track [as 别名]
# 或者: from track.Track import draw [as 别名]
paused = True
while paused:
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_p:
paused = False
clock.tick(constants.FRAME_RATE) # fps
# update game status and handle game logic
car_list.update(track, frame_counter)
particles.update(frame_counter)
bayes.update(frame_counter)
status_bar.update(frame_counter)
# update draw buffer
track.draw(screen)
sprite_list.draw(screen)
if draw_viewfield:
for car in car_list:
car.driver.draw_viewfield(screen)
# draw particles
particles.draw(screen)
bayes.draw(screen)
# update screen
clock.tick(constants.FRAME_RATE) # fps
frame_counter += 1
pygame.display.flip()