Example #1
0
        def __init__(self, surface):
            self.surface = surface

            self.BackGround = Background()
            self.DieText = Text(text="DIE! Press R to restart!", name="Die", w=WIN_WIDTH, h=WIN_HEIGHT, color=(30, 30, 30, 1), fontSize=90)
            # self.DieImage = pygame.image.load(PICTURE_AFTER_DIE)
            self.level_name = Menus.currentLevel

            self.on_level_collect = 0

            self.map = []
            self.player = Player()

            self.blocks = pygame.sprite.Group()
            self.wallList = pygame.sprite.Group()
            self.prefabs = []
            self.reload = False

            self.sound = pygame.mixer.Sound(SOUNDS_GAME["W1_Music"])
            self.sound.set_volume(SavesManager.AUDIO_VOLUME)

            self.toLevelSelectorTimer = 0.3

            self.sound.play(loops=10000)

            self.camera = None

            self.buttonMenu = Button(x=650, y=0, w=50, h=50, spriteName="Back", name=None, text=None, color=(230, 230, 230), onColor=(200, 200, 200), pressColor=(150, 150, 150), fontSize=25, func=self.ToLevelSelector)

            self.GenerateLevel()
Example #2
0
        def __init__(self, surface):
            self.surface = surface

            self.BackGround = Background()
            self.buttonStart = Button(200, 5, 300, 70, spriteName="D1_Button",  name="Start", text="Start", fontSize=60, color=(230, 230, 230), onColor=(200, 200, 200), pressColor=(150, 150, 150), func=self.ToLevelSelector)
            self.buttonSettings = Button(200, 85, 300, 70, spriteName="D1_Button", name="Settings", text="Settings", fontSize=60, color=(230, 230, 230), onColor=(200, 200, 200), pressColor=(150, 150, 150), func=self.ToLevelSettings)
            self.buttonUpgrade = Button(200, 165, 300, 70, spriteName="D1_Button", name="Upgrade", text="Upgrade", fontSize=60, color=(230, 230, 230), onColor=(200, 200, 200), pressColor=(150, 150, 150), func=self.ToLevelUpgrade)
            self.buttonCreator = Button(200, 245, 300, 70, spriteName="D1_Button", name="Level Creator", text="Level Creator", fontSize=60, color=(230, 230, 230), onColor=(200, 200, 200), pressColor=(150, 150, 150), func=self.ToLevelCreator)
            self.buttonExit = Button(200, 325, 300, 70, spriteName="D1_Button", name="Exit", text="Exit", fontSize=60, color=(230, 230, 230), onColor=(200, 200, 200), pressColor=(150, 150, 150), func=self.Exit)
Example #3
0
        def __init__(self, surface):
            self.surface = surface

            self.BackGround = Background()

            self.buttonMenu = Button(x=650, y=0, w=50, h=50, spriteName="Back", name=None, text=None, color=(230, 230, 230), onColor=(200, 200, 200), pressColor=(150, 150, 150), fontSize=25, func=self.ToMenu)
            self.levelButtons = []
            self.last = []

            self.GenerateButtons()
Example #4
0
        def __init__(self, surface):
            self.surface = surface

            self.BackGround = Background()
            self.buttonMenu = Button(200, 210, 300, 70,spriteName="D1_Button", name="Menu", text="Menu", fontSize=60, color=(230, 230, 230), onColor=(200, 200, 200), pressColor=(150, 150, 150), func=self.ToMenu)

            self.worldButtons = [
                Button(200, 20, 300, 70,spriteName="D1_Button", name=None, text="World_1", fontSize=60, color=(230, 230, 230), onColor=(200, 200, 200), pressColor=(150, 150, 150), func=lambda: self.ChangeWorldType("World_1")),
                Button(200, 110, 300, 70,spriteName="D1_Button", name=None, text="World_2", fontSize=60, color=(230, 230, 230), onColor=(200, 200, 200), pressColor=(150, 150, 150), func=lambda: self.ChangeWorldType("World_2"))
            ]
Example #5
0
        def __init__(self, surface):
            self.surface = surface

            self.BackGround = Background()

            self.sliderVolume = Slider(text="Volume", x=150, y=20, w=400, h=100, out_x=20)
            self.buttonMenu = Button(x=150, y=280, w=400, h=100, spriteName="D1_Button", name="Menu", text="Menu", color=(230, 230, 230), onColor=(200, 200, 200), pressColor=(150, 150, 150), fontSize=25, func=self.ToMenu)

            self.languages_button = [
                Button(x=150, y=140, w=180, h=100, spriteName="Ru", name=None, text=None, color=(230, 230, 230), onColor=(200, 200, 200), pressColor=(150, 150, 150), fontSize=25, func=lambda: self.ChangeLanguage("ru")),
                Button(x=370, y=140, w=180, h=100, spriteName="Eng", name=None, text=None, color=(230, 230, 230), onColor=(200, 200, 200), pressColor=(150, 150, 150), fontSize=25, func=lambda: self.ChangeLanguage("en")),
            ]
Example #6
0
        def __init__(self, surface):
            self.surface = surface

            self.BackGround = Background()

            self.u_speedPanel = Panel(x=20, y=0, w=230, h=310, color=(220, 220, 220, 150))
            self.u_speedImage = Image(x=50, y=20, w=160, h=220)
            self.u_speedButton = Button(x=20, y=240, w=230, h=70, spriteName="D1_Button", name="Speed", text="Speed", color=(230, 230, 230), onColor=(200, 200, 200), pressColor=(150, 150, 150), fontSize=25, func=lambda: self.UpgradeStat("speed_level"))

            self.u_jumpPanel = Panel(x=450, y=0, w=230, h=310, color=(220, 220, 220, 150))
            self.u_jumpImage = Image(x=490, y=20, w=160, h=220, name="U_Jump")
            self.u_jumpButton =  Button(x=450, y=240, w=230, h=70, spriteName="D1_Button", name="Jump", text="Jump", color=(230, 230, 230), onColor=(200, 200, 200), pressColor=(150, 150, 150), fontSize=25, func=lambda: self.UpgradeStat("jump_level"))

            self.u_coinPanel = Panel(x=270, y=0, w=160, h=310, color=(220, 220, 220, 150))
            self.u_coinImage = Image(x=270, y=20, w=160, h=184, name="U_Coin")
            self.u_coinText = Text(x=270, y=240, w=160, h=70, text="100", fontSize=30)

            self.buttonMenu = Button(x=150, y=330, w=400, h=50, spriteName="D1_Button", name="Menu", text="Menu", color=(230, 230, 230), onColor=(200, 200, 200), pressColor=(150, 150, 150), fontSize=25, func=self.ToMenu)
Example #7
0
        def GenerateLevel(self):
            print(self.level_name)
            try:
                with open(f"Levels\\{self.level_name}.json", "r") as levels:
                    self.level = json.load(levels)
            except:
                raise Exception("Level not found in json!")
            typeWorld = self.level["type"]
            self.level = self.level["map"]

            self.BackGround = Background(typeWorld=typeWorld)

            if (typeWorld == "World_2"):
                self.sound.stop()
                self.sound = pygame.mixer.Sound(SOUNDS_GAME["W2_Music"])
                self.sound.set_volume(SavesManager.AUDIO_VOLUME)
                self.sound.play(loops=10000)

            x, y, step = 0, 0, 32
            level_for = ""
            for i in self.level: level_for += i
            for symbol in level_for:
                if (symbol in LEVEL_GENERATOR_SPRITES[typeWorld].keys() and symbol not in "WVKCDPS|"):
                    block = Block(x, y, symbol, typeWorld=typeWorld)
                    self.blocks.add_internal(block)
                    self.wallList.add_internal(block)
                    x += step
                elif (symbol == "C"):
                    coin = Coin(x, y, typeWorld=typeWorld)
                    self.blocks.add_internal(coin)
                    self.wallList.add_internal(coin)
                    x += step
                elif (symbol == "D"):
                    door = Door(x, y, typeWorld=typeWorld)
                    self.blocks.add_internal(door)
                    self.wallList.add_internal(door)
                    x += step
                elif (symbol == "K"):
                    key = Key(x, y, typeWorld=typeWorld)
                    self.blocks.add_internal(key)
                    self.wallList.add_internal(key)
                    x += step
                elif (symbol == "W"):
                    water = Water(x, y, typeWorld=typeWorld)
                    self.blocks.add_internal(water)
                    self.wallList.add_internal(water)
                    x += step
                elif (symbol == "V"):
                    waterKill = WaterKill(x, y, typeWorld=typeWorld)
                    self.blocks.add_internal(waterKill)
                    self.wallList.add_internal(waterKill)
                    x += step
                elif (symbol == "S"):
                    spikes = Spikes(x, y, typeWorld=typeWorld)
                    self.blocks.add_internal(spikes)
                    self.wallList.add_internal(spikes)
                    x += step
                elif (symbol == "P"):
                    self.player.rect.topleft = (x, y)
                    x += step
                elif (symbol == "|"):
                    x = 0
                    y += step
                else:
                    x += step
            self.blocks.add_internal(self.player)
            self.player.walls = self.wallList


            total_level_width = len(self.level[0]) * BLOCK_SIZE[0]  # Высчитываем фактическую ширину уровня
            total_level_height = len(self.level) * BLOCK_SIZE[1]  # высоту
            self.camera = Camera(camera_configure, total_level_width, total_level_height)