def __init__(self, player, write_data=False): ''' Create level 6 ''' # Call the parents constructor Level.__init__(self, player) self.background = pygame.image.load( "resources/images/background_01.png").convert() savefile = os.path.join("level_data", "level6", "data.json") tilefile = os.path.join("level_data", "level6", "tiles.png") typefile = os.path.join("level_data", "level6", "types.png") # Create an instance of the LevelData class level = terrain.LevelData(savefile, tilefile, typefile) if write_data: level.write_data() # Load the data levelData = level.load_data() # Then render it self.render(levelData)
def __init__(self, player, write_data=False, fast=False, controls=None, sound_engine=None): # Call the parents constructor Level.__init__(self, player, controls, sound_engine) self.save_file = os.path.join("level_data", "level6.json") self.tile_file = os.path.join("level_data", "layouts", "level6") self.type_file = os.path.join("level_data", "tile_types", "level6") # How many layers the level has self.layer_range = 2 self.fast = fast self.door_linkup = {0: 1, 1: 2, 2: 2, 3: 2, 4: 2, 5: 2, 6: 0} level = terrain.LevelData(self.save_file, self.tile_file, self.type_file, "level6") if write_data: level_data = level.write_data(fast) else: level_data = level.load_data() # Then render it self.render(level_data) for door in self.doors.sprites(): door.set_keypad() # Add the level text self.level_text.add( text.LevelText("Don't get caught by the camera!", 435, 1210)) self.level_text.add( text.LevelText("Use the keypad to turn off the camera,", 435, 1235)) self.level_text.add( text.LevelText("But it will turn on again soon!", 490, 1260)) self.level_text.add( text.LevelText("Have fun with this bit...", 425, 600)) self.level_text.add(text.LevelText("Better start running!", 100, 35)) self.level_text.add(text.LevelText("Almost there...", 1680, 75)) self.level_text.add( text.LevelText("Going right is the easy way", 1150, 700)) # Set the start position self.start_x = 0 self.start_y = 719 # Scroll to the starting position self.reset_world() self.shift_world(self.start_x, self.start_y)
def __init__(self, player, write_data=False, fast=False, controls=None, sound_engine=None): Level.__init__(self, player, controls, sound_engine) self.save_file = os.path.join("level_data", "level8.json") self.tile_file = os.path.join("level_data", "layouts", "level8") self.type_file = os.path.join("level_data", "tile_types", "level8") self.layer_range = 2 self.fast = fast self.door_linkup = {0: 0, 1: 0, 2: 0, 3: 0, 4: 1, 5: 1, 6: 1} level = terrain.LevelData(self.save_file, self.tile_file, self.type_file, "level8") if write_data: level_data = level.write_data(fast) else: level_data = level.load_data() self.render(level_data) for door in self.doors.sprites(): door.set_keypad() # Add the level text self.level_text.add( text.LevelText("You've angered the guards!", 150, 1225)) self.level_text.add( text.LevelText("They now have firearms.", 150, 1250)) self.level_text.add(text.LevelText("Bullets will hurt you.", 150, 1275)) self.level_text.add( text.LevelText("Try to dodge or hide from them!", 150, 1300)) self.level_text.add( text.LevelText("There's another one up there!", 625, 1000)) self.level_text.add( text.LevelText("You'll need to run right over him", 580, 780)) self.level_text.add(text.LevelText("Big jump up head!", 150, 625)) self.level_text.add( text.LevelText("i wonder what's down there...", 900, 600)) self.level_text.add(text.LevelText("Ah, you made it!", 1300, 1250)) self.level_text.add( text.LevelText("The keypad is up this way", 1590, 950)) self.start_x = 0 self.start_y = 719 self.reset_world() self.set_scrolling()
def __init__(self, player, write_data=False, fast=False, controls=None, sound_engine=None): # Call the parents constructor Level.__init__(self, player, controls, sound_engine) self.save_file = os.path.join("level_data", "level4.json") self.tile_file = os.path.join("level_data", "layouts", "level4") self.type_file = os.path.join("level_data", "tile_types", "level4") # How many layers the level has self.layer_range = 2 self.fast = fast self.door_linkup = {0: 0, 1: 0, 2: 0, 3: 1, 4: 1} level = terrain.LevelData(self.save_file, self.tile_file, self.type_file, "level4") if write_data: level_data = level.write_data(fast) else: level_data = level.load_data() # Render it self.render(level_data) for door in self.doors.sprites(): door.set_keypad() # Add the level text self.level_text.add(text.LevelText("Up we go!", 80, 1060)) self.level_text.add( text.LevelText("Crawl through ventilation shafts", 144, 90)) self.level_text.add(text.LevelText("Doors aren't", 664, 130)) self.level_text.add(text.LevelText("always vertical", 664, 155)) self.level_text.add(text.LevelText("Slide through here!", 588, 476)) self.level_text.add( text.LevelText("You'll need to hang about on these ladders.", 1200, 1350)) self.level_text.add( text.LevelText("Here's some complex jumps", 1500, 700)) # Set the start position self.start_x = 0 self.start_y = 719 # Scroll to the starting position self.reset_world() self.shift_world(self.start_x, self.start_y)
def __init__(self, player, write_data=False, fast=False, controls=None, sound_engine=None): # Call the parents constructor Level.__init__(self, player, controls, sound_engine) save_file = os.path.join("level_data", "level1.json") tile_file = os.path.join("level_data", "layouts", "level1") type_file = os.path.join("level_data", "tile_types", "level1") # How many layers the level has self.layer_range = 2 self.fast = fast level = terrain.LevelData(save_file, tile_file, type_file, "level1") if write_data: level_data = level.write_data(fast) else: level_data = level.load_data() # Then render self.render(level_data) # Add the level text self.level_text.add( text.LevelText( "Use {} and {} to walk left/right".format( pygame.key.name(self.controls["WALK_LEFT"]), pygame.key.name(self.controls["WALK_RIGHT"])), 36, 960)) self.level_text.add( text.LevelText( "Use {} to jump!".format(pygame.key.name( self.controls["JUMP"])), 36, 990)) self.level_text.add(text.LevelText("Don't fall!", 615, 600)) self.level_text.add(text.LevelText("Watch your stamina level", 30, 600)) self.level_text.add(text.LevelText("The lower it gets", 30, 625)) self.level_text.add(text.LevelText("the slower you move", 30, 650)) self.level_text.add(text.LevelText("Nearly there...", 975, 600)) self.level_text.add(text.LevelText("Down we go", 1750, 450)) # Set start position self.start_x = 0 self.start_y = 719 # Scroll to start position self.reset_world() self.shift_world(self.start_x, self.start_y)
def __init__(self, player, write_data=False, fast=False, controls=None, sound_engine=None): # Call the parents constructor Level.__init__(self, player, controls, sound_engine) self.save_file = os.path.join("level_data", "level5.json") self.tile_file = os.path.join("level_data", "layouts", "level5") self.type_file = os.path.join("level_data", "tile_types", "level5") # How many layers the level has self.layer_range = 2 self.fast = fast self.door_linkup = {0: 0, 1: 0, 2: 1, 3: 1, 4: 2, 5: 2} level = terrain.LevelData(self.save_file, self.type_file, self.type_file, "level5") if write_data: level_data = level.write_data(fast) else: level_data = level.load_data() # Then render it self.render(level_data) for door in self.doors.sprites(): door.set_keypad() # Add the level text self.level_text.add(text.LevelText("Easy way out...", 700, 1350)) self.level_text.add(text.LevelText("Ah, some doors.", 1600, 1350)) self.level_text.add( text.LevelText("These jumps aren't easy!", 290, 670)) self.level_text.add(text.LevelText("Here's a keypad.", 70, 30)) self.level_text.add( text.LevelText("You need perfect timing for this.", 1560, 550)) self.level_text.add( text.LevelText("Watch out for the acid!", 400, 1050)) # Set the start position self.start_x = 0 self.start_y = 719 # Scroll to the starting position self.reset_world() self.shift_world(self.start_x, self.start_y)
def __init__(self, player, write_data=False, fast=False, controls=None, sound_engine=None): Level.__init__(self, player, controls, sound_engine) self.save_file = os.path.join("level_data", "level10.json") self.tile_file = os.path.join("level_data", "layouts", "level10") self.type_file = os.path.join("level_data", "tile_types", "level10") self.layer_range = 2 self.fast = fast self.door_linkup = {0: 0, 1: 0} level = terrain.LevelData(self.save_file, self.tile_file, self.type_file, "level10") if write_data: level_data = level.write_data(self.fast) else: level_data = level.load_data() self.render(level_data) for door in self.doors.sprites(): door.set_keypad() self.level_text.add(text.LevelText("Good luck!", 70, 1080)) self.level_text.add(text.LevelText("Guards everywhere!", 200, 380)) self.level_text.add(text.LevelText("Leap of faith", 300, 100)) self.level_text.add(text.LevelText("Still more guards!", 1360, 750)) self.level_text.add(text.LevelText("This was very cruel", 1050, 1090)) self.level_text.add(text.LevelText("You did it!", 1750, 1090)) self.start_x = 0 self.start_y = 719 self.reset_world() self.set_scrolling()
def __init__(self, player, write_data=False, fast=False, controls=None, sound_engine=None): Level.__init__(self, player, controls, sound_engine) self.save_file = os.path.join("level_data", "level9.json") self.tile_file = os.path.join("level_data", "layouts", "level9") self.type_file = os.path.join("level_data", "tile_types", "level9") self.layer_range = 2 self.fast = fast self.door_linkup = {0: 0, 1: 0, 2: 0} level = terrain.LevelData(self.save_file, self.tile_file, self.type_file, "level9") if write_data: level_data = level.write_data(fast) else: level_data = level.load_data() self.render(level_data) for door in self.doors.sprites(): door.set_keypad() self.level_text.add( text.LevelText("There are lots of guards!", 70, 1080)) self.level_text.add( text.LevelText("You really need to be quick...", 300, 1000)) self.start_x = 0 self.start_y = 719 self.reset_world() self.set_scrolling()
def __init__(self, player, write_data=False, fast=False, controls=None, sound_engine=None): # Call the parents constructor Level.__init__(self, player, controls, sound_engine) self.save_file = os.path.join("level_data", "level7.json") self.tile_file = os.path.join("level_data", "layouts", "level7") self.type_file = os.path.join("level_data", "tile_types", "level7") self.layer_range = 2 self.fast = fast self.door_linkup = { 0: 0, 1: 0, 2: 0, 3: 2, 4: 4, 5: 3, 6: 5, 7: 1, 8: 2, 9: 4, 10: 3, 11: 5, 12: 2, 13: 4, 14: 3, 15: 5, 16: 2, 17: 4, 18: 3, 19: 5, 20: 2, 21: 4, 22: 3, 23: 5, 24: 2, 25: 4, 26: 3, 27: 5, 28: 6 } level = terrain.LevelData(self.save_file, self.tile_file, self.type_file, "level7") if write_data: level_data = level.write_data(fast) else: level_data = level.load_data() self.render(level_data) for door in self.doors.sprites(): door.set_keypad() # Add the level text self.level_text.add( text.LevelText("if you get stuck then press", 80, 1060)) self.level_text.add( text.LevelText( "{} to restart the level".format( pygame.key.name(self.controls["RESTART"])), 80, 1085)) self.level_text.add(text.LevelText("Remember this trick?", 180, 550)) self.level_text.add( text.LevelText("You really need to be fast here!", 800, 380)) self.level_text.add( text.LevelText("You're past the security!", 890, 1230)) self.level_text.add( text.LevelText( "Use {} to plant bombs".format( pygame.key.name(self.controls["ACTION"])), 890, 1255)) self.level_text.add( text.LevelText("on each of the power supplies", 890, 1280)) self.level_text.add( text.LevelText("Once you've placed the bomb", 1200, 1230)) self.level_text.add( text.LevelText( "use {} to activate it!".format( pygame.key.name(self.controls["ACTION"])), 1200, 1255)) self.level_text.add( text.LevelText("There are guards protecting these ones", 1480, 1070)) self.level_text.add( text.LevelText("And a nice easy finish!", 1150, 800)) self.level_text.add( text.LevelText("You can't go to the next level", 1500, 800)) self.level_text.add( text.LevelText("until all the bombs are active", 1500, 825)) self.start_x = 0 self.start_y = 719 self.reset_world() self.shift_world(self.start_x, self.start_y)
def __init__(self, player, write_data=False, fast=False, controls=None, sound_engine=None): # Call the parents constructor Level.__init__(self, player, controls, sound_engine) save_file = os.path.join("level_data", "level3.json") tile_file = os.path.join("level_data", "layouts", "level3") type_file = os.path.join("level_data", "tile_types", "level3") # How many layers the level has self.layer_range = 2 self.fast = fast self.door_linkup = {0: 0, 1: 0} level = terrain.LevelData(save_file, tile_file, type_file, "level3") if write_data: level_data = level.write_data(fast) else: level_data = level.load_data() # Then render self.render(level_data) for door in self.doors.sprites(): door.set_keypad() # Add the level text self.level_text.add( text.LevelText("Watch out for the guards!", 110, 1075)) self.level_text.add( text.LevelText("They're searching with torches,", 110, 1100)) self.level_text.add( text.LevelText("Make sure they don't catch you!", 110, 1125)) self.level_text.add( text.LevelText("Try to find a way to get past the guard.", 110, 1150)) self.level_text.add(text.LevelText("Press the jump key", 700, 1300)) self.level_text.add(text.LevelText("to climb ladders!", 700, 1325)) self.level_text.add(text.LevelText("Here's another guard.", 500, 900)) self.level_text.add( text.LevelText("Let go to slide down ladders.", 800, 800)) self.level_text.add( text.LevelText("These are tricky jumps!", 1120, 1355)) self.level_text.add( text.LevelText( "Press {}".format(pygame.key.name(self.controls["CROUCH"])), 1635, 1060)) self.level_text.add(text.LevelText("to slide through", 1635, 1085)) self.level_text.add(text.LevelText("tight spaces.", 1635, 1110)) self.level_text.add(text.LevelText("Jump onto", 1200, 875)) self.level_text.add(text.LevelText("the ladders.", 1200, 900)) self.level_text.add(text.LevelText("You can also crouch", 920, 350)) self.level_text.add(text.LevelText("under torches!", 920, 375)) self.level_text.add(text.LevelText("Good job!", 200, 200)) self.level_text.add(text.LevelText("Watch out here...", 1275, 425)) # Set start position self.start_x = 0 self.start_y = 719 # Scroll to start position self.reset_world() self.shift_world(self.start_x, self.start_y)
def __init__(self, player, write_data=False, fast=False, controls=None, sound_engine=None): # Call the parents constructor Level.__init__(self, player, controls, sound_engine) save_file = os.path.join("level_data", "level2.json") tile_file = os.path.join("level_data", "layouts", "level2") type_file = os.path.join("level_data", "tile_types", "level2") # How many layers the level has self.layer_range = 2 self.fast = fast self.door_linkup = { 0: 1, 1: 1, 2: 0, 3: 0, 4: 2, 5: 2, 6: 2, 7: 2, 8: 2 } level = terrain.LevelData(save_file, tile_file, type_file, "level2") if write_data: level_data = level.write_data(fast) else: level_data = level.load_data() # Then render self.render(level_data) for door in self.doors.sprites(): door.set_keypad() # Add the level text self.level_text.add( text.LevelText("Watch out for the acid!", 100, 1300)) self.level_text.add(text.LevelText("Nice!", 850, 1150)) self.level_text.add(text.LevelText("This is tricky,", 50, 860)) self.level_text.add(text.LevelText("good luck!", 50, 885)) self.level_text.add( text.LevelText( "Use {} to hack the keypad.".format( pygame.key.name(self.controls["ACTION"])), 360, 50)) self.level_text.add( text.LevelText("Once the keypad is hacked,", 360, 75)) self.level_text.add(text.LevelText("the door will open.", 360, 100)) self.level_text.add(text.LevelText("And again", 585, 270)) self.level_text.add(text.LevelText("Jump!", 800, 370)) self.level_text.add(text.LevelText("Congrats!", 1150, 700)) self.level_text.add(text.LevelText("Choose your path", 1300, 625)) # Set start position self.start_x = 0 self.start_y = 719 # Scroll to start position self.reset_world() self.shift_world(self.start_x, self.start_y)