Beispiel #1
0
    def __init__(self, Sound=None):

        self.spritesheet = Image.SpriteSheet(path="res\\testSheet.png",
                                             spriteSize=32)
        self.OffsetX, self.OffsetY = 0, 0
        self.animTiles = []
        self.backRendered = False
        self.playerInputs = Constants.PlayerControls

        self.Entities = []

        super().__init__()

        self.TileMap, caverns = Mapper.generateCellularAutomata()
        self.entitypositions = Mapper.placeEnemiesCellular(caverns)

        for position in self.entitypositions:
            self.Entities.append(
                Entities.TestEnemy(x=position[1],
                                   y=position[0],
                                   Map=self.TileMap))

        playerPos = choice(caverns[0])
        while playerPos in self.entitypositions:
            playerPos = choice(caverns[0])

        self.player = Entities.Player(x=playerPos[1],
                                      y=playerPos[0],
                                      map=self.TileMap)
        self.graph = Pathfinding.Graph(self.TileMap)

        self.Sound = SoundHandler.Sound()
        self.Sound.PlayMusic('res/SFX/music.wav')

        self.offsetScene()
Beispiel #2
0
    def __init__(self):
        super().__init__()
        self.Font = pygame.font.SysFont("Lucida Console", 56)
        self.TitleFont = pygame.font.SysFont("Lucida Console", 82)
        self.backgroundColour = (80, 180, 100)
        self.menuPointer = 0

        self.Title = self.TitleFont.render('Coursework', True, (200, 200, 100))
        self.offset = 120

        # Dictionary that holds both the text to be displayed in
        # the menu as well as the corresponding function that
        # the option should call
        self.dictOptions = {
            0: ('Start', self.start),
            1: ('Settings', self.settings),
            2: ('Leaderboard', self.leaderboard),
            3: ('Exit', self.exit)
        }
        self.menu = []

        self.Sound = SoundHandler.Sound()
Beispiel #3
0
    def __init__(self, x: int, y: int, spriteSheet: str, spriteSize: int, interval: int):
        self.x, self.y = x, y
        self.name: str
        # Animation Attributes
        # Size represents the size of the spritesheets sprites not the sprites ingame
        self.size = spriteSize
        # Interval is the time each frame is rendered for
        self.interval = interval
        # The spritesheet the entity reads from
        self.spritesheet = Image.SpriteSheet(spriteSheet, self.size)
        # Pygame allows flipping surfaces, which will be useful for left / right
        self.flipped = False
        # The number of frames can inferred from the width of the spritesheet divided by the size of the sprites
        self.frames = int(self.spritesheet.returnSize()[0] / self.size)
        # The length it takes to run through all the sprites in the row
        self.animLength = self.frames * self.interval
        # The row the sprites should be taken from
        self.row = 0
        # A value that will dictate what sprite should be shown
        self.tick = 0
        # A default sprite so the program has something to render on the first frame
        self.sprite = self.spritesheet.returnSprite(0, self.row)

        self.Sound = SoundHandler.Sound()