Best Python code snippet using autotest_python
main.py
Source: main.py
...71 bullet[3] += world.delta_time72 pygame.draw.circle(surface, (0, 0, 0), Vector2D.vector2list(bullet[2]), 5)73 if bullet[3] >= 1:74 bullets.remove(bullet)75 world.add_object(black_hole(bullet[1], bullet[4]))76 pygame.display.update()77def level_menu(surface):78 lv1_button = menu_button(1920/2 - 228 - 228, 1080/2, 128, 128,pygame.image.load('assets\\sprites\\first.png'))79 lv2_button = menu_button(1920/2 - 228, 1080/2 , 128, 128,pygame.image.load('assets\\sprites\\second.png'))80 lv3_button = menu_button(1920/2, 1080/2, 128, 128,pygame.image.load('assets\\sprites\\third.png'))81 lv4_button = menu_button(1920/2 + 228, 1080/2, 128, 128,pygame.image.load('assets\\sprites\\fourth.png'))82 lv5_button = menu_button(1920/2 + 228 + 228, 1080/2, 128, 128,pygame.image.load('assets\\sprites\\fifth.png'))83 world = physics_world()84 run = True85 while run:86 surface.fill((51, 51, 51))87 lv1_button.render(surface)88 lv2_button.render(surface)89 lv3_button.render(surface)90 lv4_button.render(surface)91 lv5_button.render(surface)92 click = False93 for event in pygame.event.get():94 if event.type == pygame.QUIT:95 run = False96 if event.type == pygame.KEYDOWN:97 if event.key == pygame.K_ESCAPE:98 run = False99 if event.type == pygame.MOUSEBUTTONUP:100 if event.button == 1:101 click = True102 click_position = pygame.mouse.get_pos()103 if click:104 if lv1_button.is_clicked(click_position):105 world = physics_world()106 world.add_object(space_ship(Vector2D(200, 1080/2)))107 world.add_object(lava_planet(Vector2D(1920/2-200, 1080/2), 120))108 world.add_object(goal_planet(Vector2D(1920/2 + 500, 1080/2), 170))109 game(surface, world)110 elif lv2_button.is_clicked(click_position):111 world = physics_world()112 world.add_object(space_ship(Vector2D(200, 1080/2)))113 world.add_object(lava_planet(Vector2D(1920/2-200, 1080/2 + 460), 140))114 world.add_object(lava_planet(Vector2D(1920/2-200, 1080/2 - 460), 140))115 world.add_object(asteroid(Vector2D(1920/2, 1080/2 + 200), 120))116 world.add_object(asteroid(Vector2D(400, 1080/2 + 120), 80))117 world.add_object(asteroid(Vector2D(400 - 400, 1080/2 - 120), 80))118 world.add_object(asteroid(Vector2D(1920/2, 1080/2 - 200), 120))119 world.add_object(goal_planet(Vector2D(1920/2 + 500, 1080/2), 170))120 game(surface, world) 121 elif lv3_button.is_clicked(click_position):122 world = physics_world()123 world.add_object(space_ship(Vector2D(1920/2, 850)))124 world.add_object(lava_planet(Vector2D(1920/2, 1080/2 - 50), 140))125 world.add_object(lava_planet(Vector2D(200, 200), 140))126 world.add_object(asteroid(Vector2D(1500, 1080/2 - 200), 120))127 world.add_object(asteroid(Vector2D(1200, 1080/2 + 300), 80))128 world.add_object(asteroid(Vector2D(400, 400), 80))129 world.add_object(asteroid(Vector2D(1920/2 + 200, 1080/2 - 200), 120))130 world.add_object(goal_planet(Vector2D(1920/2, 1080/2 - 250), 170))131 game(surface, world)132 elif lv4_button.is_clicked(click_position):133 world = physics_world()134 world.add_object(space_ship(Vector2D(100, 100)))135 world.add_object(lava_planet(Vector2D(450, 1080/2), 140))136 world.add_object(lava_planet(Vector2D(940, 1080/2), 140))137 world.add_object(asteroid(Vector2D(1400, 1080/2 - 200), 120))138 world.add_object(asteroid(Vector2D(300, 1080/2 - 320), 120))139 world.add_object(asteroid(Vector2D(500, 60), 80))140 world.add_object(asteroid(Vector2D(1920/2 - 200, 300), 120))141 world.add_object(asteroid(Vector2D(1920/2 - 200, 1080 - 100), 120))142 world.add_object(goal_planet(Vector2D(1920/2 + 400,1080/2), 170))143 game(surface, world)144 elif lv5_button.is_clicked(click_position):145 world = physics_world()146 world.add_object(space_ship(Vector2D(100, 1080/2)))147 world.add_object(lava_planet(Vector2D(400, 300), 140))148 world.add_object(lava_planet(Vector2D(850, 1080/2 - 100), 140))149 world.add_object(lava_planet(Vector2D(1250, 1080 - 300), 140))150 world.add_object(asteroid(Vector2D(1300, 100), 120))151 world.add_object(asteroid(Vector2D(600, 1080/2 - 120), 80))152 world.add_object(asteroid(Vector2D(900, 900), 80))153 world.add_object(asteroid(Vector2D(100, 100), 120))154 world.add_object(goal_planet(Vector2D(1450, 300), 170))155 game(surface, world)156 pygame.display.update()157def main_menu(surface):158 start_button = menu_button(1920/2, 1080/2, 300, 100, pygame.image.load('assets\\sprites\\start_button.png'))159 controls_image = pygame.transform.scale(pygame.image.load('assets\\sprites\\controls.png'), (256, 256))160 game_name_image = pygame.transform.scale(pygame.image.load('assets\\sprites\\game_name.png'), (936, 65))161 controls_position = (1920/2 - 256/2, 1080/2+170)162 run = True163 while run:164 165 surface.fill((51, 51, 51))166 start_button.render(surface)167 surface.blit(controls_image, controls_position)168 surface.blit(game_name_image, (492, 200))...
add_util.py
Source: add_util.py
...129 '''Checks a MySQLdb.IntegrityError for whether the error is Duplicate130 Entry. Kludgy.'''131 return (isinstance(exception, MySQLdb.IntegrityError) and132 str(exception).find('Duplicate entry')!=-1)133def do_add_object(add_object, untranslated_args_dict, skip_old=False):134 '''Input ```args_dict``` must have been translated already.'''135 args_dict = translate_args_dict(add_object, untranslated_args_dict)136 check_required_arguments(add_object, args_dict)137 dbobject = add_object.DatabaseObject(**args_dict)138 print "Processing", dbobject, "..."139 # print "Commiting", dbobject, "with args:"140 # pprint.pprint(dbobject.__dict__)141 try:142 dbobject.commit()143 except MySQLdb.MySQLError, e:144 if skip_old and exception_is_duplicate_entry(e):145 print " Skipped existing", dbobject146 return147 else:...
aggregation.py
Source: aggregation.py
...18 :param num_agents: int:19 """20 object_loc_main = config["base"]["object_location"]21 if experiment == "stage2.0":22 self.objects.add_object(file = "experiments/flocking/images/redd.png", pos = object_loc_main, scale = [800, 800], obj_type = "obstacle")23 object_loc = config["first_circle"]["object_location"]24 self.objects.add_object(25 file="experiments/aggregation/images/greyc1.png", pos=object_loc, scale=[200, 200], obj_type="site"26 )27 object_loc = config["second_circle"]["object_location"]28 self.objects.add_object(29 file="experiments/aggregation/images/greyc1.png", pos=object_loc, scale=[200, 200], obj_type="site"30 )31 elif experiment == "stage1":32 self.objects.add_object(file="experiments/flocking/images/redd.png", pos=object_loc_main, scale=[800, 800],33 obj_type="obstacle")34 object_loc = config["center_circle"]["object_location"]35 self.objects.add_object(36 file="experiments/aggregation/images/greyc1.png", pos=object_loc, scale=[200, 200], obj_type="site"37 )38 elif experiment == "stage2.1":39 self.objects.add_object(file="experiments/flocking/images/redd.png", pos=object_loc_main, scale=[800, 800],40 obj_type="obstacle")41 object_loc = config["first_circle"]["object_location"]42 self.objects.add_object(43 file="experiments/aggregation/images/greyc1.png", pos=object_loc, scale=[200, 200], obj_type="site"44 )45 object_loc = config["second_circle"]["object_location"]46 self.objects.add_object(47 file="experiments/aggregation/images/greyc2.png", pos=object_loc, scale=[225, 225], obj_type="site"48 )49 elif experiment == "stage3":50 self.objects.add_object(file="experiments/flocking/images/redd.png", pos=object_loc_main, scale=[1000, 1000],51 obj_type="obstacle")52 object_loc = config["first_circle"]["object_location"]53 self.objects.add_object(54 file="experiments/aggregation/images/greyc1.png", pos=object_loc, scale=[200, 200], obj_type="site"55 )56 object_loc = config["second_circle"]["object_location"]57 self.objects.add_object(58 file="experiments/aggregation/images/greyc1.png", pos=object_loc, scale=[200, 200], obj_type="site"59 )60 object_loc = config["upper_circle"]["object_location"]61 self.objects.add_object(62 file="experiments/aggregation/images/greyc1.png", pos=object_loc, scale=[200, 200], obj_type="site"63 )64 object_loc = config["lower_circle"]["object_location"]65 self.objects.add_object(66 file="experiments/aggregation/images/greyc1.png", pos=object_loc, scale=[200, 200], obj_type="site"67 )68 elif experiment == "stage3.1":69 self.objects.add_object(file="experiments/flocking/images/redd.png", pos=object_loc_main, scale=[800, 800],70 obj_type="obstacle")71 object_loc = config["first_circle"]["object_location"]72 self.objects.add_object(73 file="experiments/aggregation/images/greyc1.png", pos=object_loc, scale=[200, 200], obj_type="site"74 )75 object_loc = config["second_circle"]["object_location"]76 self.objects.add_object(77 file="experiments/aggregation/images/greyc1.png", pos=object_loc, scale=[200, 200], obj_type="site"78 )79 object_loc = config["upper_circle"]["object_location"]80 self.objects.add_object(81 file="experiments/aggregation/images/greyc2.png", pos=object_loc, scale=[225, 225], obj_type="site"82 )83 object_loc = config["lower_circle"]["object_location"]84 self.objects.add_object(85 file="experiments/aggregation/images/greyc2.png", pos=object_loc, scale=[225, 225], obj_type="site")86 min_x, max_x = area(object_loc_main[0], 1000)87 min_y, max_y = area(object_loc_main[1], 1000)88 # add agents to the environment89 for index, agent in enumerate(range(num_agents)):90 coordinates = generate_coordinates(self.screen)91 while (92 coordinates[0] >= max_x93 or coordinates[0] <= min_x94 or coordinates[1] >= max_y95 or coordinates[1] <= min_y96 ):97 coordinates = generate_coordinates(self.screen)98 self.add_agent(Cockroach(pos=np.array(coordinates), v=None, cockroach=self, index=index))
Check out the latest blogs from LambdaTest on this topic:
Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools
As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????
The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!