def create_suite(argv): """ creates a gantlet.scoreboard initialized by the argument list returns a (scoreboard, remaining_args) tuple """ shortopts = "qgs:hi:c:a:ev:f:dx:m:p:k:" longopts = [ "quiet", "gui", "srcdir=", "help", "histfile=", "config=", "args=", "allow_exitstatus_only", "verbose=", "testfile=", "nowarn_deprecated", "xmlout=", "email=", "profile=", "package=" ] (opts, args) = getopt.getopt(argv, shortopts, longopts) if len(args) > 0: s = scoreboard(args[0]) else: s = scoreboard('empty') for (o, v) in opts: if o in ("-h", "--help"): print(help_string) sys.exit(0) elif o in ("-q", "--quiet"): s.config.quiet = 1 elif o in ("-g", "--gui"): s.config.gui = 1 elif o in ("-s", "--srcdir"): s.config.srcdir = v elif o in ("-i", "--histfile"): s.config.histfile = v elif o in ("-c", "--config"): s.config.name = v elif o in ("-a", "--args"): s.config.verbatim_args = v elif o in ("-e", "--allow_exitstatus_only"): s.config.allow_exit_status_only = 1 elif o in ("-v", "--verbose"): s.config.verbose = int(v) elif o in ("-f", "--testfile"): if v == '-': file = stdin else: file = open(v, 'r') args = args + gettests(file) elif o in ("-d", "--nowarn_deprecated"): s.config.warn_deprecated = 0 elif o in ("-x", "--xmlout"): s.config.xmlout = v elif o in ("-m", "--email"): s.config.email = v elif o in ("-p", "--profile"): s.profile = v elif o in ("-k", "--package"): s.package = v return s, args[1:]
def main_menu_enter(window, event, menu): """A főmenüben kezeli az enter gomb megyomását.""" if event.key == pygame.K_RETURN: if menu == 1: tetris.tetris(window) if menu == 2: scoreboard.scoreboard(window) if menu == 3: options.options(window) if menu == 4: pygame.quit()
def create_suite( argv ): """ creates a gantlet.scoreboard initialized by the argument list returns a (scoreboard, remaining_args) tuple """ shortopts = "qgs:hi:c:ev:f:dx:m:p:k:" longopts = ["quiet", "gui", "srcdir=", "help", "histfile=", "config=", "allow_exitstatus_only", "verbose=", "testfile=", "nowarn_deprecated","xmlout=", "email=","profile=","package="]; (opts, args) = getopt.getopt( argv, shortopts, longopts ) if len( args ) > 0: s = scoreboard(args[0]) else: s = scoreboard('empty') for (o, v) in opts: if o in ("-h","--help"): print help_string sys.exit(0) elif o in ("-q", "--quiet"): s.config.quiet = 1 elif o in ("-g", "--gui"): s.config.gui = 1 elif o in ("-s", "--srcdir"): s.config.srcdir = v elif o in ("-i", "--histfile"): s.config.histfile = v elif o in ("-c", "--config"): s.config.name = v elif o in ("-e", "--allow_exitstatus_only"): s.config.allow_exit_status_only = 1 elif o in ("-v", "--verbose"): s.config.verbose = int(v) elif o in ("-f", "--testfile"): if v == '-': file = stdin else: file = open(v,'r') args = args + gettests( file ) elif o in ("-d", "--nowarn_deprecated"): s.config.warn_deprecated = 0 elif o in ("-x", "--xmlout"): s.config.xmlout = v elif o in ("-m", "--email"): s.config.email = v elif o in ("-p", "--profile"): s.profile = v elif o in ("-k", "--package"): s.package = v return s, args[1:]
def __init__(self, window_x=800, window_y=600, batch=False, pipe_frequency=100, pipe_width=60, pipe_gap=150, pipe_velocity=6, debug=False): self.window_x = window_x self.window_y = window_y self.batch = batch self.debug = debug self.last_pipe = 0 self.pipes = [] self.pipe_frequency = pipe_frequency self.pipe_width = pipe_width self.pipe_gap = pipe_gap self.pipe_velocity = pipe_velocity self.bird = bird(25, window_x / 2, window_y, batch) if not batch == False: self.scoreboard = scoreboard(0, window_y - 20, batch) if debug: self.debugboard = debugboard(window_y - 200, window_x - 20, batch)
def load_instructions(self): instructions=self.read_instructions() if instructions: self.t1, self.t2, self.t3 = scoreboard(instructions) self.ui.table1.setRowCount(len(instructions)) header_row=[(','.join(i[0:4]))for i in instructions] self.ui.table1.setVerticalHeaderLabels(header_row) QtWidgets.QMessageBox.information(self, '提示', '代码加载成功', QtWidgets.QMessageBox.Yes)
def load_instructions_fromtxt(self): instructions = [] # 初始化这个实例,设置一些基本属性 dlg = QtWidgets.QFileDialog(directory='./',filter="*.txt") dlg.setFileMode(QtWidgets.QFileDialog.AnyFile) dlg.setFilter(QtCore.QDir.Files) # 当选择器关闭的时候 if dlg.exec_(): # 拿到所选择的的文本 filenames = dlg.selectedFiles() # 读取文本内容设置到TextEdit当中来 # print(filenames)#可以选择多个文件,返回的是一个list f = open(filenames[0], 'r') with f: x=f.readlines() # print(x) # .strip('\n').split('\n') for i in x: i = i.strip() if i: i_list = i.split(',') if len(i_list) == 4: i_list.append(2) i_list.append(0) instructions.append(i_list) elif len(i_list) == 5: i_list[4] = int(i_list[4]) i_list.append(0) instructions.append(i_list) else: instructions=[] break if instructions: self.t1, self.t2, self.t3 = scoreboard(instructions) self.ui.table1.setRowCount(len(instructions)) header_row=[(','.join(i[0:4]))for i in instructions] self.ui.table1.setVerticalHeaderLabels(header_row) QtWidgets.QMessageBox.information(self, '提示', '代码加载成功', QtWidgets.QMessageBox.Yes) else: QtWidgets.QMessageBox.warning(self, "警告", "指令读入错误或者文件中没有代码,请重新加载", QtWidgets.QMessageBox.Yes)
def rungame(): p.init() ai_Settings=Settings() screen=p.display.set_mode((ai_Settings.screen_width,ai_Settings.screen_heigth)) ship=Ship(screen,ai_Settings) p.display.set_caption("Alien Invasion") play_button=button(ai_Settings,screen,"play") lose_button=button(ai_Settings,screen,"Gamal AbdelNaser") bullets=Group() aliens=Group() state=Game_Sate(ai_Settings) sb=scoreboard(screen,state,ai_Settings) gf.fleet_of_aliens(ai_Settings,screen,aliens,ship) while True: gf.check_event(state,play_button,ship,aliens,ai_Settings,screen,bullets,lose_button,sb) gf.update_screen(ai_Settings,screen,ship,bullets,aliens,state,play_button,lose_button,sb) if state.game_active: ship.update() bullets.update() gf.update_aliens(aliens,ai_Settings,ship,screen,bullets,state,sb) gf.update_bullets(bullets,aliens,ai_Settings,screen,ship,sb,state)
def run_game(): # Initialize game and create a screen object. pygame.init() ai_Setting = Settings() screen = pygame.display.set_mode((ai_Setting.screen_width, ai_Setting.screen_height)) pygame.display.set_caption("Alien Invasion mofo") stats = GameStats(ai_Setting) sb = scoreboard(ai_Setting,screen,stats) alien = Alien(ai_Setting,screen) bg_music = ai_Setting.bg_music bg_music.set_volume(0.4) bg_music.play(-1) # make a ship ship = Ship(ai_Setting,screen) play_button =Button(ai_Setting,screen,"play") screen.blit(ai_Setting.bg,[0,0]) bullets = Group() aliens = Group() # Start the main loop for the game. gf.create_fleet(ai_Setting, screen, ship, aliens) # create the fleet of aliens while True: gf.check_events(ai_Setting,screen,stats,sb,play_button,ship,aliens,bullets) # Watch for keyboard and mouse events. if stats.game_active: screen.blit(ai_Setting.bg,[0,0]) ship.update() gf.update_bullets(ai_Setting,screen,stats,sb,ship,aliens,bullets) gf.update_aliens(ai_Setting,stats,screen,sb,ship,aliens,bullets) gf.update_screen(ai_Setting,screen,stats,sb,ship,aliens,bullets,play_button) # Make the most recently drawn screen visible. pygame.display.flip()
def __init__(self): pygame.init() self.settings = settings() self.screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN) self.settings.screen_width = self.screen.get_rect().width self.settings.screen_height = self.screen.get_rect().height pygame.display.set_caption("Alien Invasion") self.spaceship = Spaceship(self) self.game_screen = gamescreen(self) self.bullets = pygame.sprite.Group() self.aliens = pygame.sprite.Group() self.music = Music_button(self) self.create_fleet() self.settings.increase_speed() self.stats = gamestats(self) self.scoreboard = scoreboard(self) self.play_button = button(self, "play") self.clock = pygame.time.Clock() self.game_music = pygame.mixer.music.load('sounds/theme_song.mp3') pygame.mixer.music.play(-1) self.bullet_sound = pygame.mixer.Sound( "sounds/GunShooting() (online-audio-converter.com).wav") self.alien_destroying = pygame.mixer.Sound('sounds/Explosion.wav')
last_pipe = 0 pipes = [] # Create window with resolution of 800 x 600 window = pyglet.window.Window(800, 600, 'flappy bird') if DEBUG: fps_display = pyglet.window.FPSDisplay(window=window) # Create the main drawing batch for vertices main_batch = pyglet.graphics.Batch() # create the player / agent at center of screen agent = bird(25 ,window.height / 2, window.height, main_batch) # create scoreboard scoreboard = scoreboard(0, window.height - 20, main_batch) # define game over reset def game_over(): global last_pipe global pipes for p in pipes: p.delete() pipes = [] last_pipe = 0 agent.game_over() # logic to run every 1 / 120 seconds
def run(self): print "scoreboard starting..." scoreboard.scoreboard(9990)
def main(): if __name__ == "__main__": team1_name = input("Enter name of team 1: ") team2_name = input("Enter name of team 2: ") team1 = sb.scoreboard(team1_name) team2 = sb.scoreboard(team2_name) #Set to random points team1.set_sets(0) team1.set_points(0) team2.set_sets(0) team2.set_points(0) # Instructions print("Press a to add a point to team 1") print("Press s to add a point to team 2") print("Press d to add a set to team 1") print("Press f to add a set to team 2") print("\n") # Text Option 1 '''text = "{}: Sets: {} Points: {} \n {}: Sets: {} Points: {}".format( team1.get_teamname(), team1.get_sets(), team1.get_points(), team2.get_teamname(), team2.get_sets(), team2.get_points())''' # Text Option 2 print("Game is: \n") text = "{} vs. {} \n Sets: {} - {} \n Points: {} - {}".format( team1.get_teamname(), team2.get_teamname(), team1.get_sets(), team2.get_sets(), team1.get_points(), team2.get_points()) output.boxPrint(text, 40) # Start of scoreboard runner add_points = input( "Press c to cancel. Otherwise press any key to continue. ") while (add_points != 'c'): #team1.init_graph() add_points = input("") # 'a' to add points to team 1 if (add_points == 'a'): team1.add_points() text = "{} vs. {} \n Sets: {} - {} \n Points: {} - {}".format( team1.get_teamname(), team2.get_teamname(), team1.get_sets(), team2.get_sets(), team1.get_points(), team2.get_points()) output.boxPrint(text, 40) # 's' to add points to team 2 elif (add_points == 's'): team2.add_points() text = "{} vs. {} \n Sets: {} - {} \n Points: {} - {}".format( team1.get_teamname(), team2.get_teamname(), team1.get_sets(), team2.get_sets(), team1.get_points(), team2.get_points()) output.boxPrint(text, 40) # 'd' to add sets to team 1 elif (add_points == 'd'): team1.add_sets() text = "{} vs. {} \n Sets: {} - {} \n Points: {} - {}".format( team1.get_teamname(), team2.get_teamname(), team1.get_sets(), team2.get_sets(), team1.get_points(), team2.get_points()) output.boxPrint(text, 40) # 'f' to add sets to team 2 elif (add_points == 'f'): team2.add_sets() text = "{} vs. {} \n Sets: {} - {} \n Points: {} - {}".format( team1.get_teamname(), team2.get_teamname(), team1.get_sets(), team2.get_sets(), team1.get_points(), team2.get_points()) output.boxPrint(text, 40) # 'r' to reset all points elif (add_points == 'r'): team1.reset_all() team2.reset_all() text = "{} vs. {} \n Sets: {} - {} \n Points: {} - {}".format( team1.get_teamname(), team2.get_teamname(), team1.get_sets(), team2.get_sets(), team1.get_points(), team2.get_points()) output.boxPrint(text, 40) print("Program cancelled.") print("Passed Test")
def test_scoreboard(): assert scoreboard("The score is four nil") == [4, 0] assert scoreboard("new score: two three") == [2, 3] assert scoreboard("two two") == [2, 2] assert scoreboard("Arsenal just conceded another goal, two nil") == [2, 0]
screen.tracer(0) screen.update() screen.title("Pong Game") pong1 = Pong((-350, 0)) pong2 = Pong((350, 0)) ball = Ball() screen.listen() screen.onkey(key="w", fun=pong1.go_up) screen.onkey(key="s", fun=pong1.go_down) screen.onkey(key="Up", fun=pong2.go_up) screen.onkey(key="Down", fun=pong2.go_down) game_is_on = True scoreboard1 = scoreboard(1, (-350, 260)) scoreboard2 = scoreboard(2, (50, 260)) drawline = scoreboard(0, (0, 300)) drawline.draw_line() while game_is_on: screen.update() time.sleep(0.1) ball.going() if ball.ycor() >= 280 or ball.ycor() <= -280: ball.bounce() elif ball.xcor() <= -380: ball.home() scoreboard2.update()