本文整理汇总了Python中simplegui.create_timer函数的典型用法代码示例。如果您正苦于以下问题:Python create_timer函数的具体用法?Python create_timer怎么用?Python create_timer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_timer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
self.tetris = {}
self.pile = Pile()
self.time = 0
self.state = 0
self.score = 0
self.chain = 0
self.points = []
self.move_dict = {}
self.best = 0
self.time1 = simplegui.create_timer(500, self.tetri_down)
self.time2 = simplegui.create_timer( 20, self.tetri_down)
self.time3 = simplegui.create_timer(120, self.pile_update)
self.timer = simplegui.create_timer(1000, self.count_down)
self.frame = simplegui.create_frame('Tetris', width, height)
开发者ID:mistert14,项目名称:mistert-skulpt,代码行数:15,代码来源:Tetris.py
示例2: __init__
def __init__(self,center_xy = (30,200),radius = 10 ,motion_vector=(1.0,0.5)):
self.xy = center_xy
self.radius = radius
self.radius_squared = radius * radius
self.color = "orange"
self.tics = 0
self.last_move_1_or_more = (0,0)
self.mv = motion_vector # px/s x , px/s y
self.timer_interval = 20.0
self.tic_freq = self.timer_interval / 1000.0
self.d_per_tic = (self.tic_freq * self.mv[0],self.tic_freq * self.mv[1])
if self.d_per_tic[0] == 0.0:
move_freq_x = 999999
else:
move_freq_x = abs(1.0 / self.d_per_tic[0])
if self.d_per_tic[1] == 0.0:
move_freq_y = 999999
else:
move_freq_y = abs(1.0 / self.d_per_tic[1])
self.move_freq = (move_freq_x,move_freq_y)
self.timer = simplegui.create_timer(int(self.timer_interval),self.tic)
self.timer.start()
self.last_hit = -1
self.walls = []
开发者ID:semisided1,项目名称:cousera-iip,代码行数:30,代码来源:user39_p5sfay9PXvgTHc2_11.py
示例3: rock_spawner
def rock_spawner():
global rock_group
if started:
if len(rock_group) < 12:
rock_pos = [random.randrange(0, WIDTH), random.randrange(0, HEIGHT)]
rock_vel = [random.random() * ROCK_VEL_FACTOR - ROCK_VEL_FACTOR / 2, random.random() * ROCK_VEL_FACTOR - ROCK_VEL_FACTOR / 2]
rock_avel = random.random() * ROCK_AVEL_FACTOR - ROCK_AVEL_FACTOR / 2
a_rock = Sprite(rock_pos, rock_vel, 0, rock_avel, asteroid_image, asteroid_info)
# add rock to group only if its not colliding with the ship
if not a_rock.collide(my_ship):
rock_group.add(a_rock)
# Main part
# Declare frame
frame = simplegui.create_frame("Asteroids", WIDTH, HEIGHT)
# initialize ship and two sprites
my_ship = Ship([WIDTH / 2, HEIGHT / 2], [0, 0], 0, ship_image, ship_info)
rock_group = set([])
explosions_group = set([])
missiles_group = set([])
# register handlers
frame.set_keyup_handler(keyup)
frame.set_keydown_handler(keydown)
frame.set_mouseclick_handler(click)
frame.set_draw_handler(draw)
timer = simplegui.create_timer(1000.0, rock_spawner)
# get things rolling
timer.start()
frame.start()
开发者ID:dkonst001,项目名称:Python-examples,代码行数:32,代码来源:new2.py
示例4: setup_frame
def setup_frame():
# initialize stuff
global timer, quiz, questions
quiz = Quiz(questions)
frame = simplegui.create_frame("QUIZ", WIDTH, HEIGHT)
timer = simplegui.create_timer(1000, timer_handler)
frame.set_canvas_background("Pink")
# register handlers
#frame.set_keyup_handler(keyup)
#frame.set_keydown_handler(keydown)
#frame.set_mouseclick_handler(click)
frame.set_draw_handler(draw)
frame.add_label("Game Controls")
frame.add_button("Restart", restart, 100)
frame.add_button("Next Question", nextQuestion, 100)
frame.add_button("Review Question", prev, 100)
# frame.add_button("Reset Question", resetQuestion, 100)
frame.add_label("Select Your Answer")
frame.add_button("A", selectA, 100)
frame.add_button("B", selectB, 100)
frame.add_button("C", selectC, 100)
frame.add_button("D", selectD, 100)
# get things rolling
init_game()
frame.start()
开发者ID:amits91,项目名称:quiz,代码行数:25,代码来源:Question.py
示例5: __init__
def __init__(self):
"""
Set elements of the game.
"""
self.loaded = False
self.keydown_left = False
self.keydown_right = False
self.lives = 3
self.my_ship = None
self.nb_bombs = None
self.score = 0
self.started = False
self.time = 0
self.explosions = []
self.live_explosions = []
self.missiles = []
self.rocks = []
self.animate_background_active = True
self.music_active = True
self.sounds_active = True
self.timer = simplegui.create_timer(1000, self.rock_spawner)
self.img_infos = None
self.medias = None
开发者ID:EthanSeaver,项目名称:Python-Projects,代码行数:27,代码来源:RiceRocks.py
示例6: __init__
def __init__(self,interval):
self.interval = interval
self.timer = simplegui.create_timer(interval, self.tic)
self.step = 1
self.tic_signal = Signal("tic")
SignalSender.__init__(self)
print('TimerManager __init__ done')
开发者ID:semisided1,项目名称:cousera-iip,代码行数:7,代码来源:user39_N4eqXbfsXpdvwOO_13.py
示例7: init
def init():
# initialize frame
global my_ship, a_missile, frame, timer, upgrade_number, upgrade_dist
frame = simplegui.create_frame("Asteroids, by dare7", WIDTH, HEIGHT)
upgrade_number = frame.add_button("+1 missile for %s$" % str(upgrade_cost), upgrade_count, 180)
upgrade_dist = frame.add_button("+1 missile range %s$" % str(upgrade_cost), upgrade_range, 180)
frame.add_button("Reset all", full_reset, 180)
frame.add_button("Quit", quit, 180)
# initialize ship and two sprites
my_ship = Ship([WIDTH / 2, HEIGHT / 2], [0, 0], 0, ship_image, ship_info)
#a_rock = Sprite([WIDTH / 3, HEIGHT / 3], [1, 1], 0, 0, asteroid_image, asteroid_info)
#a_missile = Sprite([2 * WIDTH / 3, 2 * HEIGHT / 3], [-1,1], 0, 0, missile_image, missile_info, missile_sound)
# register handlers
frame.set_draw_handler(draw)
frame.set_keydown_handler(key_down)
frame.set_keyup_handler(key_up)
frame.set_mouseclick_handler(click)
frame.add_label("Shoot stars!")
frame.add_label("Earn money!")
frame.add_label("Avoid collision!")
frame.add_label("Upgrade ship!")
frame.add_label("")
frame.add_label("Controls:")
frame.add_label("Up: accelerate")
frame.add_label("Left, right: turn")
frame.add_label("Space: shoot")
timer = simplegui.create_timer(1000.0, rock_spawner)
# get things rolling
timer.start()
frame.start()
开发者ID:dare7,项目名称:Coursera-An-Introduction-to-Interactive-Programming-in-Python,代码行数:32,代码来源:Rice_Rocks.py
示例8: gameWindow_init
def gameWindow_init():
global pong_frame, reset_timer
# Create Game Window
pong_frame = simplegui.create_frame("Pong", roomRect.getWidth(), roomRect.getHeight(), 300)
game_instructions = []
game_instructions.append(pong_frame.add_label("Welcome to Pong!"))
game_instructions.append(pong_frame.add_label(""))
game_instructions.append(pong_frame.add_label("Up and Down arrow keys control the Blue paddle"))
game_instructions.append(pong_frame.add_label(""))
game_instructions.append(pong_frame.add_label("W and S keys control the Red paddle"))
game_instructions.append(pong_frame.add_label(""))
game_instructions.append(pong_frame.add_label("Click anywhere in the game window to start"))
game_instructions.append(pong_frame.add_label(""))
game_instructions.append(pong_frame.add_label("May the force be with you."))
game_instructions.append(pong_frame.add_label(""))
# Game Window Buttons and Controls
# resetButton = pong_frame.add_button("New Game", new_game, 150)
pong_frame.add_button("Single Player (vs Computer)", singlePlayer, 250)
pong_frame.add_button("2 Player (Restart)", twoPlayer, 250)
# Timers
reset_timer = simplegui.create_timer(1000, reset_pause)
# Register event handlers
pong_frame.set_keydown_handler(keydown)
pong_frame.set_keyup_handler(keyup)
pong_frame.set_draw_handler(draw)
pong_frame.set_mouseclick_handler(mouseclick_startGame)
开发者ID:4karsh,项目名称:my_git_repos,代码行数:30,代码来源:Pong_optimized.py
示例9: __init__
def __init__(self, delay):
# sets the initial time to 0
self.time = 0
# sets the delay
self.delay = delay
# creates a timer
self.timer = simplegui.create_timer(delay, self.count)
开发者ID:vutran,项目名称:asteroids,代码行数:7,代码来源:game.py
示例10: reset_handler
def reset_handler():
global timer, t, attempts, score
timer.stop()
t = 0
attempts = 0
score = 0
timer = simplegui.create_timer(interval, timer_handler)
开发者ID:MaDickal,项目名称:Stopwatch,代码行数:7,代码来源:stopwatch.py
示例11: start
def start(self):
"""
Start calculation and drawing.
See `draw_fct()`.
"""
if self._timer is not None:
self.stop()
self._fps = 0
self._nb_frames_drawed = 0
self._nb_seconds = 0
try:
from simplegui import create_timer
except ImportError:
from SimpleGUICS2Pygame.simpleguics2pygame import create_timer
def update():
"""
Update counters.
"""
if self._timer is not None:
self._nb_seconds += 1
self._fps = int(round(float(self._nb_frames_drawed)
/ self._nb_seconds))
self._timer = create_timer(1000, update)
self._timer.start()
开发者ID:guohengkai,项目名称:hw-poc,代码行数:30,代码来源:simplegui_lib_fps.py
示例12: start
def start(self):
self.img_loader.start()
frame = simplegui.create_frame(
self.title,
self.width,
self.height
)
frame.set_draw_handler(self.draw_handler)
frame.set_mouseclick_handler(self.mouse_click_handler)
frame.set_canvas_background("#87CEEB")
frame.start()
self.init_balls()
self.init_clouds(2)
self.cloud_timer = simplegui.create_timer(
10 * 1000,
self.add_cloud)
self.cloud_timer.start()
frame.add_button("Clear sky", self.clear_clouds)
# frame.add_button("Add cloud", self.add_cloud)
self.rs_button = frame.add_button("Enable radius shrink", self.toggle_radius_shrink)
开发者ID:flc,项目名称:juggle-codeskulptor,代码行数:26,代码来源:juggle.py
示例13: click_dec
def click_dec():
global timer , interval
if timer.is_running():
timer.stop()
interval = interval+200
timer = simplegui.create_timer(interval, timer_handler)
timer.start()
开发者ID:nicetag,项目名称:omooc.py-2,代码行数:7,代码来源:iippy-2.py
示例14: deal
def deal():
global outcome, in_play, deck, dealer, player
global timer, status, dealed, score
if in_play:
in_play = False
dealed = True
status = LOOSE
timer = simplegui.create_timer(2000, timer_handler)
timer.start()
score -= 1
else:
in_play = True
dealed = False
# your code goes here
deck = Deck()
dealer = Hand()
player = Hand()
deck.shuffle()
i=0
while i<2:
player.add_card(deck.deal_card())
dealer.add_card(deck.deal_card())
i+=1
#print "Player " + str(player)
#print "Dealer " + str(dealer)
outcome = "Hit or Stand?"
开发者ID:AndyFoolish,项目名称:Python_Game,代码行数:31,代码来源:blackjack_game.py
示例15: timer_handler
def timer_handler():
global Count, timer
Count += 1
print Count
if Count == 10:
timer.stop()
timer = simplegui.create_timer(1000, timer_handler)
timer.start()
开发者ID:UtkarshPathrabe,项目名称:An-Introduction-to-Interactive-Programming-in-Python----Coursera,代码行数:8,代码来源:Quiz+3B+Code.py
示例16: click_acc
def click_acc():
global timer , interval
if timer.is_running():
timer.stop()
#防止变量变为0
interval = interval/2 + 1
timer = simplegui.create_timer(interval, timer_handler)
timer.start()
开发者ID:nicetag,项目名称:omooc.py-2,代码行数:8,代码来源:iippy-2.py
示例17: reset
def reset():
global t, curr_time, x, y, running
x = 0
y = 0
running = False
t.stop()
t = simplegui.create_timer(100, tick)
curr_time = 0
开发者ID:JasonGitHub,项目名称:Python,代码行数:8,代码来源:stop_watch.py
示例18: __init__
def __init__(self, images, finished_callback=None, check_interval=250):
self.images = images
self.images_len = len(images)
self.timer = simplegui.create_timer(check_interval, self._timer_handler)
self.finished_callback = finished_callback
self.total_count = len(images)
self.loaded_count = 0
self.progress = 0
开发者ID:flc,项目名称:juggle-codeskulptor,代码行数:9,代码来源:juggle.py
示例19: handle_timer
def handle_timer():
global gbl_timer
global gbl_timer_is_runing
bool( gbl_timer_is_runing )
if gbl_timer_is_runing == False:
if gbl_timer == None:
gbl_timer = simplegui.create_timer( gbl_timer_interval, handle_timer_event)
gbl_timer.start()
gbl_timer_is_runing = 1
开发者ID:otasowieosifo,项目名称:courserepo,代码行数:9,代码来源:stopwatch.py
示例20: auto_review
def auto_review():
global timer
#点击自动回放开关
if timer.is_running():
timer.stop()
else:
timer = simplegui.create_timer(interval,timer_handler)
timer.start()
pass
开发者ID:nicetag,项目名称:pythoncamp0-1,代码行数:9,代码来源:draw.py
注:本文中的simplegui.create_timer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论