def show_list(self): if len(self.hosts['aliases']) == 0: print('Hosts list is empty.') return self.menu() cli = b.Bullet(prompt='Available hosts:', choices=self.hosts['aliases']) alias = cli.launch() CON_HOST = 'connect' DEL_HOST = 'delete host' BACK = 'back' host_cli = b.Bullet(prompt=f'Host {alias} options:', choices=[CON_HOST, DEL_HOST, BACK]) result = host_cli.launch() if result == CON_HOST: self.connect(alias) elif result == DEL_HOST: self.hosts['aliases'].remove(alias) del self.hosts['hosts'][alias] del self.hosts['users'][alias] self.update() return self.show_list() elif result == BACK: return self.menu()
def shoot(self, scroll, display, sound): if self.timer < 0: return self.mx, self.my = pygame.mouse.get_pos() self.mag_bullets -= 1 if (self.mx > display.get_width() / 2 + 180): self.flipped = False else: self.flipped = True if not self.flipped: blt = bullet.Bullet([self.pos[0] + 28, self.pos[1] + 12], 1, self.bullet_damage, self.bullet_speed, self.bullet_time, self.bullet_spread, self.mode) else: blt = bullet.Bullet([self.pos[0] + 5, self.pos[1] + 12], -1, self.bullet_damage, self.bullet_speed, self.bullet_time, self.bullet_spread, self.mode) self.timer = -self.firerate sound.play() if self.mag_bullets <= 0: self.timer -= self.firerate * self.reload_time self.mag_bullets = self.mag_size return blt
def shoot(self, key): if key == pg.K_SPACE: direction = 1 self.shot = bullet.Bullet(self.shootyThingRect.x, self.shootyThingRect.y, direction, "myBullet.png") if key == pg.K_RSHIFT: #elif doesn't work what? direction = -1 self.shot = bullet.Bullet(self.shootyThingRect.x, self.shootyThingRect.y, direction, "myBullet2.png") return self.shot
def shoot_double(self,bullet_image): if self.double_fire >= 0: x1 = self.x + self.w/4 x2 = self.x + self.w/4*3 y = self.y - bullet_image.height() bu1 = bullet.Bullet(x1,y,bullet_image) bu2 = bullet.Bullet(x2,y,bullet_image) self.double_fire -= 2 return bu1,bu2
def fire(self): #print(len(bullet.Bullet.bullets)) if (bullet.Bullet.BULLET_NUM < bullet.Bullet.BULLET_MAX): if self.flip == 'h': bullet1 = bullet.Bullet(self.pos[0] + 4, self.pos[1] - 4, -1) else: bullet1 = bullet.Bullet(self.pos[0] + 4, self.pos[1] - 4, 1) gfw.world.add(gfw.layer.bullet, bullet1) self.STATESMUSIC['Attack'].set_volume(Player.Volume) self.STATESMUSIC['Attack'].play() bullet.Bullet.BULLET_NUM += 1 Player.LASER_INTERVAL = 0.15
def shoot(self, my_bullet, photo_bullet): if self.vector == 1: bullet = bul.Bullet([self.rect.centerx, self.rect.centery + 30], self.vector, photo_bullet[0]) my_bullet.add(bullet) elif self.vector == 2: bullet = bul.Bullet([self.rect.centerx, self.rect.centery - 30], self.vector, photo_bullet[1]) my_bullet.add(bullet) elif self.vector == 3: bullet = bul.Bullet([self.rect.centerx + 30, self.rect.centery], self.vector, photo_bullet[2]) my_bullet.add(bullet) elif self.vector == 4: bullet = bul.Bullet([self.rect.centerx - 30, self.rect.centery], self.vector, photo_bullet[3]) my_bullet.add(bullet)
def shoot(self, bcount): if self.direction == 0: return bullet.Bullet(self.pebool, self.direction, self.x + 1, self.y + 0.5, bcount) elif self.direction == 1: return bullet.Bullet(self.pebool, self.direction, self.x + 0.5, self.y + 1, bcount) elif self.direction == 2: return bullet.Bullet(self.pebool, self.direction, self.x, self.y + 0.5, bcount) elif self.direction == 3: return bullet.Bullet(self.pebool, self.direction, self.x + 0.5, self.y, bcount)
def fire(self): cos = math.cos(math.pi / 2) sin = math.sin(math.pi / 2) left_bullet = bullet.Bullet(x=self.x - 15, y=self.y, batch=self.batch) right_bullet = bullet.Bullet(x=self.x + 15, y=self.y, batch=self.batch) left_bullet.vel.x = self.vel.x + cos * left_bullet.speed left_bullet.vel.y = self.vel.y + sin * left_bullet.speed right_bullet.vel.x = self.vel.x + cos * right_bullet.speed right_bullet.vel.y = self.vel.y + sin * right_bullet.speed self.children.append(left_bullet) self.children.append(right_bullet)
def state_siege(self, dt): super().state_siege(dt) if self.busters > 0 and isinstance(self.effective_target, planet.Planet): self.buster_time -= dt if self.buster_time <= 0: self.busters -= 1 self.buster_time = 0.5 ang = (self.effective_target.pos - self.pos).as_polar()[1] ang *= 3.14159 / 180 rvel = helper.from_angle(ang + 3.14159 + random.random() - 0.5) b = bullet.Bullet(self.pos, self.effective_target, self, vel=rvel, mods={ 'homing': 0.5, 'color': PICO_PINK, 'missile_speed': -0.65, 'life': 15, 'kill_pop': 1, 'shape': 'circle', 'size': 2, 'trail': PICO_PINK }) self.scene.game_group.add(b) self._generate_buster_display()
def shoot(self): if self.dead: return weapon_type_id = self.inventory.main_hand_item.item_type_id if self.inventory.ammo_nine_mm_count <= 0: return self.inventory.ammo_nine_mm_count -= 1 speed = 1 damage = 0 if weapon_type_id == 1001: speed = 15 damage = 55 elif weapon_type_id == 1002: speed = 15 damage = 20 # Maybe player died after coming into this method, then body_position will be None, check for this if not self.dead: bullet.Bullet(self.player_id, self.body.position[0], self.body.position[1], degrees(self.body.angle), speed, damage)
def shootOneBullet(self, angle): #Shoot a bullet spread = self.xs[BULLET_SPREAD_INDEX] r = (random.random() - 0.5) * 2 * spread dx = math.cos(angle + r) r = (random.random() - 0.5) * 2 * spread dy = math.sin(angle + r) size = self.xs[BULLET_SIZE_INDEX] speed = self.xs[BULLET_SPEED_INDEX] hp = self.xs[BULLET_HP_INDEX] #penetration timeout = self.xs[BULLET_LONGEVITY_INDEX] damage = self.xs[BULLET_DAMAGE_INDEX] if self.use_seeking: b = bullet_seeking.BulletSeeking(self.screen, self.x, self.y, red, size, dx * speed, dy * speed, hp, damage, timeout, self) else: b = bullet.Bullet(self.screen, self.x, self.y, red, size, dx * speed, dy * speed, hp, damage, timeout, self) global all_sprites funcs.insertInOrder(b, all_sprites) #Recoil self.dx -= dx * self.xs[RECOIL_INDEX] self.dy -= dy * self.xs[RECOIL_INDEX]
def update(self, origin, target, timePassed): self.timePassed += timePassed bulletlist = [] if self.timePassed % 250 != self.timePassed: posx = origin.rect.centerx posy = origin.rect.centery posx += self.vet.x posy += self.vet.y for i in range(0, 24): posx = origin.rect.centerx posy = origin.rect.centery posx += self.vet.x posy += self.vet.y r = Rect(posx, posy, self.surf1.get_width(), self.surf1.get_height()) r.center = (posx, posy) bulletlist.append( bullet.Bullet( r, self.surf1, movement.Line(Vector2(self.vet.x, self.vet.y), 0.6, 4, 6), self.mask1)) self.vet.rotate_ip(15) self.timePassed = 0 return bulletlist
def setUp(self): initial_x = 11 initial_y = 22 initial_dx = 11 initial_dy = 22 self.expected_rotation = 45 self.expected_radius = 3 self.expected_world_width = 600 self.expected_world_height = 800 self.expected_color = (255, 255, 255) self.expected_age = 0 self.expected_dx = initial_dx + 100. * math.cos( math.radians(self.expected_rotation)) self.expected_dy = initial_dy + 100. * math.sin( math.radians(self.expected_rotation)) self.expected_x = initial_x + 0.1 * self.expected_dx self.expected_y = initial_y + 0.1 * self.expected_dy self.constructed_obj = bullet.Bullet(initial_x, initial_y, initial_dx, initial_dy, self.expected_rotation, self.expected_world_width, self.expected_world_height) return
def update(self, planet, dt): if not self.indicator: self.indicator = RangeIndicator(planet.pos, planet.DEFENSE_RANGE + planet.get_radius(), PICO_PINK, line_length=2, line_space=5) planet.scene.game_group.add(self.indicator) planet.selected_graphics.append(self.indicator) self.fire_time += dt threats = planet.get_threats() if self.fire_time > self.FIRE_RATE and threats: t = random.choice(threats) delta = t.pos - planet.pos _, angle = delta.as_polar() angle *= 3.14159 / 180 angle += random.random() * 1.5 - 0.75 self.fire_time = 0 b = bullet.Bullet(planet.pos + helper.from_angle(angle) * planet.get_radius(), t, planet, vel=helper.from_angle(angle) * 20, mods={ 'homing': 1, "damage_base": 10 * planet.planet_weapon_mul, "blast_radius": 10, "color": PICO_WHITE, "life": 5, "missile_speed": 0.5 }) planet.scene.game_group.add(b)
def setup_telegram_bot_commands_list(data): prompt_yes = _("Yes, please update.") prompt_no = _("No, I want to keep the old commands list.") choices = bullet.Bullet(prompt=_("Do you want to update the list of commands of your bot?"), choices=[prompt_yes, prompt_no]) answer = choices.launch() if answer == prompt_yes: print(_("Updating commands list..."), end="", flush=True) Bot(data.data['token'], request=data.request).set_my_commands( [ ("help", _("Show commands list.")), ("link", _("Link a remote chat to a group.")), ("unlink_all", _("Unlink all remote chats from a group.")), ("info", _("Display information of the current Telegram chat.")), ("chat", _("Generate a chat head.")), ("extra", _("Access additional features from Slave Channels.")), ("update_info", _("Update info of linked Telegram group.")), ("react", _("Send a reaction to a message, or show a list of reactors.")), ("rm", _("Remove a message from its remote chat.")), ] ) print(_("OK")) print() input(_("Press ENTER/RETURN to continue..."))
def get_bullet(self, pos, vel, speed, color): if self.bullet_cache: b = self.bullet_cache.pop() else: b = bullet.Bullet(self.app) b.spawn(pos, vel, speed, color) return b
def setup_telegram_bot(data): print_wrapped(_( "1. Set up your Telegram Bot\n" "---------------------------\n" "ETM requires you to have a Telegram bot ready with you to start with." )) print() if data.data['token']: # Config has token ready. # Assuming user doesn't need help creating one data.data['token'] = input_bot_token(data, data.data['token']) else: # No config is ready. # prompt to guide user to create one. prompt_yes = _("Yes, please tell me how to make one.") prompt_no = _("No, I have already made one according to the docs.") choices = bullet.Bullet(prompt=_("Do you need help creating a bot?"), choices=[prompt_no, prompt_yes]) answer = choices.launch() if answer == prompt_yes: print_wrapped(_( "Follow this guide to create your first ETM Telegram Bot.\n" "\n" ">>> Step 1: Search @BotFather on Telegram, or follow the " "link below. You should be able to see a bot named " "“BotFather”." )) print(" https://t.me/BotFather") print() input(_("Press ENTER/RETURN to continue...")) print() print_wrapped(_( ">>> Step 2: Send /newbot to BotFather to create a new bot. " "Follow its prompts to give it a name and a username. " "Note that its username must end with “bot”.\n" "\n" "After setting its username, you should receive a long line " "of code called “token”. Keep it with you securely, we will " "need that later on." )) print() input(_("Press ENTER/RETURN to continue...")) print() print_wrapped(_( ">>> Step 3: Get the bot ready for ETM.\n" "Send /setjoingroups to BotFather, choose the bot you " "just created, then choose “Enable”. This will allow your bot " "to join groups.\n" "\n" "Send /setprivacy to BotFather, choose the bot you just " "created, then choose “Disable”. This will allow your bot to " "process all messages in groups it joined, not just commands." )) print() input(_("Press ENTER/RETURN to continue...")) print() data.data['token'] = input_bot_token(data)
def update(self, room): if not self.angles: self.update_angles(room) self.animate() for b in self.bullets: b.update(room) if not b.alive and not b.particles: self.bullets.remove(b) if self.timer == 0: dx = (8, 1, -6, 1) dy = (1, 8, 1, -6) for i in self.angles: angle = i * 90 x = self.x + dx[i] * helpers.SCALE y = self.y + dy[i] * helpers.SCALE b = bullet.Bullet(self, x, y, 1 * helpers.SCALE, angle) b.group = gameobject.CollisionGroup.ebullets self.bullets.append(b) self.timer = self.cooldown self.sounds.add('shoot') else: self.timer -= 1
def shoot(self, win, playerx, playery, cameraposx, cameraposy, level, tilewidth, tileheight): mousepos = pygame.mouse.get_pos() mouseclick = pygame.mouse.get_pressed() if (mouseclick[0] and self.cocktimer >= self.cocktime and self.ammo > 0): for i in range(self.bshot): self.bullets.append( bullet.Bullet(self.speed, playerx, playery, mousepos[0], mousepos[1], tilewidth, tileheight, cameraposx, cameraposy, level, self.spread)) self.cocktimer = 0 self.reload = False self.reloadtimer = 0 self.ammo = self.ammo - 1 self.cocktimer = self.cocktimer + 1 keys = pygame.key.get_pressed() if (self.ammo == 0 or keys[pygame.K_r]): self.reload = True if (self.ammo >= self.maxammo): self.reload = False self.reloadtimer = 0 if (self.reload): self.reloadtimer = self.reloadtimer + 1 if (self.reloadtimer == self.reloadtime): self.ammo = self.ammo + 1 self.reloadtimer = 0
def fire(self): (x, y) = self.rotateAndTranslatePoint(self.mOriginalPolygon[0][0], self.mOriginalPolygon[0][1]) return bullet.Bullet(x, y, float(self.getDX()), float(self.getDY()), float(self.getRotation()), float(self.getWorldWidth()), float(self.getWorldHeight()))
def update(self, planet, dt): # Regenerate planet.health += 0.5 * dt # Fire at threats self.fire_time += dt threats = self.get_threats(planet) if self.fire_time > self.FIRE_RATE and threats: self.fire_time = 0 threat = random.choice(threats) _, angle = (threat.pos - planet.pos).as_polar() angle *= 3.14159 / 180 angle += random.random() * 0.5 - 0.25 b = bullet.Bullet( planet.pos + helper.from_angle(angle) * planet.get_radius(), threat, planet, vel=helper.from_angle(angle) * 20, mods={ 'homing': 1, 'color': PICO_YELLOW, 'damage_base': 3, 'missile_speed': -0.25, 'life': 5 }, ) planet.scene.game_group.add(b)
def get_spreadsheet(sheet_name=None): gc = pygsheets.authorize() try: sh = gc.open(sheet_name) except pygsheets.SpreadsheetNotFound: if sheet_name: query = f'name contains "{sheet_name.split()[0].lower()}"' else: query = "" spreadsheets = gc.spreadsheet_titles(query=query) while not spreadsheets: if bullet.YesNo( prompt= "Could not find spreadsheet. Do you want to create one?"): return gc.create(sheet_name) prompt = bullet.Input( prompt="Here are the sheets we found: Enter your query: ") query = prompt.launch() spreadsheets = gc.spreadsheet_titles( query=f'name contains "{query.lower()}"') prompt = bullet.Bullet(choices=spreadsheets, prompt="Spreadsheet Names (Closest Match):") sheet_name = prompt.launch() sh = gc.open(sheet_name) return sh
def prompt_module(nodes, prompt, modtype='LoRa', cliname=None): """ Prompts the user to select a module of a specific type :param nodes: The nodes list of TPyControl :param prompt: The request that will be shown to the user :param modtype: Type of the module, defaults to 'LoRa' :param cliname: If set, checks sys.argv for a "[cliname]=node.module" parameter and if a matching node exists, shows no prompt. """ if cliname is not None: for arg in sys.argv: if arg.startswith(cliname + "="): argval = arg[len(cliname) + 1:] if "." in argval: (node, module) = argval.split(".", 1) if node in nodes and module in nodes[ node].modules and nodes[node].modules[ module] == modtype: return nodes[node][module] modules = mod_list(nodes, modtype) cli = bullet.Bullet(prompt=prompt, choices=[mod_to_str(*m) for m in modules], **bulletstyle) return str_to_mod(nodes, cli.launch())
def experiment(pattern, visual=False, player_controlled=False): #Create the player p = player.Player(screen, 100, 200) p.attack_pattern = pattern #Create bullet list bullets = [] #create the target target = bullet.Bullet(screen, screen_width/2, screen_height/2, 0) points = 0 #Main loop timelimit = 20*fps for _ in range(timelimit): #Handle any events, possibly closing the game. handleEvents() #Send user input to the player if player_controlled: userInputToPlayer(p) else: p.update(target,bullets) #Lose points for colliding with target if p.collidedCircular(target): points -= 5 p.moveBallistic() points += updateBullets(bullets, target) if visual: #Draw on the screen drawAndDelay(p, bullets, target) return points
def command(self) -> None: """Uninstall a plugin.""" installed_plugins = { name: attrs for name, attrs in disthelpers.get_installed_plugins().items() if not attrs.get("builtin") } if self.plugin_name: # non-interactive uninstall if self.plugin_name not in installed_plugins: raise plug.PlugError( f"no plugin '{self.plugin_name}' installed" ) selected_plugin_name = self.plugin_name else: # interactive uninstall if not installed_plugins: plug.echo("No plugins installed") return plug.echo("Installed plugins:") _list_installed_plugins( installed_plugins, disthelpers.get_active_plugins() ) selected_plugin_name = bullet.Bullet( prompt="Select a plugin to uninstall:", choices=list(installed_plugins.keys()), ).launch() _uninstall_plugin(selected_plugin_name, installed_plugins)
def _select_plugin(plugins: dict) -> Tuple[str, str]: """Interactively select a plugin.""" selected_plugin_name = bullet.Bullet( prompt="Select a plugin to install:", choices=list(plugins.keys()) ).launch() selected_plugin_attrs = plugins[selected_plugin_name] _list_plugin(selected_plugin_name, plugins) selected_version = bullet.Bullet( prompt="Select a version to install:", choices=list(selected_plugin_attrs["versions"].keys()), ).launch() return selected_plugin_name, selected_version
def shoot(self): """ Performs all creation and procedures needed to shoot a bullet """ prev_ticks = self.bullet_cur_ticks self.bullet_cur_ticks = pygame.time.get_ticks() ticks = self.bullet_cur_ticks - prev_ticks self.bullet_elapsed += ticks if self.bullet_elapsed > self.bullet_delay: fired = False player_loc = self.player.get_loc() player_size = self.player.get_size() player_mid_right = ((player_loc[0] + player_size[0]), (player_loc[1] + (player_size[1] / 2))) for bul in self.bullets: if not bul.is_on_screen(): b_size = bul.get_size() b_loc = ((player_mid_right[0] - (b_size[0] / 2)), (player_mid_right[1] - (b_size[1] / 2))) bul.shoot(b_loc) fired = True break if not fired: bul = bullet.Bullet() b_size = bul.get_size() b_loc = ((player_mid_right[0]), (player_mid_right[1] - (b_size[1] / 2))) bul.shoot(b_loc) self.bullets.append(bul) self.bullet_elapsed = self.bullet_elapsed % self.bullet_delay
def ShootBullet(settings, shooter, bullets): # Requirement ID: 2.0.4 """Shoot ordinary bullets.""" settings.bullet_size = 7 settings.bullet_color = settings.black new_bullet = Bul.Bullet(settings, shooter) bullets.add(new_bullet)
def launch_bullet(self, bullet_img, position, speed): bullet_obj = bullet.Bullet(bullet_img, position, speed, self.bgsize) self.our_bullets.append(bullet_obj) for each in self.our_bullets: if each.move(): self.screen.blit(each.image, (each.rect[0], each.rect[1])) else: self.our_bullets.remove(each)
def shoot(self, tab): x = random.randint(0, 100) if x > 25 and x < 29 and not self.is_dead: tab.append( blt.Bullet((self.rect.x + 32, self.rect.y + 62), 1, self.bullet_power)) return True return False