def create_board(): ''' Creates board and fills in Obstacles and Scenery ''' board = list() for i in range(int(defs.rows)): temp_list = list() for _ in range(defs.board_len): if i==0 or i==0: clouds.add_element(temp_list,fn=34) elif i==int(defs.rows)-1 : clouds.add_element(temp_list,fn=32) else: clouds.add_element(temp_list,cont=1) board.append(temp_list) defs.board_len-=int(defs.columns) # clouds.Clouds(100,board) defs.plain_board=copy.deepcopy(board) arcs.Arcs((2*int(defs.rows)//3+1),board) coins.Coins(100,board) powerup.Powerup(defs.board_len//5) enemy.Enemy(40) magnet.Magnet(200,10) # defs.board_len+=int(defs.columns) return board
def __init__(self, name='uknsite', time=None, moonaltitude=None, moonazimuth=None, sunaltitude=None, sunazimuth=None, winddirection=-1, windspeed=-1, cloudscheck=True, fimage=None, debugmode=False): """ :param name: string, name of the meteo object (typically the site where you are located, i.e. LaSilla. Must correspond to a .cfg file in :file:`config` that contains the location of the site. See :file:`config/LaSilla.cfg` for example. :param time: Astropy Time object. If None, use the current time as default :param moonaltitude: Astropy Angle object, altitude of the moon . If none, is computed using the site location when :meth:`~meteo.update` is called. :param moonazimuth: Astropy Angle object, azimuth of the moon . If none, is computed using the site location when :meth:`~meteo.update` is called. :param sunaltitude: Astropy Angle object, altitude of the Sun . If none, is computed using the site location when :meth:`~meteo.update` is called. :param sunazimuth: Astropy Angle object, azimuth of the Sun . If none, is computed using the site location when :meth:`~meteo.update` is called. :param winddirection: float, direction of the wind, in degree. If none, is computed using the site weather report when :meth:`~meteo.update` is called. :param windspeed: float, speed of the wind in m/s. If none, is computed using the site weather report when :meth:`~meteo.update` is called. :param cloudscheck: boolean. If True, uses :meth:`clouds.Clouds` to analyze an all-sky image and create a mapping of the clouds in the plane of the sky :param fimage: string, name of the filename of the all-sky image to analyse :param debugmode: boolean. If True, use dummy values for the wind and all-sky .. warning:: the moon and sun position, wind speed and angle default values provided at construction will be overwritten by :meth:`~meteo.update` """ self.name = name self.location = util.readconfig( os.path.join( os.path.dirname(os.path.abspath(inspect.stack()[0][1])), "config", "{}.cfg".format(name))) self.get_telescope_params() self.weatherReport = (util.load_station(name)).WeatherReport() self.time = time self.moonalt = moonaltitude self.moonaz = moonazimuth self.sunalt = sunaltitude self.sunaz = sunazimuth self.winddirection = winddirection self.windspeed = windspeed self.temperature = 9999 self.humidity = -1 self.lastest_weatherupdate_time = None self.debugmode = debugmode self.cloudscheck = cloudscheck self.cloudmap = None self.allsky = clouds.Clouds(name=name, fimage=fimage, debugmode=debugmode) self.update()
def test_clouds(self): cloud = clouds.Clouds(Mario.map_mario) cloud.draw(HEIGHT - 4, WIDTH - 10) assert Mario.map_mario[HEIGHT - 4][WIDTH - 10] == "(" assert Mario.map_mario[HEIGHT - 4][WIDTH - 9] == ")" assert Mario.map_mario[HEIGHT - 4][WIDTH - 8] == "(" assert Mario.map_mario[HEIGHT - 4][WIDTH - 7] == ")" assert Mario.map_mario[HEIGHT - 4][WIDTH - 6] == "(" assert Mario.map_mario[HEIGHT - 4][WIDTH - 5] == ")" assert Mario.map_mario[HEIGHT - 3][WIDTH - 13] == "." assert Mario.map_mario[HEIGHT - 3][WIDTH - 12] == "." assert Mario.map_mario[HEIGHT - 3][WIDTH - 11] == "(" assert Mario.map_mario[HEIGHT - 3][WIDTH - 10] == ")" assert Mario.map_mario[HEIGHT - 3][WIDTH - 9] == "(" assert Mario.map_mario[HEIGHT - 3][WIDTH - 8] == ")" assert Mario.map_mario[HEIGHT - 3][WIDTH - 7] == "(" assert Mario.map_mario[HEIGHT - 3][WIDTH - 6] == ")"
def create_clouds(self): while len(self.cloud_group) < self.settings.cloud_number: cloud = clouds.Clouds(self) self.cloud_group.add(cloud)
def __init__(self): self.win = py.display.set_mode( (config.screen_width, config.screen_height)) py.font.init() py.display.set_caption("EscapeVector") #----------Menusystem--------- self.menu_system = menu.Menu() ############ self.mouse_clicked = False self.quit = False self.mouse_pos = (0, 0) self.pressed_escape = False self.turn_right = False self.turn_left = False self.turbo = False self.throttle_down = True self.throttle_up = False self.slowtime = False self.slowduration = 10 self.clock = py.time.Clock() self.hud_base = py.transform.scale(py.image.load("../images/hud.png"), (200, 200)) self.explode = explosion.Explosion() self.minimap = minimap.Minimap() self.missiles_exploded = [] self.close_time = 0 self.fighters = py.sprite.Group() self.missiles = py.sprite.Group() self.emps = py.sprite.Group() self.turn_screen_red = False self.slowvalue = 1 self.bullets = bullet.BulletsSystem() self.enemiesbullets = bullet.BulletsSystem() self.shoot = False self.ai = brain.Brain() self.ai.fighters = self.fighters.sprites() self.sparkSystem = particle.SparkSystem() self.explosions_size = 10 self.initial_explosion = [] self.clouds = clouds.Clouds() self.explosions = [] self.camoffs = [] for i in range(20): self.camoffs.append( [random.randint(-10, 10), random.randint(-10, 10)]) self.camoffx = 0 self.camoffy = 0 self.shake = False self.shakecount = 0 self.screen_r = 0x8c self.screen_g = 0xbe self.screen_b = 0xd6 self.turn_screen_normal = True self.dirty_rects = [] self.game_exists = False #######sounds##### self.sounds = sound.Sound() self.playerhit = False self.fighterhit = False self.ticklowspeed = 0.5 self.tickhighspeed = 0.1 self.tickspeedrate = 0.05 self.tickspeed = 0.1
def init_game(height, width, level): config.mario = scene.Mario_map(height, width) config.mario.initialize() config.enemy = [] config.coin = coins.Coins() config.cake = cake.Cakes() config.pistol = pistol.Pistol() config.flagger = flag_1.Flag(config.mario.map_mario) if level == 1: counter = 3 elif level == 2: counter = 4 #initialize enemies for i in range(0, counter - 2): for i in config.mario.boundary: enemy_original_y = i + randint(int(width / 2), width - 15) enemy_original_x = height - 4 config.enemy.append( small_enemy.enemy_1(enemy_original_x, enemy_original_y)) stable_set = ["#", "&"] #initialize clouds for i in config.mario.boundary: n = randint(counter, counter + 2) for count in range(0, n): cloud = clouds.Clouds(config.mario.map_mario) cloud_x, cloud_y = randint(30, 140) + i, randint(3, 5) cloud.update(n, cloud_y, cloud_x) config.clouds.append(cloud) #initialize pillars for i in config.mario.boundary: for count in range(0, counter): pole = poles.Poles(config.mario.map_mario) pole_x, pole_y = randint(int(width / 2), width - 15) + i, height - 4 pole.draw(pole_x, pole_y) config.poles.append(pole) #initialize stairs for count in range(0, 3): config.ending = ending.End(config.mario.map_mario) stair_x, stair_y = width * 6 + 20 + count * 21, height - 10 config.ending.draw_left(stair_x, stair_y, height, width) stair_x, stair_y = width * 6 + 31 + count * 21, height - 10 config.ending.draw_right(stair_x, stair_y, height, width) config.stair_coordinates.append([stair_x, stair_y]) #initialize coins for j in range(0, 4): for i in range(0, 6): k = randint(height - 14, height - 8) a = randint(int(width / 12), width - 24) b = a + 12 config.coin.set_position(k, a, randint(0, 13), config.mario.boundary[i]) config.coin.set_position(k, a, randint(0, 13), config.mario.boundary[i]) config.mario.make_wall(k, a, b, config.char, i) config.mario.make_wall(k - 1, a, b, config.char, i) if i % 3 == 0: cake_y, cake_x = k, a + randint(1, 11) + config.mario.boundary[i] config.cake.set_position(cake_y, cake_x) if i % 3 == 1: pistol_y, pistol_x = k, a + randint( 1, 11) + config.mario.boundary[i] config.pistol.set_position(pistol_y, pistol_x) #initialize variables config.x_flag = width * 6 + int(width / 2) + 30 config.y_flag = height - 14 config.flagger.draw_2(config.y_flag, config.x_flag) config.distance = 0 config.score = 0 config.index = 0 config.counter = 0 config.counter_back = 0 config.start_x = 0 os.system('clear') print("score- " + str(config.score) + " " + "distance- " + str(config.distance)) config.player = mario_player.Mario(int(height - 4), 0) config.player.draw(config.mario.map_mario) for items in config.enemy: items.draw(config.mario.map_mario) config.enemy_count.append(1) config.mario.print_map(int(width), int(height), config.start_x) config.final_height = height - 4 config.limit = 0 config.flag = 1 config.follow_coefficient = -1 config.game_over = False config.big_mario = False os.system('aplay -qN ./sound/theme.wav &')
def init_game(height, width, level): """gaurav""" config.mario = scene.Mario_map(height, width) config.mario.initialize() config.ENEMY = [] config.coin = coins.Coins() config.cake = cake.Cakes() config.pistol = pistol.Pistol() config.flagger = flag_1.Flag(config.mario.map_mario) if level == 1: counter = 3 elif level == 2: counter = 4 # initialize enemies for j in range(0, counter - 2): for i in config.mario.boundary: enemy_original_y = i + randint(int(width / 2), width - 15) enemy_original_x = height - 4 config.ENEMY.append( small_enemy.enemy_1(enemy_original_x, enemy_original_y)) for i in config.mario.boundary: number = randint(counter, counter + 2) for count in range(0, number): cloud = clouds.Clouds(config.mario.map_mario) cloud_x, cloud_y = randint(30, 140) + i, randint(3, 5) cloud.update(number, cloud_y, cloud_x) config.CLOUDS.append(cloud) # initialize pillars for i in config.mario.boundary: for count in range(0, counter): pole = poles.Poles(config.mario.map_mario) pole_x, pole_y = randint(int(width / 2), width - 15) + i, height - 4 pole.draw(pole_x, pole_y) config.POLES.append(pole) # initialize stairs for count in range(0, 3): config.ending = ending.End(config.mario.map_mario) stair_x, stair_y = width * 6 + 20 + count * 21, height - 10 config.ending.draw_left(stair_x, stair_y, height, width) stair_x, stair_y = width * 6 + 31 + count * 21, height - 10 config.ending.draw_right(stair_x, stair_y, height, width) config.STAIR_COORDINATES.append([stair_x, stair_y]) # initialize coins for j in range(0, 4): for i in range(0, 6): j = j temp = randint(height - 14, height - 8) air = randint(int(width / 12), width - 24) boom = air + 12 config.coin.set_position(temp, air, randint(0, 13), config.mario.boundary[i]) config.coin.set_position(temp, air, randint(0, 13), config.mario.boundary[i]) config.mario.make_wall(temp, air, boom, config.CHAR, i) config.mario.make_wall(temp - 1, air, boom, config.CHAR, i) if i % 3 == 0: cake_y, cake_x = temp, air + \ randint(1, 11)+config.mario.boundary[i] config.cake.set_position(cake_y, cake_x) if i % 3 == 1: pistol_y, pistol_x = temp, air + \ randint(1, 11)+config.mario.boundary[i] config.pistol.set_position(pistol_y, pistol_x) # initialize variables config.X_FLAG = width * 6 + int(width / 2) + 30 config.Y_FLAG = height - 14 config.flagger.draw_2(config.Y_FLAG, config.X_FLAG) config.DISTANCE = 0 config.SCORE = 0 config.INDEX = 0 config.COUNTER = 0 config.COUNTER_BACK = 0 config.START_X = 0 os.system('clear') print("score- " + str(config.SCORE) + " " + "distance- " + str(config.DISTANCE)) config.player = mario_player.Mario(int(height - 4), 0) config.player.draw(config.mario.map_mario) for items in config.ENEMY: items.draw(config.mario.map_mario) config.ENEMY_COUNT.append(1) config.mario.print_map(int(width), int(height), config.START_X) config.FINAL_HEIGHT = height - 4 config.LIMIT = 0 config.FLAG = 1 config.follow_coefficient = -1 config.GAME_OVER = False config.BIG_MARIO = False os.system('aplay -qN ./sound/theme.wav &')