예제 #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()
예제 #2
0
def displaySprite(mapNum):
    player = Entities.Player()
    king = Entities.King()
    vizzi = Entities.Vizzi()
    charles = Entities.Charles()
    dragon = Entities.Dragon()
    wizard = Entities.Wizard()
    villain = Entities.Villain()
    if mapNum == 0:
        player.x = (40 * 4)
        player.y = (40 * 2) - 15
        remove(player)
        add(player)  # //player sprite
        king.x = (40 * 9)
        king.y = (40 * 2) - 15
        remove(king)
        add(king)
    elif mapNum == 1:
        #remove(king) #// Can't seem to get this function to work
        king.y += 1000  #// Moving them off-screen instead of removing them
        vizzi.x = (40 * 9)
        vizzi.y = (40 * 2) - 15
        remove(vizzi)
        add(vizzi)
    elif mapNum == 2:
        #remove(vizzi)
        vizzi.y += 1000
        charles.x = (40 * 9)
        charles.y = (40 * 2) - 15
        remove(charles)
        add(charles)
    elif mapNum == 3:
        #remove(charles)
        charles.y += 1000
        dragon.x = (40 * 9)
        dragon.y = (40 * 2) - 15
        remove(dragon)
        add(dragon)
    elif mapNum == 4:
        #remove(dragon)
        dragon.y += 1000
        wizard.x = (40 * 9)
        wizard.y = (40 * 2) - 15
        remove(wizard)
        add(wizard)
    elif mapNum == 5:
        #remove(wizard)
        wizard.y += 1000
        villain.x = (40 * 9)
        villain.y = (40 * 2) - 15
        remove(villain)
        add(villain)
    elif mapNum >= 6:
        #remove(wizard)
        wizard.y += 1000
        villain.x = (40 * 9)
        villain.y = (40 * 2) - 15
        remove(villain)
        add(villain)
예제 #3
0
def add_sprites():
    #TODO Add algorithm to drop in open spaces in any map
    for i in range(v.player_num):
        [row, col] = get_space()
        # print(row)
        # print(col)
        players.append(e.Player(i+2, row, col, brains[i]))


    e.group.add_sprite(players)
예제 #4
0
    def __init__(self, width, height, mapFile):
        super().__init__(width, height)
        self.logger = Logger.Logger(pos = Main.WIDTH, width = Main.LOGWIDTH, height = Main.SCREEN_HEIGHT)
        path1 = Main.getPath("res/TileSheet.png")
        path2 = Main.getPath("res/AnimTileSheet.png")
        self.map = Mapper.Map(mapFile, path1, path2)

        self.CELLMAP = True

        if self.CELLMAP:
            self.tileMap, caverns = self.map.getCavernTileMap()
            playerLocationY, playerLocationX = random.choice(caverns[0])
            playerLocation = (playerLocationX, playerLocationY)
            self.player = Entities.Player(playerLocation[0],playerLocation[1],"res/playerSheet.png",self.tileMap,3,10, self.logger)
            enemyLocations = self.calculateEnemyPlacements(caverns, playerLocation)
            self.Entities = [self.player]
            for each in enemyLocations:
                seed = random.randint(0,3)
                if not seed == 1:
                    self.Entities.append(Entities.TestEnemy(each[0],each[1],self.tileMap))
                else:
                    self.Entities.append(Entities.Goblin(each[0], each[1], self.tileMap))
        else:
            self.tileMap = self.map.getTileMap()
            playerLocationY, playerLocationX = (2,2)
            playerLocation = (playerLocationY, playerLocationX)
            self.player = Entities.Player(playerLocationY,playerLocationX, "res/playerSheet.png", self.tileMap, 3, 10, self.logger)
            self.Entities = [self.player]
            #Will need to make a system of entity placement that isn't hard coded, but Im not entirely sure how other than random generation or messing around with alpha channels.
            # ^ IGNORE ALREADY DONE WITH RANDOM GEN
            self.DummyEnemies = [Entities.TestEnemy(5,5,self.tileMap, 100),
                                Entities.TestEnemy(5,7,self.tileMap, 100),
                                Entities.TestEnemy(4,6,self.tileMap, 100),
                                Entities.TestEnemy(6,6,self.tileMap, 100)]
            self.Entities.extend(self.DummyEnemies)
        self.graph = Pathing.Graph(self.tileMap)

        self.animTiles = []
        self.renderedBack = False
        self.CameraX = -(playerLocation[0] * Tiles.TILESIZE - Main.WIDTH/2)
        self.CameraY = -(playerLocation[1] * Tiles.TILESIZE - Main.HEIGHT/2)
예제 #5
0
 def start_game(self):
     self.loading_screen()
     self.map = MapGenerator.Map(self.settings['map_size'])
     self.Player = Entities.Player(
         (int(self.settings['window_size'][0] / 2),
          int(self.settings['window_size'][1] / 2), 180),
         self.settings['map_size'])
     self.entities = self.create_entities()
     self.projectiles = []
     self.Camera = Entities.Camera(self.Player,
                                   self.settings['window_size'], self.map)
     self.score = 0
     self.game_loop()
예제 #6
0
파일: Main.py 프로젝트: GJ2021-SSU/UPDATE
# MONOLITHIC VARIABLES
Running = True
Paused = False
Debug = False
Sound = True
clock = pygame.time.Clock()
pygame.display.set_caption('Main.py')

# Window Variables
window_width = 3200
window_height = 2400
window = pygame.display.set_mode((window_width // 4, window_height // 4), 0,
                                 32)

# Player Variables
player = Entities.Player(375, 375)

# Camera Variables
camera = Entities.Camera(10, 10, 780, 580)

# Button Variables
button_list = {
    'Play_Button': Entities.Buttons(100, 100, 300, 100),
    'Quit_Button': Entities.Buttons(100, 250, 150, 70)
}

# Room Variables
room_count_total = 0
cur_level = 0
room_size = 11
room_model = 1
예제 #7
0
 def setUp(self):
     self.player = Entities.Player((100, 100, 0), test_map_size)
     self.enemy = Entities.Enemy((110, 110, 0), test_map_size)