Beispiel #1
1
 def is_empty(self, x, y):
     if pyxel.tilemap(0).get(
             x // 8,
             y // 8) == 0 or pyxel.tilemap(0).get(x // 8, y // 8) >= 32:
         return True
     else:
         return False
Beispiel #2
0
    def checkColisions(self):
        #TAIL
        for s in self.snake:
            if s == self.snake[0]: continue
            if self.isColliding(s) == True:
                self.currentGameState = GameState.GAMEOVER
                self.playSound("explosion")
                
        #COIN

        checkPositionCoin = False

        for s in self.snake:
            
            if s == self.snake[0]: 
                if self.coin.IsColliding(s):
                    self.addSection()
                    self.coin.randomPosition() 
                    checkPositionCoin = True
                    self.snakeSpeed += (self.snakeSpeed * 0.01)
                    self.playSound("coin")
                    
        if (self.coin.IsColliding(s) and checkPositionCoin) or (pyxel.tilemap(0).get((self.coin.x/8), (self.coin.y/8))==33):
            self.coin.randomPosition()
            
            
        #WALL
        
        if pyxel.tilemap(0).get((self.snake[0].x/8), (self.snake[0].y/8))==33:
            self.currentGameState = GameState.GAMEOVER
            self.playSound("explosion")
Beispiel #3
0
    def put(self, x, y, t, a, s, test):
      for j in range(4):
        for i in range(4):
          p = [ i, 3 - j, 3 - i, j]
          q = [ j, i, 3  - j, 3 - i]

          # on sept tiles differents
          # mais ici 7 c'est la noir
          if pyxel.tilemap(0).get(17 + t * 4 + p[a], q[a]) == NOIR:
            continue
          #pdb.set_trace() 
          v = t
          # もし s == false 消えます
          if s == False:
            v = NOIR 

          # si c'est pas pixel noir; dans notre pyxres pixel noir est definé comme
          # si c'est pas la noir on a touche une autre piece ou le zid
          # 7
          elif pyxel.tilemap(0).get( x + i, y + j) != NOIR:
            return False
          # si on ne deboug pas
          '''
            set(x, y, data)
            (x, y) に値または文字列のリストでイメージのデータを設定する
            例:pyxel.image(0).set(10, 10, ["1234", "5678", "9abc", "defg"])
          '''
          if test == False:
            pyxel.tilemap(0).set( x + i, y + j, v)
      return True
Beispiel #4
0
    def update(self):
        super().update()
        if pyxel.btnp(pyxel.KEY_R):
            self.selected_item.get_sprite(1)
        elif pyxel.btnp(pyxel.KEY_A):
            self.selected_item.get_sprite(-1)
        elif pyxel.btnp(pyxel.KEY_E):
            self.selected_item.get_sprite(1)

        if pyxel.btnp(pyxel.KEY_1):
            self.selected_item.set_type("simple_arrow")
        elif pyxel.btnp(pyxel.KEY_2):
            self.selected_item.set_type("double_arrow")
        elif pyxel.btnp(pyxel.KEY_2):
            self.selected_item.set_type("pusher")
        if pyxel.btnp(pyxel.MOUSE_LEFT_BUTTON):
            # print(pyxel.tilemap(0).get())
            # pyxel.tilemap(0).set(pyxel.mouse_x//8, pyxel.mouse_y//8, 2)
            # print(*self.selected_item.get_timemap_index(), pyxel.tilemap(0).get(0,0))
            # test = self.selected_item.get_timemap_index()
            test = (16,16)
            print( pyxel.image(0).get(test[0], test[1]) )
            print(pyxel.tilemap(0).refimg)
            pyxel.tilemap(0).set( pyxel.mouse_x//8, pyxel.mouse_y//8, pyxel.image(0).get(test[0], test[1]) )
            
        update_list(self.slot)
Beispiel #5
0
    def __on_mouse_down(self, key, x, y):
        if key != pyxel.KEY_LEFT_BUTTON:
            return

        (x, y) = self._screen_to_view(x, y)

        self._press_x = x
        self._press_y = y

        self._is_dragged = True
        self._is_assist_mode = False

        if self.parent.tool == TOOL_SELECT:
            self._select_x1 = self._select_x2 = x
            self._select_y1 = self._select_y2 = y
        elif self.parent.tool >= TOOL_PENCIL and self.parent.tool <= TOOL_CIRC:
            self._overlay_canvas.pix(x, y, self.parent.color)
        elif self.parent.tool == TOOL_BUCKET:
            if self._is_tilemap_mode:
                dest = pyxel.tilemap(
                    self.parent.tilemap).data[self.viewport_y:self.viewport_y +
                                              16,
                                              self.viewport_x:self.viewport_x +
                                              16, ]

                data = {}
                data["tilemap"] = self.parent.tilemap
                data["pos"] = (self.viewport_x, self.viewport_y)
                data["before"] = dest.copy()

                dest = pyxel.tilemap(
                    self.parent.tilemap).data[self.viewport_y:self.viewport_y +
                                              16,
                                              self.viewport_x:self.viewport_x +
                                              16, ]
            else:
                dest = pyxel.image(
                    self.parent.image).data[self.viewport_y:self.viewport_y +
                                            16,
                                            self.viewport_x:self.viewport_x +
                                            16, ]

                data = {}
                data["image"] = self.parent.image
                data["pos"] = (self.viewport_x, self.viewport_y)
                data["before"] = dest.copy()

                dest = pyxel.image(
                    self.parent.image).data[self.viewport_y:self.viewport_y +
                                            16,
                                            self.viewport_x:self.viewport_x +
                                            16, ]

            self._overlay_canvas.paint(x, y, self.parent.color, dest)

            data["after"] = dest.copy()
            self.parent.add_edit_history(data)

        self._last_x = x
        self._last_y = y
Beispiel #6
0
    def update(self):  # ゲーム内情報更新、キー入力処理
        if btnp(KEY_Q): quit()  # qキーで終了
        if self.pacman.P[0] % 8 == 0 and self.pacman.P[1] % 8 == 0:  # 移動判定
            if self.tilemap_state.get(
                    self.pacman.T[0] + self.pacman.V[0], self.pacman.T[1] +
                    self.pacman.V[1]) == 33:  # 進行方向を確認 壁に行こうとしてたら
                self.pacman.V[0] = self.pacman.V[1] = 0  # stop
            elif btn(KEY_W) and self.tilemap_state.get(
                    self.pacman.T[0], self.pacman.T[1] - 1) != 33:
                self.pacman.V = [0, -1]  # 上に行くように設定
            elif btn(KEY_S) and self.tilemap_state.get(
                    self.pacman.T[0], self.pacman.T[1] + 1) != 33:
                self.pacman.V = [0, 1]  # 描画する向きを下に設定
            elif btn(KEY_D) and self.tilemap_state.get(self.pacman.T[0] + 1,
                                                       self.pacman.T[1]) != 33:
                self.pacman.V = [1, 0]  # 描画する向きを右に設定
            elif btn(KEY_A) and self.tilemap_state.get(self.pacman.T[0] - 1,
                                                       self.pacman.T[1]) != 33:
                self.pacman.V = [-1, 0]  # 描画する向きを左に設定

            self.pacman.T = [
                x + y for x, y in zip(self.pacman.T, self.pacman.V)
            ]  # タイルの座標を進行方向に合わせて変える

        self.pacman.P = [x + y for x, y in zip(self.pacman.P, self.pacman.V)
                         ]  # 毎フレーム毎に描画する座標を変更していく

        # clear tile
        current_tile = self.tilemap_state.get(self.pacman.T[0],
                                              self.pacman.T[1])
        if current_tile == 64: self.pacman.score += 10  # ノーマルクッキーに触れたら
        if current_tile == 65: self.pacman.score += 50  # パワークッキーに触れたら
        pyxel.tilemap(0).set(self.pacman.T[0], self.pacman.T[1],
                             5)  # パックマン後は、何もないブロックに変える
Beispiel #7
0
    def collision_detection(self,tile_x,tile_y,direction):
        global IS_MODE_TERMINATE
        if IS_MODE_TERMINATE == 0:
            if direction == "r":
                add_num = (2,0)
            elif direction == "d":
                add_num = (0,2)
            if direction == "l":
                add_num = (-2,0)
            elif direction == "u":
                add_num = (0,-2)

            if pyxel.tilemap(0).get(tile_x/8 + add_num[0], tile_y/8 + add_num[1]) == self.dead_tile:
                IS_MODE_TERMINATE = 1

            # ----- To debug.
            # print(pyxel.tilemap(0).get(tile_x/8 + add_num[0], tile_y/8 + add_num[1]))# show img pallet code.

            if pyxel.tilemap(0).get(tile_x/8 + add_num[0], tile_y/8 + add_num[1]) not in self.cant_go and\
            pyxel.tilemap(0).get(tile_x/8+ add_num[0] +1, tile_y/8 + add_num[1]) not in self.cant_go and\
            pyxel.tilemap(0).get(tile_x/8+ add_num[0], tile_y/8 + add_num[1] +1) not in self.cant_go and\
            pyxel.tilemap(0).get(tile_x/8+ add_num[0] +1, tile_y/8 + add_num[1] +1) not in self.cant_go:
                return True
            else:
                # print("CantGo")

                pyxel.play(2,10, loop=False)
                return False
Beispiel #8
0
def collide_map(x: float, y: float, w: int, h: int) -> tuple[bool, bool]:
    collide = False
    harm = False
    x = math.floor(x)
    y = math.floor(y)
    i = x
    while i < x + w:
        current_tiles = [
            pyxel.tilemap(0).get(i / 8, y / 8),
            pyxel.tilemap(0).get(i / 8, (y + h) / 8)
        ]
        for tile in current_tiles:
            if tile in solid_tiles:
                collide = True
            if tile in harmful_tiles:
                harm = True
        i += 1

    i = y
    while i < y + h:
        current_tiles = [
            pyxel.tilemap(0).get(x / 8, i / 8),
            pyxel.tilemap(0).get((x + w) / 8, i / 8)
        ]
        for tile in current_tiles:
            if tile in solid_tiles:
                collide = True
            if tile in harmful_tiles:
                harm = True
        i += 1

    return collide, harm
Beispiel #9
0
def place_objects(obj_type: int) -> list[tuple[int, int]]:
    coords = []
    for x in range(MAP_WIDTH):
        for y in range(MAP_HEIGHT):
            if pyxel.tilemap(0).get(x, y) == obj_type:
                coords.append((x, y))
                pyxel.tilemap(0).set(x, y, BACK_WALL)
    return coords
Beispiel #10
0
def put_tile(layer_id, tile_id, position):
    '''Put a "16 pixel sized" tiled into a "8 pixel sized" tilemap'''
    assert_valid_tilemap_bank(layer_id)
    x = (tile_id % TILES_PER_ROW) * 2
    y = int(tile_id / TILES_PER_ROW) * 2
    for y_ofs in [0, 1]:
        for x_ofs in [0, 1]:
            cell_id = ((y + y_ofs) * CELLS_PER_ROW) + (x + x_ofs)
            pyxel.tilemap(layer_id).set(position[0] + x_ofs, position[1] + y_ofs, cell_id)
Beispiel #11
0
 def __init__(self):
     init(256, 256, caption="Pyxel Draw API",scale=1)
     image(0).load(0, 0, "assets/cat_16x16.png")
     image(1).load(0, 0, "assets/tileset_24x32.png")
     tilemap(0).set( 0,0, ["022000002004001000060061062000040", "042003020021022003000001002003060"],)
     tilemap(0).refimg = 1
     self.pallet_test=0
     self.clip_test =0
     mouse(1)
     run(self.update, self.draw)
Beispiel #12
0
    def wait(self):
      self.mWait -= 1
      if self.mWait == 0:
        self.next()

      if self.mWait == WAIT / 2 - 1:
        for y in range(22, 2, -1):
          n = 0
          for x in range(2, 12):
            if pyxel.tilemap(0).get(x, y) < NOIR:
              n += 1

          if n != 10:
            continue
          
          # n == 10 それでラインを消えます
          self.score += 10
          #pyxel.playm(1, loop=False)
          #self.musique = 0

          for x in range(2, 12):
            pyxel.tilemap(0).set(x, y, 10)

      if self.mWait == 1:
        for y in range(22, 2, -1):
          while pyxel.tilemap(0).get(2, y) == 10:
            self.mWait = WAIT / 2 - 2
            for i in range(y, 3, -1):
              for x in range(2, 12):
                pyxel.tilemap(0).set(x, i, pyxel.tilemap(0).get(x, i - 1))
            for x in range(2, 12):
              pyxel.tilemap(0).set(x, 3, 7)
Beispiel #13
0
 def update_tilemap(self):
     # ノーマルクッキーはスコア30点追加
     # パワークッキーはスコア100点追加
     # ノーマルクッキーに触れたら
     if self.tilemap_state.get(self.pacman.tile_x,self.pacman.tile_y) == 65:
         self.pacman.score += 30
     # パワークッキーに触れたら
     elif self.tilemap_state.get(self.pacman.tile_x,self.pacman.tile_y) == 64:
         self.pacman.score += 100
     # パックマンがノーマルクッキーとパワークッキーを踏んだら、何もないブロックに変える
     pyxel.tilemap(0).set(self.pacman.tile_x,self.pacman.tile_y,5,refimg=0)
Beispiel #14
0
    def __init__(self):
        pyxel.init(200, 150, caption="Pyxel Draw API")

        pyxel.image(0).load(0, 0, "assets/cat_16x16.png")
        pyxel.image(1).load(0, 0, "assets/tileset_24x32.png")

        pyxel.tilemap(0).set(0, 0, ["2200020401006061620040", "4203202122030001020360"])

        self.pal_test_is_enabled = False
        self.clip_test_is_enabled = False

        pyxel.run(self.update, self.draw)
Beispiel #15
0
def _generate_tilemap_and_thumbnail(preprocessed_level: _PreprocessedLevel,
                                    level_theme: LevelTheme) -> None:
    thumbnails_image = pyxel.image(LEVEL_THUMBNAIL_IMAGE_BANK)
    tile_positions = preprocessed_level.tile_positions()
    for level_pos, tilemap_pos in tile_positions:
        tile = preprocessed_level.get_tile_at(level_pos)
        thumbnails_image.set(tilemap_pos.x, tilemap_pos.y, level_theme.thumbnail_color(tile))

        if tile is not Tile.VOID:
            for layer in range(level_theme.num_layers):
                tile_id = level_theme.tile_id(layer, tile)
                pyxel.tilemap(layer).set(tilemap_pos.x, tilemap_pos.y, tile_id)
Beispiel #16
0
    def make_stage(self):
        self.block = Block(0, 0, self.width, self.height)
        for _ in range(Block.MAX_NUM):
            self.block.divide()
        self.block.make_room()
        self.block.make_path()

        self.data = numpy.zeros((self.width, self.height), dtype=int)

        # room の追加
        for room in self.block.rooms():
            for i in range(room.x, room.x + room.width):
                for j in range(room.y, room.y + room.height):
                    self.data[i, j] = 1

        # aisle の追加
        for s, t in self.block.paths():
            x1 = min(s[0], t[0])
            x2 = max(s[0], t[0])
            y1 = min(s[1], t[1])
            y2 = max(s[1], t[1])
            for i in range(x1, x2 + 1):
                for j in range(y1, y2 + 1):
                    self.data[i, j] = 1

        self.make_map()
        for i in range(self.width):
            for j in range(self.height):
                t1, t2, t3, t4 = Stage.tile_num[self.tile[i][j]]
                pyxel.tilemap(0).set(j * 2, i * 2, t1)
                pyxel.tilemap(0).set(j * 2 + 1, i * 2, t2)
                pyxel.tilemap(0).set(j * 2, i * 2 + 1, t3)
                pyxel.tilemap(0).set(j * 2 + 1, i * 2 + 1, t4)

        Stage.stair_x, Stage.stair_y = self.choice_room_point()
Beispiel #17
0
    def generate_tilemap(self, tilemap_id: int, tilemap_rect: Rect, seed: int) -> None:
        """Generate a tilemap using random tiles at given position in Pyxel's mega-tilemap.

        Tiles are randomized using specified seed and tiles weights.

        :param tilemap_id: Pyxel's mega-tilemap id
        :param tilemap_rect: tilemap rect where generated tiles will be put into
        :param seed: seed to be used during tiles generation
        """
        state = random.getstate()
        random.seed(seed)
        tilemap_points = tilemap_rect.inside_points()
        for point in tilemap_points:
            pyxel.tilemap(tilemap_id).set(point.x, point.y, self._next_tile())
        random.setstate(state)
Beispiel #18
0
    def __init__(self, stage):
        gcommon.ObjMgr.init()
        gcommon.ObjMgr.myShip = MyShip()
        gcommon.cur_scroll = 0.4
        self.story_pos = 0
        self.stage = stage
        self.mapOffsetX = 0
        self.star_pos = 0
        self.star_ary = []
        self.pause = False
        gcommon.game_timer = gcommon.START_GAME_TIMER
        gcommon.map_y = gcommon.cur_scroll * gcommon.game_timer
        self.initStory()
        if self.stage == 1:
            pyxel.image(1).load(0, 0, "assets/gra-den1.png")
            self.mapOffsetX = 0
            gcommon.draw_star = False
        elif self.stage == 2:
            pyxel.image(1).load(0, 0, "assets/gra-den2.png")
            self.mapOffsetX = 32
            gcommon.draw_star = False
        elif self.stage == 3:
            pyxel.image(1).load(0, 0, "assets/gra-den3a.png")
            pyxel.image(2).load(0, 0, "assets/gra-den3b.png")
            self.mapOffsetX = 64
            gcommon.draw_star = True
        pyxel.tilemap(0).refimg = 1

        for i in range(0, 128):
            o = [
                int(random.randrange(0, 256)),
                int(random.randrange(0, 2) + 5)
            ]
            self.star_ary.append(o)
Beispiel #19
0
 def __init__(self, x, y, tm, type=None):
     self.x = self.ix = x + 3
     self.y = self.iy = y + 4
     self.vx = self.vy = self.angle = 0
     self._is_shoot = self._has_hit = False
     self.g = 0.08
     self.tm = pyxel.tilemap(0)
Beispiel #20
0
 def __init__(self):
     init(128, 140, caption="pacman-ish", fps=25, scale=2)
     load('pacman.pyxres')
     self.pacman = Pacman()  #################  抜けてた!
     self.tilemap_state = tilemap(
         0)  #################  抜けてた! 超重要!!! 偶然でも、よく見つけたな俺
     run(self.update, self.draw)  # 毎フレーム毎にupdateとdrawを呼び出す
Beispiel #21
0
    def __init__(self, parent):
        super().__init__(parent)

        self._drawing_panel = DrawingPanel(self, is_tilemap_mode=True)
        self._tilemap_panel = TilemapPanel(self)
        self._image_panel = ImagePanel(self, is_tilemap_mode=True)
        self._tilemap_picker = NumberPicker(self, 48, 161, 0,
                                            TILEMAP_BANK_COUNT - 1, 0)
        self._tool_button = RadioButton(self, 81, 161, 3, EDITOR_IMAGE_X + 63,
                                        EDITOR_IMAGE_Y, 7, TOOL_PENCIL)
        self._image_picker = NumberPicker(
            self,
            192,
            161,
            0,
            IMAGE_BANK_COUNT - 2,
            pyxel.tilemap(self._tilemap_picker.value).refimg,
        )

        self.add_event_handler("undo", self.__on_undo)
        self.add_event_handler("redo", self.__on_redo)
        self.add_event_handler("update", self.__on_update)
        self.add_event_handler("draw", self.__on_draw)
        self._tilemap_picker.add_event_handler("change",
                                               self.__on_tilemap_picker_change)
        self._image_picker.add_event_handler("change",
                                             self.__on_image_picker_change)
        self.add_number_picker_help(self._tilemap_picker)
        self.add_number_picker_help(self._image_picker)
        self.add_tool_button_help(self._tool_button)
Beispiel #22
0
 def check_collisions(self):
     # Apple
     if self.apple.intersects(self.snake[0].x, self.snake[0].y,
                              self.snake[0].w, self.snake[0].h):
         pyxel.play(
             3, 0)  # Play sound track 0 on channel 3 - Apple pickup sound
         self.speed += (self.speed * 0.1)
         self.sections_to_add += 4
         self.move_apple()
         self.apples_eaten_total += 1
         self.apples_eaten_this_level += 1
     # Snake Tail
     for s in self.snake:
         if s == self.snake[0]:
             continue
         if s.intersects(self.snake[0].x, self.snake[0].y, self.snake[0].w,
                         self.snake[0].h):
             pyxel.stop()
             pyxel.play(3,
                        1)  # Play sound track 1 on channel 3 - Crash sound
             self.current_game_state = GameState.GAME_OVER
     # Wall
     if pyxel.tilemap(0).get(self.snake[0].x / 8, self.snake[0].y / 8) == 3:
         pyxel.stop()
         pyxel.play(3, 1)  # Play sound track 1 on channel 3 - Crash sound
         self.current_game_state = GameState.GAME_OVER
Beispiel #23
0
 def get_tile_angle(self, x, y): # x,y is screen pixels.
     tile = pyxel.tilemap(self.tm).get(
         self.tmu + math.floor((x-8)/8), 
         self.tmv + math.floor((y-16)/8)
     )
     
     if tile in SLOPE_TILES:
         # check if triangle matrix collision check needed.
         if SLOPE_TILES[tile][1] is not None:
             t = SLOPE_TILES[tile]
             
             tx = math.floor(abs(x - math.floor(x/8)*8))
             ty = math.floor(abs(y - math.floor(y/8)*8))
             
             #print("Checking matrix x,y: {a},{b} ...".format(a=tx, b=ty))
             
             if constants.is_colliding_matrix(tx, ty, t[1]):
                 #print("{a}, {b} hit triangle".format(a=x, b=y))
                 #print("... collides.")
                 return t[0]
             else:
                 #print("... no collision.")
                 return None
         else:
             return SLOPE_TILES[tile][0]
     else:
         return None
Beispiel #24
0
    def __on_mouse_down(self, key, x, y):
        if key != pyxel.MOUSE_LEFT_BUTTON:
            return

        x, y = self._screen_to_view(x, y)

        self._press_x = x
        self._press_y = y

        self._is_dragged = True
        self._is_assist_mode = False

        if self.parent.tool == TOOL_SELECT:
            self._select_x1 = self._select_x2 = x
            self._select_y1 = self._select_y2 = y
        elif self.parent.tool == TOOL_PENCIL:
            self._overlay_canvas.pix(x, y, self.parent.color)
        elif self.parent.tool >= TOOL_RECTB and self.parent.tool <= TOOL_CIRC:
            self._overlay_canvas.rect(x, y, x, y, self.parent.color, False)
        elif self.parent.tool == TOOL_BUCKET:
            data = (pyxel.tilemap(self.parent.tilemap).data
                    if self._is_tilemap_mode else pyxel.image(
                        self.parent.image).data)
            dest = data[self.viewport_y:self.viewport_y + 16,
                        self.viewport_x:self.viewport_x + 16, ]

            self._add_pre_history(dest)

            self._overlay_canvas.fill(x, y, self.parent.color, dest)

            self._add_post_history(dest)

        self._last_x = x
        self._last_y = y
Beispiel #25
0
    def __init__(self):
        pyxel.init(52, 80, caption='Halloween Playing Game')

        self.gameover = False

        self.w = pyxel.width
        self.h = pyxel.height

        resources.images()

        resources.tilemap()
        pyxel.tilemap(0).refimg = 0

        resources.music()

        # Characters informations
        characters.skeleton(self)
        self.hh = 1
        characters.shadow(self)
        characters.kids(self)

        resources.ui(self)

        self.heart = {'three': [1, 1, 1], 'two': [1, 1, 0], 'one': [0, 0, 0]}

        play_music(True, True, True)

        pyxel.run(self.update, self.draw)
Beispiel #26
0
 def __init__(self):
     gcommon.map_y = 0
     self.cnt = 0
     pyxel.image(1).load(0, 0, "assets/title.png")
     pyxel.tilemap(0).refimg = 1
     self.menuPos = 0
     self.timer = 0
     # 0 - タイトルデモ
     # 100 メニュー選択
     # 200 ゲーム開始
     self.state = 0
     self.star_pos = 0
     self.subState = 0
     self.subCnt = 0
     self.rnd = gcommon.ClassicRand()
     self.py = 0
     self.ey = 24
     self.cntLimit = 70
     self.objs = []
     self.difficulty = Settings.difficulty
     self.credits = Settings.credits
     self.mouseManager = MouseManager()
     self.menuRects = []
     for i in range(5):
         self.menuRects.append(
             gcommon.Rect.create(48, __class__.menu_top_y - 2 + i * 15,
                                 48 + 160 - 1, __class__.menu_top_y - 2 +
                                 i * 15 + 12 - 1))
     self.difficultyRects = [
         gcommon.Rect.createWH(128 - 8 - 48 - 4, 120, 8, 8),
         gcommon.Rect.createWH(128 + 48 + 4, 120, 8, 8),
     ]
Beispiel #27
0
    def get_blocks(self):
        blocks = []

        tile_keys = globs.tiles.data.keys()

        rows = globs.config.height // self.tilesize
        cols = globs.config.width // self.tilesize

        for row in range(rows):
            for col in range(cols):
                tile_id = str(pyxel.tilemap(self.index).get(self.offsetx + col, self.offsety + row))

                if tile_id in tile_keys:
                    tile_data = globs.tiles.data[tile_id]
                    x = col * self.tilesize
                    y = row * self.tilesize
                    w = 8
                    h = 8

                    if type(tile_data) is dict:
                        w = tile_data['hitbox_w']
                        h = tile_data['hitbox_h']

                    blocks.append(Entity(x, y, w, h))

        return blocks
Beispiel #28
0
 def __on_update(self):
     start_y = (pyxel.frame_count % 8) * 8
     for y in range(start_y, start_y + 8):
         for x in range(64):
             val = pyxel.tilemap(self.tilemap).data[y * 4 + 1, x * 4 + 1]
             col = pyxel.image(self.image).data[(val // 32) * 8 + 3,
                                                (val % 32) * 8 + 3]
             pyxel.image(3, system=True).data[y + 192, x] = col
Beispiel #29
0
 def reset(self):
     pyxel.load("assets/my_resource.pyxres")
     self.fade_in = 30
     self.camera = Thing("camera", 0, 0)
     self.sprites = []
     self.colliders = []
     self.tilemap = pyxel.tilemap(0)
     self.scan_map()
Beispiel #30
0
 def __init__(self):
     pyxel.init(200, 150, title="Pyxel Draw API")
     pyxel.mouse(True)
     pyxel.image(0).load(0, 0, "assets/cat_16x16.png")
     pyxel.image(1).load(0, 0, "assets/tileset_24x32.png")
     pyxel.tilemap(0).set(
         0,
         0,
         [
             "0201 0000 0200 0400 0100 0000 0003 0103 0203 0000 0002",
             "0202 0300 0001 0101 0201 0300 0000 0100 0200 0300 0003",
         ],
     )
     pyxel.tilemap(0).image = pyxel.image(1)
     self.pal_test_is_enabled = False
     self.clip_test_is_enabled = False
     pyxel.run(self.update, self.draw)