Mini-project # 3 - "Stopwatch: The Game"
来源:互联网 发布:c语言五子棋课程设计 编辑:程序博客网 时间:2024/05/18 18:00
=========================第一版=========================
# template for "Stopwatch: The Game"import simplegui# define global variablestime = "0:00.0"number = "0/0"width = 300height = 200interval = 100count = 0m, n = 0, 0# define helper function format that converts timedef create_timer(): global count count = count + 1 global time time = format(count)# in tenths of seconds into formatted string A:BC.Ddef format(t): millisecond = t % 10 second = (t / 10) % 60 minute = (t / 600) if second < 10: time = str(minute) + ":" + "0" + str(second) + "." + str(millisecond) return time else: time = str(minute) + ":" + str(second) + "." + str(millisecond) return time # define event handlers for buttons; "Start", "Stop", "Reset"def start(): timer.start()def stop(): if not timer.is_running(): return timer.stop() global m m = m + 1 if count % 10 == 0: global n n = n + 1 global number number = str(n) + "/" + str(m)def restart(): timer.stop() global count, time, number, m, n count = 0 time = "0:00.0" number = "0/0" m, n = 0, 0# define event handler for timer with 0.1 sec interval# define draw handlerdef draw(canvas): canvas.draw_text(number, [250, 30], 30, "Green") canvas.draw_text(time, [80, 115], 50, "White") # create frameframe = simplegui.create_frame("Timer", width, height)# register event handlersframe.set_draw_handler(draw)frame.add_button("Start", start, 200)frame.add_button("Stop", stop, 200)frame.add_button("Restart", restart, 200)timer = simplegui.create_timer(interval, create_timer)# start frameframe.start()# Please remember to review the grading rubric
0 0
- Mini-project # 3 - "Stopwatch: The Game"
- Interactive Python:Mini-project # 3 - "Stopwatch: The Game"
- 莱斯大学Python课程Mini-project# 3 - "Stopwatch: The Game"
- mini project : stopwatch
- Mini-project # 2 - "Guess the number" game"
- Interactive Python:Mini-project # 1 - "Guess the number" game"
- 作业Week3 "Stopwatch: The Game"
- 莱斯大学Python课程Mini-project # 2 - "Guess the number" game
- IIPP迷你项目(三)“Stopwatch: The Game”
- Coursera_An Introduction to Interactive Programming in Python_Mini-project # 3 Stopwatch
- Beware of the stopwatch
- Mini-project # 4 - "Pong"
- Mini-project # 5 - Memory
- Mini-project #4 - "Pong"
- Mini-project # 6 - Blackjack
- Mini-project #4 - Pong
- Mini-project #5 - Memory
- Mini-project #6 - Blackjack
- PV操作—2014/10/8
- Firing up OpenAppID
- hdu3018 一笔画问题
- VMware在最近的2014年VMworld大会上宣布了其在推动云计算和开源方面的相关行动和规划
- MySQL JDBC的queryTimeout的一个坑
- Mini-project # 3 - "Stopwatch: The Game"
- HLJUOJ1125(暴力三点一线)
- Oracle 应用总结
- 简叙C++
- GDB和LLDB断点调试指令
- oracle mount及nomount
- 日语学习之沪江整理 20141008
- 软考复习——程序设计语言基础
- JAVA面试汇总