0

So far with my map I have gotten to blitting the tiles and getting collisions with them. But the thing is my map doesn't work with my previous camera setup, so I have to turn it off to see my player on the tiles. Basically whats happening is that the map that I'm loading is visible, and I can collide with it, the problem is that the images aren't moving with the rects. I have tried to offset my tiles in the code, but no effect takes place. I am also using a very unusual method of blitting the tiles:

class Level_1():

    def __init__(self, surface, tile_rects):
        # properties
        self.display = surface
        self.tile_rects = tile_rects
        self.tmx_data = load_pygame('data/levels/level_1.tmx')
        true_scroll = [0,0]

        # layers
        self.terrain = self.tmx_data.get_layer_by_name('terrain')
        self.coins = self.tmx_data.get_layer_by_name('coins')
        self.grass = self.tmx_data.get_layer_by_name('grass')
        self.rocks = self.tmx_data.get_layer_by_name('rocks')
        self.start = self.tmx_data.get_layer_by_name('start')

    # loads terrain layer ----------------------------------
    def load_terrain(self):
        for x, y, surf in self.terrain.tiles():
            self.tile = Tile(surf, (x * TILESIZE, y * TILESIZE))
            self.tile_rects.append(self.tile.rect)
            self.display.blit(self.tile.image, self.tile.position)


    # loads coins layer ------------------------------------
    def load_coins(self):
        for x, y, surf in self.coins.tiles():
            self.tile = Tile(surf, (x * TILESIZE, y * TILESIZE))
            self.display.blit(self.tile.image, self.tile.position)      

    # loads grass layer ------------------------------------
    def load_grass(self):
        for x, y, surf in self.grass.tiles():
            self.tile = Tile(surf, (x * TILESIZE, y * TILESIZE))
            self.display.blit(self.tile.image, self.tile.position)      

    # loads rocks layer ------------------------------------
    def load_rocks(self):
        for x, y, surf in self.rocks.tiles():
            self.tile = Tile(surf, (x * TILESIZE, y * TILESIZE))
            self.display.blit(self.tile.image, self.tile.position)



    def run(self):
        # runs level 1 -------------------------------------
        self.load_terrain()
        self.load_rocks()
        self.load_grass()
        self.load_coins()

I then import this class into my main file and just do:

level = Level_1(display, tile_rects)
level.run

I do the latter in the main loop. I am using DaFluffyPotato's tutorial.

Quantum
  • 21
  • 3

0 Answers0