Пример #1
0
 def load_data(self):
     self.game_over = False
     self.start_on = True
     self.start_on2 = True
     self.end_on = True
     game_folder = path.dirname(__file__)
     img_folder = path.join(game_folder, 'Textures')
     ground_folder = path.join(img_folder, "ground")
     char_folder = path.join(img_folder, "char")
     wall_folder = path.join(img_folder, "wall")
     #map
     self.map = tilemap.Map(path.join(game_folder, 'mapa mato.txt'))
     self.map2 = tilemap.Map(path.join(game_folder, 'mapa castelo.txt'))
     self.player_img_up = pg.image.load(
         path.join(char_folder, "char_up.png")).convert_alpha()
     self.player_img_down = pg.image.load(
         path.join(char_folder, "char_down.png")).convert_alpha()
     self.player_img_left = pg.image.load(
         path.join(char_folder, "char_left.png")).convert_alpha()
     self.player_img_right = pg.image.load(
         path.join(char_folder, "char_right.png")).convert_alpha()
     self.tilezito = pg.image.load(path.join(
         ground_folder, "tilezito.png")).convert_alpha()
     self.wall_img = pg.image.load(path.join(wall_folder,
                                             "wall.png")).convert_alpha()
     self.tree_wall_img = pg.image.load(path.join(
         wall_folder, "tree.png")).convert_alpha()
     self.stone_ground_img = pg.image.load(
         path.join(ground_folder, "stone_brick.png")).convert_alpha()
     self.dirt_ground_img = pg.image.load(
         path.join(ground_folder, "ground2.png")).convert_alpha()
     self.lake = pg.image.load(path.join(img_folder,
                                         "lake.png")).convert_alpha()
     self.stone_grass_img = pg.image.load(
         path.join(ground_folder, "mossy_stone_brick.png")).convert_alpha()
     self.dirt_grass_img = pg.image.load(
         path.join(ground_folder, "grass2.png")).convert_alpha()
     self.tall_grass_img = pg.image.load(
         path.join(ground_folder, "grass3.png")).convert_alpha()
     self.bau_a_img = pg.image.load(path.join(img_folder,
                                              "bau_aberto.png")).convert()
     self.bau_f_img = pg.image.load(path.join(img_folder,
                                              "bau_fechado.png")).convert()
     self.inicio = pg.image.load(path.join(img_folder,
                                           "start_screen.png")).convert()
     self.fim = pg.image.load(path.join(img_folder,
                                        "end_screen.png")).convert()
     self.combat_back = pg.image.load(
         path.join(img_folder, "combat_background.png")).convert()
     self.escolha = pg.image.load(path.join(img_folder,
                                            "escolha.png")).convert()
     self.cura_img = pg.image.load(path.join(img_folder,
                                             "cura.png")).convert()
     self.pc_img = pg.image.load(path.join(img_folder, "pc.png")).convert()
     self.font = settings.fonte
     self.font40 = settings.fonte_combate
     self.font20 = settings.fonte_legenda
     self.coloca_monstros()
     self.coloca_itens()
Пример #2
0
 def __init__(self):
     self.screen = pg.display.set_mode((settings.WIDTH, settings.HEIGHT))
     self.clock = pg.time.Clock()
     self.player = Player(self.screen)
     self.menu = Menu(self.screen)
     self.running = True
     self.state = 'start'
     self.map = tilemap.Map(self, 'assets/maps/map_0.tmx')
     self.map_img = self.map.make_map()
     self.map_rect = self.map_img.get_rect()
Пример #3
0
    def __init__(self, index):
        if index == LEVEL_1:
            self.tilemap = tilemap.Map(LVL1["CHECKPOINTS"])
            self.lazor = lazor.Lazor(LVL1["LAZOR_SPAWN"], LVL1["LAZOR_DIR"])
            self.tilestack = tilestack.Tilestack(LVL1["TILES"])
        elif index == LEVEL_2:
            self.tilemap = tilemap.Map(LVL2["CHECKPOINTS"])
            self.lazor = lazor.Lazor(LVL2["LAZOR_SPAWN"], LVL2["LAZOR_DIR"])
            self.tilestack = tilestack.Tilestack(LVL2["TILES"])
        elif index == LEVEL_3:
            self.tilemap = tilemap.Map(LVL3["CHECKPOINTS"])
            self.lazor = lazor.Lazor(LVL3["LAZOR_SPAWN"], LVL3["LAZOR_DIR"])
            self.tilestack = tilestack.Tilestack(LVL3["TILES"])
        elif index == LEVEL_4:
            self.tilemap = tilemap.Map(LVL4["CHECKPOINTS"])
            self.lazor = lazor.Lazor(LVL4["LAZOR_SPAWN"], LVL4["LAZOR_DIR"])
            self.tilestack = tilestack.Tilestack(LVL4["TILES"])
        elif index == LEVEL_5:
            self.tilemap = tilemap.Map(LVL5["CHECKPOINTS"])
            self.lazor = lazor.Lazor(LVL5["LAZOR_SPAWN"], LVL5["LAZOR_DIR"])
            self.tilestack = tilestack.Tilestack(LVL5["TILES"])
        elif index == LEVEL_RAND:
            self.tilemap = tilemap.Map()
            self.lazor = lazor.Lazor(LVLRAND["LAZOR_SPAWN"],
                                     LVLRAND["LAZOR_DIR"])
            self.tilestack = tilestack.Tilestack()

        self.empty_tile = pygame.image.load("emptytile.png")
        self.occupied_tile = pygame.image.load("tile.png")
    def __init__(self):
        self.highlight = spryte.Sprite(highlight_image, 0, 0)
        self.show_highlight = False

        # CREATE THE MAP
        self.field = tilemap.Map()
        self.play_field = {}
        l = []
        for y, line in enumerate(field_rows):
            m = []
            l.append(m)
            for x, cell in enumerate(line):
                if cell == '#':
                    m.append(
                        spryte.Sprite(wall_image,
                                      x * cw,
                                      y * ch,
                                      batch=self.field))
                    content = path.Blocker
                else:
                    m.append(
                        spryte.Sprite(blank_image,
                                      x * cw,
                                      y * ch,
                                      batch=self.field))
                    if cell == 'E':
                        content = path.End
                    elif cell == 'S':
                        content = path.Start
                    elif cell == '+':
                        content = path.Blocker
                    else:
                        content = None
                self.play_field[x * 2, y * 2] = content
                self.play_field[x * 2 + 1, y * 2] = content
                self.play_field[x * 2, y * 2 + 1] = content
                self.play_field[x * 2 + 1, y * 2 + 1] = content
        self.field.set_cells(cw, ch, l)

        # PATH FOR ENEMIES
        self.path = path.Path.determine_path(self.play_field, map_width * 2,
                                             map_height * 2)
        #self.path.dump()

        self.constructions = spryte.SpriteBatch()

        self.enemies = spryte.SpriteBatch()
        self.bullets = spryte.SpriteBatch()
Пример #5
0
    def load_data(self):
        # Easy names to start file directories
        self.game_folder = path.dirname(__file__)
        self.img_folder = path.join(self.game_folder, 'img')
        self.map_folder = path.join(self.game_folder, 'maps')

        # load Tiled map stuff
        self.map = tilemap.Map(path.join(self.map_folder, 'test_map.tmx'))
        self.map_img = self.map.make_map()
        self.map_rect = self.map_img.get_rect()
        self.camera = tilemap.Camera(self.map.width, self.map.height)

        # Temporary Player Character Images
        self.player_img_right = pygame.image.load(
            path.join(self.img_folder,
                      'player_img_right.png')).convert_alpha()
        self.player_img_left = pygame.image.load(
            path.join(self.img_folder, 'player_img_left.png')).convert_alpha()
        self.player_img_up = pygame.image.load(
            path.join(self.img_folder, 'player_img_up.png')).convert_alpha()
        self.player_img_down = pygame.image.load(
            path.join(self.img_folder, 'player_img_down.png')).convert_alpha()
Пример #6
0
    def init(self, win):

        # test if initialized, not draw before
        self.initialized = False

        # pause
        self.paused = False

        # show infoconsole
        self.infoOn = False

        # shift pressed
        self.lShift = False

        # alt pressed
        self.lAlt = False

        # mouse coordinates
        self.mouseX = 0
        self.mouseY = 0

        self.mouseViewX = 0
        self.mouseViewY = 0

        # scrolling
        self.scrollSpeed = 500
        self.scrollLeftRight = 0
        self.scrollUpDown = 0

        # cursor
        self.cursor = False
        self.cursorX = 0
        self.cursorY = 0

        # dragging
        self.drag = False
        self.dragStartX = 0
        self.dragStartY = 0
        self.dragX = 0
        self.dragY = 0

        # test paht
        self.showPath = False
        self.startPath = (0, 0)
        self.endPath = (0, 0)

        # view
        self.view = view.View(x=0, y=0, win=win, maxScale=5, minScale=0.5)

        # scale speed
        self.scaleSpeed = 0.1

        pyglet.gl.glClearColor(0.0, 0.0, 0.0, 1.0)

        self.bgBatch = pyglet.graphics.Batch()
        self.fgBatch = pyglet.graphics.Batch()

        # info console
        self.info = infoconsole.InfoConsole("", x=10, y=win.height-25, width=300)

        self.gameObjects = []

        # the map
        self.map = tilemap.Map()

        self.loadLevel()

        # now drawing is allowed
        self.initialized = True
Пример #7
0
 def load_level(self, mapname):
     self.map = tilemap.Map(path.join(self.map_folder, mapname))
     self.map_img = self.map.make_map()
     self.map_rect = self.map_img.get_rect()
     self.initialize_level()