def __init__(self, player, height=70, screen=None, level_design=None): """ Create level 1. """ # Call the parent constructor Level.__init__(self, player, height=height, screen=screen, level_design=level_design) # Create platforms with sprites level = self.get_level_from_design(using_sprite=True, sprite_left=GRASS_LEFT, sprite_right=GRASS_RIGHT, sprite_center=GRASS_MIDDLE, pos_y=screen.get_rect().height - PLAYER_HEIGHT) # This is the door level change. # ======================================= door = Door(70, 70, self.level_limit_x, self.level_limit_y, DOOR) self.background_sprites.add(door) # ======================================= for platform in level: block = Platform(image=platform[4]) block.rect.x = platform[2] block.rect.y = platform[3] block.player = self.player self.platform_list.add(block)
def __init__(self): Level.__init__(self) self.name = "Breakout Minus Bricks 2" # Rect that objects are allowed to move inside global move_space move_space = pygame.Rect(grid_step, grid_step, shared.dim.x - 2*grid_step, shared.dim.y - 2*grid_step)
def __init__(self, player): '''call parent constructor''' Level.__init__(self, player) self.level_limit = -10000 '''array with with width, height, x, and y of platform''' level = [ [210, 70, 500, 500], [210, 70, 800, 400], [210, 70, 1120, 280], [210, 70, 2000, 300], [210, 70, 1800, 500], [210, 70, 2900, 400], ] walls = [[70, 600, 0, 0], [70, 600, 3200, 0]] '''go through the array and add platforms''' for platform in level: block = Platform(platform[0], platform[1]) block.rect.x = platform[2] block.rect.y = platform[3] block.player = self.player self.platform_list.add(block) '''do the same for level walls''' for wall in walls: block = Wall(wall[0], wall[1]) block.rect.x = wall[2] block.rect.y = wall[3] block.player = self.player self.walls_list.add(block) '''add enemies to level''' self.enemy_list.add(Enemy()) self.enemy_list.add(Enemy())
def __init__(self, player, height=70, screen=None, level_design=None): """ Create level 1. """ # Call the parent constructor Level.__init__(self, player, height=height, screen=screen, level_design=level_design) # Create platforms with sprites level = self.get_level_from_design(using_sprite=True, sprite_left=STONE_PLATFORM_LEFT, sprite_right=STONE_PLATFORM_RIGHT, sprite_center=STONE_PLATFORM_MIDDLE, pos_y=screen.get_rect().height - PLAYER_HEIGHT) # Add door to finish level door = Door(70, 70, self.level_limit_x, self.level_limit_y, DOOR) self.background_sprites.add(door) # Add door to enter level door2 = Door(70, 70, (screen.get_rect().width // 2) - 50, screen.get_rect().height - PLAYER_HEIGHT, DOOR) self.background_sprites.add(door2) # Go through the array above and add platforms for platform in level: block = Platform(image=platform[4]) block.rect.x = platform[2] block.rect.y = platform[3] block.player = self.player self.platform_list.add(block)
def __init__(self, player, AI): Level.__init__(self,player, AI) #enemies = [[40, 40, 0, 0, 'Basic_enemy', 0], # [40, 40, 0, 0, 'Basic_enemy', 1]] self.parse_map('tutorial_map.txt'); """
def __init__(self, level, game, raw, *args, name="GenericLoadScreenLevel",distortion_params=False,color=(30,30,30),scroll=0,autoscroll_speed=(0.0,0.0),vis_ofs=0,audio_section="current",**kwargs): Level.__init__(self, level, game, raw, *args, distortion_params=distortion_params, color=color, scroll=scroll, autoscroll_speed=autoscroll_speed, vis_ofs=vis_ofs, audio_section=audio_section, **kwargs )
def __init__(self, player, AI): Level.__init__(self,player, AI) enemies = { 'G': initGhost, 'S': initSpider, 'M': initMonkey } self.parse_map('tutorial_map.txt', enemies, initEnemy) self.set_background_image('tutorial_background.png') self.music = 'levels/forest.mp3'
def __init__(self, player, AI): Level.__init__(self,player, AI) enemies = { 'G': initGhost, 'S': initSpider, 'M': initMonkey } self.parse_map('level1_map.txt', enemies, initEnemy) self.set_background_image('tutorial_background.png') self.background_image = pygame.transform.scale(self.background_image, (self.level_width, self.level_height - BLOCK_HEIGHT*3)) self.music = 'levels/forest.mp3'
def __init__ (self, game, event_handler, num_cars = 2): event_handler.add_key_handlers([ (conf.KEYS_BACK, lambda *args: game.quit_backend(), eh.MODE_ONDOWN) ]) Level.__init__(self, game, event_handler, 0, False) self.accel = 0 self.scores = [0] * num_cars self._num_players = num_cars self.init_opts(( ('Start', 1, self.start_level), ('Players: ', 2, self._num_players, 1, 4, 1, '{0}', self.change_players), ('Graphics: ', 2, conf.GRAPHICS, 0, None, .1, '{0:.1f}', self.change_graphics), ('Health: ', 3, conf.CAR_HEALTH_ON, ('off', 'on'), self.change_health), ('Health: ', 2, conf.CAR_HEALTH_MULTIPLIER, 0, None, .1, '{0:.1f}', self.change_health, False), ('Quit', 1, self.game.quit_backend) ))
def __init__(self, game, name): Level.__init__(self, game, name) self.speed = 1 self.name = None self.options = [] self.menu = [] self.cursel = 0 self.curmenu = 0 self.lastkeys = pygame.key.get_pressed() self.nblives = 3 self.difficulty = [] self.curdifficulty = 0 self.ingame = False self.menuingame = [] self.slots = [] self.slotcount = 5
def __init__(self, player, AI): Level.__init__(self,player, AI) enemies = { } self.parse_map('end.txt', enemies, initEnemy) self.set_background_image('level2_background.gif') self.background_image = pygame.transform.scale(self.background_image, (self.level_width, self.level_height - BLOCK_HEIGHT*5)) myFont = pygame.font.SysFont("monospace", 100) title = myFont.render("YOUR A WINNER", 1, (255,255,255)) self.title_list.append(title) self.music = 'levels/forest.mp3'
def __init__(self, player, AI): Level.__init__(self,player, AI) enemies = { } self.parse_map('menu.txt', enemies, initEnemy) self.set_background_image('menu.png') self.background_image = pygame.transform.scale(self.background_image, (self.level_width, self.level_height - BLOCK_HEIGHT*5)) myFont = pygame.font.SysFont("monospace", 100) title = myFont.render("Imaginary", 1, (255,255,255)) self.title_list.append(title) # block for loading myFont2 = pygame.font.SysFont("monospace", 50) title2 = myFont2.render("Load", 1, (255,255,255)) self.load_block = title2
def __init__(self, player): """ Create level 1. """ # Call the parent constructor Level.__init__(self, player) self.level_limit = -1000 # Array with type of platform, and x, y location of the platform. level = [ [210, 30, 450, 570], [210, 30, 850, 420], [210, 30, 1000, 520], [210, 30, 1120, 280], ] # Go through the array above and add platforms for platform in level: block = Platform(platform[0], platform[1]) block.rect.x = platform[2] block.rect.y = platform[3] block.player = self.player self.platform_list.add(block)
def __init__(self): Level.__init__(self) self.name = "Template Level"
def __init__(self): Level.__init__(self) self._init_plates()
def __init__(self): Level.__init__(self) self.name = "Basics 1" self.data.completed = False self.won = False
def __init__(self, game, name): Level.__init__(self, game, name) self.speed = 1 self.ytile = 16 self.bgcolor = (96, 105, 120)
def __init__(self): Level.__init__(self) self.name = "Breakout"
def __init__(self, game, name): Level.__init__(self, game, name) self.speed = 1 self.bgcolor = (40, 60, 85)
def __init__(self, game, name): Level.__init__(self, game, name) self.speed = 1 self.bgcolor = (120, 200, 225)
def __init__(self, game, name): Level.__init__(self, game, name) self.speed = 1 self.ytile = 32 self.bgcolor = (8, 40, 56)
def __init__(self, world, image, id): midx = constants.SCREEN_WIDTH / 2.0 midy = constants.SCREEN_HEIGHT / 2.0 self.id = id self.image = image self.img = pygame.image.load(image).convert() playerAnim = pyganim.PygAnimation([('images/granny.png', 0.1), ('images/granny2.png', 0.1), ('images/granny3.png', 0.1), ('images/granny2.png', 0.1), ('images/granny.png', 0.1), ('images/grannyr.png', 0.1), ('images/granny2r.png', 0.1), ('images/granny3r.png', 0.1), ('images/granny2r.png', 0.1), ('images/grannyr.png', 0.1), ('images/grannyf.png', 0.1), ('images/grannyf2.png', 0.1), ('images/grannyf3.png', 0.1), ('images/grannyf2.png', 0.1), ('images/grannyf.png', 0.1), ('images/granny.png', 0.1), ('images/grannyfr.png', 0.1), ('images/grannyf2r.png', 0.1), ('images/grannyf3r.png', 0.1), ('images/grannyf2r.png', 0.1), ('images/grannyfr.png', 0.1), ('images/granny.png', 0.1)]) self.player = Player((midx - 0 ,midy + 300), 'images/granny.png', playerAnim, world) Level.__init__(self, self.player) self.walls = [ #screenPos, Size # MAIN WALLS ############################################# Wall((midx - 635, midy - 90), (3,300), world), Wall((midx + 620, midy - 90), (3,300), world), Wall((midx + 640, midy - 310), (1280,3), world), Wall((midx + 440, midy + 175), (400,40), world), Wall((midx - 450, midy + 175), (400,40), world), Wall((midx - 465, midy - 130), (380,30), world), Wall((midx + 270, midy - 130), (225,30), world), Wall((midx - 450, midy + 67), (15,100), world), Wall((midx - 470, midy + 10), (30,40), world), Wall((midx - 240, midy + 120), (15,40), world), Wall((midx - 240, midy - 50), (15,40), world), Wall((midx + 210, midy + 60), (15,70), world), Wall((midx + 123, midy - 170), (15,20), world), Wall((midx + 430, midy - 170), (15,20), world), Wall((midx - 155, midy - 200), (10,40), world), Wall((midx + 440, midy + 350), (400,40), world), Wall((midx - 450, midy + 350), (400,40), world), ] self.rooms = [ Room(0, (midx - 20, midy + 30), (450, 320)), Room(1, (midx + 430, midy + 30), (450, 320)), Room(2, (midx - 350, midy + 30), (220, 320)), Room(3, (midx - 570, midy + 30), (220, 320)), Room(4, (midx + 360, midy - 290), (500, 320)), Room(5, (midx - 20, midy - 290), (250, 310)), Room(6, (midx - 400, midy - 290), (500, 310)), ] victimAnim = pyganim.PygAnimation([('images/victim.png', 0.1), ('images/victim2.png', 0.1), ('images/victim3.png', 0.1), ('images/victim2.png', 0.1), ('images/victim.png', 0.1), ('images/victimr.png', 0.1), ('images/victim2r.png', 0.1), ('images/victim3r.png', 0.1), ('images/victim2r.png', 0.1), ('images/victimr.png', 0.1)]) self.victims = [ Victim( (midx + 100, midy - 60), 'images/victim.png', victimAnim, world, TaskList([ #screenpos, time(ms), name Task((284, 138), 2000, "a"), Task((623, 391), 2000, "b"), Task((1151, 417), 2000, "c"), Task((290, 403), 2000, "c"), Task((1167, 129), 2000, "c"), ] ), 'images/collisionMap2.png' ), Victim( (midx + 500, midy - 100), 'images/victim.png', victimAnim, world, TaskList([ #screenpos, time(ms), name Task((284, 138), 2000, "a"), Task((623, 391), 2000, "b"), Task((1151, 417), 2000, "c"), Task((290, 403), 2000, "c"), Task((1167, 129), 2000, "c"), ] ), 'images/collisionMap2.png' ), Victim( (midx - 500, midy - 60), 'images/victim.png', victimAnim, world, TaskList([ #screenpos, time(ms), name Task((284, 138), 2000, "a"), Task((623, 391), 2000, "b"), Task((290, 403), 2000, "c"), Task((1167, 129), 2000, "c"), Task((1151, 417), 2000, "c"), ] ), 'images/collisionMap2.png' ), ] tvAnim = pyganim.PygAnimation([('images/tv.png', 0.1), ('images/tv3.png', 0.1), ('images/tv4.png', 0.1)]) self.destructables = [ Destructable((13, 107), tvAnim, 'images/tv.png'), Destructable((13, 439), tvAnim, 'images/tv.png'), ] self.asignRooms()
def __init__(self): Level.__init__(self) self.name = "Breakout... With more colors!"
def __init__(self,player): Level.__init__(self, player) self.obstacles = [ [800,20,20,SCREEN_HEIGHT-120], [200,20,860,SCREEN_HEIGHT-120], [SCREEN_WIDTH-380,20,400,SCREEN_HEIGHT-220], [150,20,210,SCREEN_HEIGHT-220], [700,20,20,SCREEN_HEIGHT-320], [300,20,760,SCREEN_HEIGHT-320], [SCREEN_WIDTH-380,20,400,SCREEN_HEIGHT-420], [200,20,160,SCREEN_HEIGHT-420], [500,20,20,SCREEN_HEIGHT-520], [400,20,560,SCREEN_HEIGHT-520], [SCREEN_WIDTH-330,20,350,SCREEN_HEIGHT-620], [100,20,210,SCREEN_HEIGHT-620], [750,20,20,SCREEN_HEIGHT-720], [200,20,810,SCREEN_HEIGHT-720], [SCREEN_WIDTH-380,20,400,SCREEN_HEIGHT-820], [150,20,210,SCREEN_HEIGHT-820], [100,20,600,SCREEN_HEIGHT-920], [200,20,740,SCREEN_HEIGHT-920], ] self.ladders = [ [820,SCREEN_HEIGHT-120,55,100], [350,SCREEN_HEIGHT-220,55,100], [710,SCREEN_HEIGHT-320,55,100], [350,SCREEN_HEIGHT-420,55,100], [515,SCREEN_HEIGHT-520,55,100], [305,SCREEN_HEIGHT-620,55,100], [755,SCREEN_HEIGHT-720,55,100], [355,SCREEN_HEIGHT-820,55,100], [695,SCREEN_HEIGHT-920,55,100], [800,SCREEN_HEIGHT-220,55,30], [800,SCREEN_HEIGHT-160,55,20], [800,SCREEN_HEIGHT-620,55,30], [800,SCREEN_HEIGHT-560,55,20] ] L = [self.level[0],self.level[2]] for platform in L: k = platform[3] for i in range(platform[1]/16): block = Platform() block.rect.x = platform[2] block.rect.y = k self.platform_list.add(block) k+=16 __level = [self.level[1],self.level[3]] for i in self.obstacles: __level.append(i) for platform in __level: __k = platform[2] for i in range(platform[0]/16): block = Platform() block.rect.x = __k block.rect.y = platform[3] block.player = self.player self.platform_list.add(block) __k+=16 for ladder in self.ladders: block = Ladders(ladder[2],ladder[3]) block.rect.x = ladder[0] block.rect.y = ladder[1] self.ladder_list.add(block)
def __init__(self, world, image, id): midx = constants.SCREEN_WIDTH / 2.0 midy = constants.SCREEN_HEIGHT / 2.0 self.id = id self.image = image self.img = pygame.image.load(image).convert() playerAnim = pyganim.PygAnimation([('images/granny.png', 0.1), ('images/granny2.png', 0.1), ('images/granny3.png', 0.1), ('images/granny2.png', 0.1), ('images/granny.png', 0.1), ('images/grannyr.png', 0.1), ('images/granny2r.png', 0.1), ('images/granny3r.png', 0.1), ('images/granny2r.png', 0.1), ('images/grannyr.png', 0.1), ('images/grannyf.png', 0.1), ('images/grannyf2.png', 0.1), ('images/grannyf3.png', 0.1), ('images/grannyf2.png', 0.1), ('images/grannyf.png', 0.1), ('images/granny.png', 0.1), ('images/grannyfr.png', 0.1), ('images/grannyf2r.png', 0.1), ('images/grannyf3r.png', 0.1), ('images/grannyf2r.png', 0.1), ('images/grannyfr.png', 0.1), ('images/granny.png', 0.1)]) self.player = Player((midx - 430 ,midy + 200), 'images/granny.png', playerAnim, world) Level.__init__(self, self.player) self.walls = [ #screenPos, Size # MAIN WALLS ############################################# Wall((midx - 545, midy - 20), (3,250), world), #LEFT WALL Wall((midx - 235, midy - 205), (345,70), world), # TOP WALL Wall((midx + 350, midy - 305), (240,50), world), # TOP WALL Wall((midx, midy + 220), (540,3), world), # BOTTOM WALL Wall((midx + 522, midy - 155), (3,90), world), #RIGHT WALL TOP Wall((midx + 522, midy + 120), (3,110), world), #RIGHT WALL BOTTOM Wall((midx + 600, midy + 20), (60,3), world), #OUTSIDE TOP Wall((midx + 600, midy - 65), (60,3), world), #OUTSIDE BOTTOM # GRANNY ROOM ############################################ Wall((midx - 386, midy + 110), (10,120), world), #GRANNY RIGHT WALL LARGE Wall((midx - 410, midy + 15), (10,30), world), #GRANNY RIGHT WALL SMALL Wall((midx - 510, midy + 60 ), (40,70), world), #GRANNY LEFT WALL # CORRIDOR ############################################## Wall((midx - 60, midy + 100), (300,120), world), # BOTTOM WALL Wall((midx - 60, midy + 160), (350,100), world), # BOTTOM WALL 2 Wall((midx + 410, midy + 160), (25, 300), world), # RECEPTION WALL Wall((midx + 300, midy - 120), (100, 30), world), # RECEPTION WALL Wall((midx + 390, midy + 90), (40, 30), world), # RECEPTION WALL ] self.rooms = [ Room(0, (midx - 500, midy + 180), (300, 300)), Room(1, (midx - 155, midy - 60), (750, 170)), Room(2, (midx + 320, midy - 222), (440, 150)), Room(3, (midx + 320, midy + 70), (200, 400)), ] victimAnim = pyganim.PygAnimation([('images/victim.png', 0.1), ('images/victim2.png', 0.1), ('images/victim3.png', 0.1), ('images/victim2.png', 0.1), ('images/victim.png', 0.1), ('images/victimr.png', 0.1), ('images/victim2r.png', 0.1), ('images/victim3r.png', 0.1), ('images/victim2r.png', 0.1), ('images/victimr.png', 0.1)]) self.victims = [ Victim( (midx + 100, midy - 60), 'images/victim.png', victimAnim, world, TaskList([ #screenpos, time(ms), name Task((964, 386), 3000, "a"), Task((374, 291), 3000, "b"), #Task((1215, 342), 2000, "c"), ] ), 'images/collisionMap.png' ), ] tvAnim = pyganim.PygAnimation([('images/tv.png', 0.1), ('images/tv3.png', 0.1), ('images/tv4.png', 0.1)]) self.destructables = [ Destructable((midx + 430, 500), tvAnim, 'images/tv.png'), Destructable((midx + 250, 510), tvAnim, 'images/tv.png'), ] self.asignRooms()
def __init__(self): Level.__init__(self) self._init_plates() self._init_obstacles()