def create_fuels(self): # update fuel list self.fuels = [x for x in self.fuels if x.is_active()] # remove props that are dead or out of screen for f in self.fuels: if not f.is_active(): del f if (self.travel_distance - self.last_fuel_spawn) > self.fuel_randomizer: self.last_fuel_spawn = self.travel_distance self.fuel_randomizer = random.randint( self.fuel_spawn_distance * 0.6, self.fuel_spawn_distance * 1.5) # get the wall coordinate at y=0 for spawning wall_1 = self.walls.return_wall_coordinate(0) # get the wall coordinate at the bottom of CG for spawning wall_2 = self.walls.return_wall_coordinate(self.cg['fuel'][1] * 2.5) # select the correct wall size if wall_1[0] >= wall_2[0]: wall = wall_1 pos_h = random.randint( wall[0], wall[1] - self.cg['fuel'][0] ) #wall[0] # or wall[1]-self.cg['fuel'][0] fuel = Enemy(scr=self.screen, name='fuel', ent_type='fuel', cg=self.cg['fuel'], pos=[pos_h, 0], icon_list=['media/covid/icon/fuel.png'], v_speed=self.settings['player_speed'], h_speed=0) self.fuels.append(fuel) fuel.set_walls(wall)
def create_people(self): # update enemy list self.peoples = [x for x in self.peoples if x.is_active()] # remove peoples that are dead or out of screen for e in self.peoples: if not e.is_active(): del e if (self.travel_distance - self.last_people_spawn) > self.randomizer: self.last_people_spawn = self.travel_distance self.randomizer = random.randint(self.people_spawn_distance * 0.5, self.people_spawn_distance * 0.8) people_name = random.choice(self.people_names) # get the wall coordinate at y=0 for spawning wall_1 = self.walls.return_wall_coordinate(0) # get the wall coordinate at the bottom of CG for spawning wall_2 = self.walls.return_wall_coordinate(self.cg['human'][1] * 3) # select the correct wall size if wall_1[0] >= wall_2[0]: wall = wall_1 pos_h = random.randint(wall[0], wall[1] - self.cg['human'][0]) vel_h = random.randint(0, 1) people = Enemy( scr=self.screen, name=people_name, ent_type='people', cg=self.cg['human'], pos=[pos_h, 0], icon_list=['media/covid/icon/{}.png'.format(people_name)], v_speed=self.settings['player_speed'] * 1.5, h_speed=self.settings['enemy_speed'] * vel_h * 0) self.peoples.append(people) people.set_walls(wall)
def create_cars(self): self.cars = [x for x in self.cars if x.is_active()] # remove cars that are dead or out of screen for p in self.cars: if not p.is_active(): del p if (self.travel_distance - self.last_car_spawn) > 300: self.last_car_spawn = self.travel_distance car_name = random.choice(self.car_names) # get the wall coordinate at y=0 for spawning wall = self.walls.return_wall_coordinate(0) car = Enemy(scr=self.screen, name=car_name, ent_type='car', cg=self.cg['car'], pos=[670, 0], icon_list=['media/covid/icon/{}.png'.format(car_name)], v_speed=self.settings['player_speed'], h_speed=0) self.cars.append(car) car.set_walls(wall)
def create_trees(self): # update trees list self.trees = [x for x in self.trees if x.is_active()] # remove trees that are dead or out of screen for p in self.trees: if not p.is_active(): del p if (self.travel_distance - self.last_tree_spawn) > 150: self.last_tree_spawn = self.travel_distance tree_name = random.choice(self.tree_names) # get the wall coordinate at y=0 for spawning wall = self.walls.return_wall_coordinate(0) tree = Enemy( scr=self.screen, name=tree_name, ent_type='tree', cg=self.cg['tree'], pos=[0, 0], icon_list=['media/covid/icon/{}.png'.format(tree_name)], v_speed=self.settings['player_speed'], h_speed=0) self.trees.append(tree) tree.set_walls(wall)
def create_enemies(self, data=None): # update enemy list self.enemies = [x for x in self.enemies if x.is_active()] # remove enemies that are dead or out of screen for e in self.enemies: if not e.is_active(): del e if not self.random_assets: if data != None: # get the wall coordinate at y=0 for spawning wall = self.walls.return_wall_coordinate(0) enemy_name = data[0] pos_h = data[1] vel_h = data[2] enemy = Enemy( scr=self.screen, name=enemy_name, ent_type='enemy', cg=self.cg[enemy_name], pos=[pos_h, 0], icon_list=['media/icon/{}.png'.format(enemy_name)], v_speed=self.settings['player_speed'], h_speed=self.settings['enemy_speed'] * vel_h) self.enemies.append(enemy) enemy.set_walls(wall) else: if (self.travel_distance - self.last_enemey_spawn) > self.enemy_randomizer: self.last_enemey_spawn = self.travel_distance self.enemy_randomizer = random.randint( self.enemy_spawn_distance * 0.5, self.enemy_spawn_distance * 1.5) enemy_name = random.choice(self.enemy_names) # get the wall coordinate at y=0 for spawning wall_1 = self.walls.return_wall_coordinate(0) # get the wall coordinate at the bottom of CG for spawning wall_2 = self.walls.return_wall_coordinate( self.cg[enemy_name][1] * 3) # select the correct wall size if wall_1[0] >= wall_2[0]: wall = wall_1 pos_h = random.randint(wall[0], wall[1] - self.cg[enemy_name][0]) vel_h = random.randint(0, 1) enemy = Enemy( scr=self.screen, name=enemy_name, ent_type='enemy', cg=self.cg[enemy_name], pos=[pos_h, 0], icon_list=['media/icon/{}.png'.format(enemy_name)], v_speed=self.settings['player_speed'], h_speed=self.settings['enemy_speed'] * vel_h) self.enemies.append(enemy) enemy.set_walls(wall)
def create_props(self, data=None): # update prop list self.props = [x for x in self.props if x.is_active()] # remove props that are dead or out of screen for p in self.props: if not p.is_active(): del p if not self.random_assets: if data != None: prop_name = random.choice(self.prop_names) # get the wall coordinate at y=0 for spawning wall = self.walls.return_wall_coordinate(0) pos_h = data[1] prop = Enemy(scr=self.screen, name=prop_name, ent_type='prop', cg=self.cg['prop'], pos=[pos_h, 0], icon_list=['media/icon/{}.png'.format(prop_name)], v_speed=self.settings['player_speed'], h_speed=0) self.props.append(prop) prop.set_walls(wall) else: if (self.travel_distance - self.last_prop_spawn) > self.prop_randomizer: self.last_prop_spawn = self.travel_distance self.prop_randomizer = random.randint( self.prop_spawn_distance * 0.3, self.prop_spawn_distance * 1.3) prop_name = random.choice(self.prop_names) # get the wall coordinate at y=0 for spawning wall_1 = self.walls.return_wall_coordinate(0) # get the wall coordinate at the bottom of CG for spawning wall_2 = self.walls.return_wall_coordinate(self.cg['prop'][1]) # select the correct wall size wall = min(wall_1, wall_2) pos_h = [] pos_h.append(random.randint(0, wall[0] - self.cg['prop'][0])) pos_h.append( random.randint(wall[1], self.settings['width'] - self.cg['prop'][0])) pos = random.choice(pos_h) prop = Enemy(scr=self.screen, name=prop_name, ent_type='prop', cg=self.cg['prop'], pos=[pos, 0], icon_list=['media/icon/{}.png'.format(prop_name)], v_speed=self.settings['player_speed'], h_speed=0) self.props.append(prop) prop.set_walls(wall)