Exemplo n.º 1
0
 def draw(self):
     for star in self.stars:
         pyxel.pix(star[0], star[1], star[2])
         star[1] += self.scroll_speed
         if star[1] > SIZE.y:
             star[1] = 0
             star[0] = randrange(0, SIZE.x, 1)
Exemplo n.º 2
0
 def display(self):
     """Sparkle the sparkles and disappear them over time."""
     for idx, particle in enumerate(self.particles):
         if pyxel.frame_count - particle["zero_frame"] >= 20:
             del self.particles[idx]
         else:
             pyxel.pix(particle["x"], particle["y"], particle["color"])
Exemplo n.º 3
0
    def draw(self):
        x, y = self.xy
        if pyxel.frame_count % self.twinkle_interval == 0:
            pyxel.circb(x, y, 1, self.color)
#            pyxel.blt(self.sprite)
        else:
            pyxel.pix(*self.xy, self.color)
Exemplo n.º 4
0
 def drawGlimmer(self):
     if (self.count == 100):
         pyxel.pix(30, pyxel.height - 20, 7)
         self.count = 0
     else:
         pyxel.pix(30, pyxel.height - 20, 3)
         self.count += 1
Exemplo n.º 5
0
 def draw(self):
     if self.property == 'NORMAL':
         pyxel.line(self.x, self.y, self.x + 3, self.y, 10)
     if self.property == 'RAPID':
         pyxel.pix(self.x, self.y, 10)
     if self.property == 'LAZER':
         pyxel.line(self.x, self.y, self.x + 100, self.y, 10)
Exemplo n.º 6
0
    def draw(self):
        pyxel.cls(0)

        arc = math.tau / self.segments

        player_seg = int(self.segments * self.player_ang / math.tau)
        for seg in range(0, self.segments):
            if player_seg == seg or ((player_seg + 1) % self.segments) == seg:
                col = 2
            else:
                col = 1
            x = W // 2 - state.cam_x
            y = H // 2 - state.cam_y
            end_x = W // 2 + math.cos(self.rotation +
                                      arc * seg) * 256 - state.cam_x
            end_y = H // 2 + math.sin(self.rotation +
                                      arc * seg) * 256 - state.cam_y
            dx = end_x - x
            dy = end_y - y

            steps = int(abs(dx) if abs(dx) > abs(dy) else abs(dy))
            xup = dx / steps
            yup = dy / steps
            for k in range(0, steps):
                if k % 4 == self.segment_line_cycle:
                    pyxel.pix(x, y, col)
                x += xup
                y += yup

        if self.segment_line_cycle_timer < 3:
            self.segment_line_cycle_timer += 1
        else:
            self.segment_line_cycle_timer = 0
            self.segment_line_cycle = (self.segment_line_cycle + 1) % 4

        for _, shape in self.shapes.each():
            shape.draw(arc, self.rotation)

        for _, p in self.particles.each():
            p.draw(state.cam_x, state.cam_y)

        vx = math.cos(self.player_ang + self.rotation)
        vy = math.sin(self.player_ang + self.rotation)
        top_x = W // 2 + vx * 14 - state.cam_x
        top_y = H // 2 + vy * 14 - state.cam_y
        left_x = W // 2 + vx * 8 + vy * 2 - state.cam_x
        left_y = H // 2 + vy * 8 - vx * 2 - state.cam_y
        right_x = W // 2 + vx * 8 - vy * 2 - state.cam_x
        right_y = H // 2 + vy * 8 + vx * 2 - state.cam_y
        pyxel.line(left_x, left_y, top_x, top_y, 8)
        pyxel.line(right_x, right_y, top_x, top_y, 8)
        pyxel.line(left_x, left_y, right_x, right_y, 8)
        pyxel.circ(W // 2 - state.cam_x, H // 2 - state.cam_y, 2, 7)

        for _, sp in self.score_particles.each():
            sp.draw(state.cam_x, state.cam_y)

        pyxel.text(5, 5, f"{self.display_score:010} pts", 7)
        pyxel.text(145, 5, f"HIGH SCORE: {state.high_score:010} pts", 7)
Exemplo n.º 7
0
    def test_pix(self, x, y):
        pyxel.text(x, y, "pix(x,y,col)", 7)

        x += 4
        y += 10

        for i in range(16):
            pyxel.pix(x + i * 2, y, i)
Exemplo n.º 8
0
 def draw(self):
     pyxel.cls(0)
     for i in range(16):
         x = i * 10
         pyxel.text(x, 10, str(i), 7)
         pyxel.pix(x, 20, i)
         pyxel.line(x, 30, x + 8, 40, i)
         pyxel.rect(x, 50, x + 8, 60, i)
         pyxel.circ(x + 4, 80, 8, i)
Exemplo n.º 9
0
 def draw(self):
     if self.chip.should_draw:
         pyxel.cls(6)
         for y, row in enumerate(self.chip.video_memory):
             for x, col in enumerate(row):
                 if col:
                     pyxel.pix(x, y + Y_OFFSET, 7)
                 else:
                     pyxel.pix(x, y + Y_OFFSET, 0)
Exemplo n.º 10
0
    def draw(self):
        pyxel.cls(pyxel.COLOR_WHITE)
        # show window
        for y in range(pyxel.height):
            for x in range(pyxel.width):
                if self.windowData[y][x]==-1:
                    pyxel.pix(x, y, pyxel.COLOR_BLACK)

        pyxel.text(0, 0, 'PREDICT: {}'.format(self.pred_digit), pyxel.COLOR_RED)
Exemplo n.º 11
0
    def draw_snake(self):
        """Draw the snake with a distinct head by iterating through deque."""

        for i, point in enumerate(self.snake):
            if i == 0:
                colour = COL_HEAD
            else:
                colour = COL_BODY
            pyxel.pix(point.x, point.y, col=colour)
Exemplo n.º 12
0
 def draw(self):
     if self.draw_flag:
         pyxel.cls(0)
         display_buffer = self.display
         for r in range(32):
             for c in range(64):
                 if display_buffer[r][c] == 1:
                     pyxel.pix(c, r, 7)
     self.draw_flag = False
Exemplo n.º 13
0
 def renderEntitiesPivot(self, camera, world):
     if (math.floor(pyxel.frame_count / 5) % 2) == 0:
         entities = list(
             world.querryEntities(camera.inflated(Vector2f(48, 64))))
         if entities != None:
             entities.sort(key=Renderer.entityKey)
             for entity in entities:
                 entityPosFromCam = entity.position - camera.position
                 pyxel.pix(entityPosFromCam.x, entityPosFromCam.y, 0)
             self.primitiveDrawn += len(entities)
Exemplo n.º 14
0
    def draw(self):
        px.cls(0)
        for pos in self.game.snake:
            if pos:
                x, y = pos
                px.pix(x=x, y=self.game.height - y - 1, col=3)

        food = self.game.food
        if food:
            px.pix(x=food[0], y=self.game.height - food[1] - 1, col=4)
Exemplo n.º 15
0
    def draw(self):
        """Draw the background, snake, score, and apple OR the end screen."""

        if not self.death:
            pyxel.cls(col=COL_BACKGROUND)
            self.draw_snake()
            self.draw_score()
            pyxel.pix(self.apple.x, self.apple.y, col=COL_APPLE)

        else:
            self.draw_death()
Exemplo n.º 16
0
    def put2(self, bgcolor=DEFAULT_BG_COLOR):
        """
        アクターを指定済みの座標に表示する
        """
        # 登録されている画像やイメージバンクの範囲の数をカウントする
        # この処理はImageLoaderで読み込まれたデータが優先される
        actions_count = len(self.pixmap) if len(self.pixmap) > 0 else len(
            self.actions)
        if (pyxel.frame_count % self.icon_action_wait == 0):
            if self.frame >= actions_count - 1:
                self.frame = 0
            else:
                self.frame += 1

        if (len(self.pixmap) > 0):
            # pixmapが空でなければImageLoaderが利用されているので優先する
            pixmap = self.pixmap[self.frame]
            x = self.position_x
            y = self.position_y
            start_x = self.position_x
            start_y = self.position_y
            color_old = 255  # 存在しない色
            pix_count = 0  # 処理したpixel数
            #print("################################# x: %s, y: %s" % (self.position_x, self.position_y))
            for color in pixmap:
                p = pix_count % (self.width)  # pix_map上のx座標
                x = self.position_x + p
                #print("p: %s, x: %s, px: %s" % (p, x, self.position_x + p))
                if (pix_count != 0 and (x == 0 or p == 0)):
                    y += 1
                    #print("pix_count %s, p: %03s, x: %s, y: %s, x2: %s, y2: %s Y+1" % (int(pix_count / self.width), p, start_x, start_y, x, y))
                    if ((y - self.position_y) > self.height
                            or y > self.window_height):
                        break

                # ボツ案: 単純にpixel単位で描画する方式だと描画回数が限界を超えて(?)表示できなくなってしまう
                if (color != bgcolor):
                    if self.wraparound == True or self.wraparound == False and x >= self.position_x:
                        pyxel.pix(x, y, color)

                color_old = color
                pix_count += 1

            # 代替案1: 最後の1ラインを描画する
            if (color_old != bgcolor):
                pyxel.line(start_x, start_y, x, y, color_old)
            #print("[+] ImageLoader: x: %s(%s), y: %s" % (x, idx / width,y))

        else:
            #print(str(len(self.actions)) + "," + str(self.frame) + ", [" + str(self.actions[self.frame][0]) + "," + str(self.actions[self.frame][1]) + "]")
            pyxel.blt(self.position_x, self.position_y, self.img_bank_index,
                      self.actions[self.frame][0], self.actions[self.frame][1],
                      self.width, self.height, DEFAULT_BG_COLOR)
Exemplo n.º 17
0
    def draw(self):
        fc=pyxel.frame_count
        if self.pallet_test==1:pal(2,3)# pallet swap - test_pal1
        if self.pallet_test==2:pal(4,7)
        if self.pallet_test==3:pal(7,10)
        _,__=cls(2),text(6,6, "cls(col)",7) #self.test_cls(6, 6)
        
        text(6, 20, "pix(x,y,col)", 7)
        for i in range(16):pix(10 + i*2, 30, i)

        text(106, 6, "line(x1,y1,x2,y2,col)", 7)
        for i in range(3):line(110, 15 + i * 8, 158, 15 + i * 8, 5+i)
        for i in range(4):line(110 + i*16, 15,110 + i * 16,31, 8+i)
        for i in range(4):line(110 + i*16, 15,110+ (3 - i) * 16,31, 12+i)
        
        text(6, 38, "rect(x,y,w,h,col)", 7)
        for i in range(8):rect(10 + i * 8, 54 - i, i + 1, i + 1, i + 8)

        text(106, 38, "rectb(x,y,w,h,col)", 7)
        for i in range(8):rectb(110+i*8,54- i, i + 1, i + 1, i + 8)

        text(6,61, "circ(x,y,r,col)", 7)
        for i in range(8):circ(10+ i * 8,76, i, i + 8)
        
        text(106, 61, "circb(x,y,r,col)", 7)
        for i in range(8):circb(110+i*8,76,i,i+8)

        text(6,88, "blt(x,y,img,u,v,\n    w,h,[colkey])", 7)
        x,y=6,103
        blt(x, y, 0, 0, 0, 16, 16)
        blt(x + math.sin(fc * 0.1) * 2 + 19, y, 0, 0, 0, 16, 16, 5)
        blt(x + 38, y, 0, 0, 0, -16, 16, 5)
        blt(x + 57, y, 0, 0, 0, 16, -16, 5)
        blt(x + 76, y, 0, 0, 0, -16, -16, 5)

        text(106, 88, "bltm(x,y,tm,u,v,\n w,h,[colkey])", 7)
        bltm(106, 103, 0, 0, 0, 11, 2, 2)

        text(6, 124, "text(x,y,s,col)",7)
        s = "Elapsed frame count is {}\n" "Current mouse position is ({},{})".format(fc,pyxel.mouse_x,pyxel.mouse_y)
        text(11,133,s,1)# shadow
        text(10,132,s,9)

        _,__=text(106, 124, "pal(col1,col2)", 4),pal()# test_pal2 

        if not self.clip_test:return
        clip()
        x,y,w,h=math.sin(fc*0.02)*39+40,math.sin(fc*0.03)*29+30,120,90
        text(x,y-8,"clip(x,y,w,h)",14)
        rectb(x-1,y-1,w+2,h+2,14)
        clip(x,y,w,h)
Exemplo n.º 18
0
    def draw(self):

        pyxel.cls(0)
        game = self.game
        walls = self.game.walls

        draw_item_ids = False
        items = game.items.copy()
        for item in items:
            item.think(pyxel.frame_count)
            self.draw_entity(item)

            if draw_item_ids:
                pyxel.text(item.top_left[0], item.top_left[1], str(item.id),
                           Colour.BLACK.value)
        del items

        npcs = game.npcs.copy()
        for npc in npcs:
            npc.think(pyxel.frame_count)
            self.draw_entity(npc)

        del npcs

        draw_wall_ids = False

        for wall in walls:
            self.draw_entity(wall)

            if draw_wall_ids:
                pyxel.text(wall.top_left[0], wall.top_left[1], str(wall.id),
                           Colour.BLACK.value)

        pyxel.text(
            40, 10,
            "score: {a} - herder speed: {b} - rabbit speed: {c}".format(
                a=game.score, b=game.player.tick_rate,
                c=game.rabbit.tick_rate), Colour.PINK.value)

        if game.game_message != "":
            pyxel.text(40, App.height / 2, self.game_message,
                       Colour.LIGHT_GREEN.value)

        self.draw_entity(game.player)

        draw_grid = False
        if draw_grid:
            grid = self.game.grid
            for point in grid.flat_pixel_positions:
                pyxel.pix(point[1], point[0], Colour.PINK.value)
Exemplo n.º 19
0
    def draw(self):
        pyxel.cls(1)
        for boid in self.boids:
            vec_o1 = round(boid.pos + boid.vel.orth.norm).as_ituple
            vec_o2 = round(boid.pos - boid.vel.orth.norm).as_ituple

            pyxel.line(*vec_o1, *vec_o2, [5, 6, 7,
                                          6][pyxel.frame_count // 3 % 4])

            vec_l1 = round(boid.pos + boid.vel.norm * 2).as_ituple
            vec_l2 = round(boid.pos - boid.vel.norm * 2).as_ituple

            pyxel.line(*vec_l1, *vec_l2, 6)
            pyxel.pix(*vec_l1, 9)
Exemplo n.º 20
0
    def draw_panel(x, y, width, height, *, with_shadow=True):
        x1 = x
        y1 = y
        x2 = x + width - 1
        y2 = y + height - 1

        pyxel.line(x1 + 1, y1, x2 - 1, y1, WIDGET_PANEL_COLOR)
        pyxel.rect(x1, y1 + 1, x2, y2 - 1, WIDGET_PANEL_COLOR)
        pyxel.line(x1 + 1, y2, x2 - 1, y2, WIDGET_PANEL_COLOR)

        if with_shadow:
            pyxel.line(x1 + 2, y2 + 1, x2, y2 + 1, WIDGET_SHADOW_COLOR)
            pyxel.line(x2 + 1, y1 + 2, x2 + 1, y2, WIDGET_SHADOW_COLOR)
            pyxel.pix(x2, y2, WIDGET_SHADOW_COLOR)
Exemplo n.º 21
0
 def draw(self):
     if self.running:
         # running - red on black
         bg = 0
         fg = 8
     else:
         # stopped - black on white
         bg = 7
         fg = 0
     pyxel.cls(bg)
     for x in range(pyxel.width):
         for y in range(pyxel.height):
             if self.grid[x][y] == 1:
                 pyxel.pix(x, y, fg)
Exemplo n.º 22
0
    def draw(self):
        # clear screen
        pyxel.cls(5)

        # draw title
        pyxel.text(60, 10, "best cat game ever", 12)

        # draw cat coordinates
        coords = "({}, {})".format(self.player_x, self.player_y)
        pyxel.text(10, 10, coords, 7)

        # draw score
        score = "score: {}".format(self.score)
        pyxel.text(150, 10, score, 7)

        # draw frame count
        frames = "frames: {}".format(pyxel.frame_count)
        pyxel.text(150, 190, frames, 7)

        # draw apples
        for location in self.random_locations:
            x, y = location[0], location[1]
            pyxel.blt(x, y, 0, 16, 0, 16, 16, 5)

        # color chart :D
        for i in range(1, 17 * 10, 10):
            pyxel.text(i, 2, "{}".format(i // 10), 2)
            for j in range(10):
                pyxel.pix(i + j, 0, i / 10)

        # draw cat
        if self.facing_left:
            m = 1
        else:
            m = -1

        if not self.eating:
            pyxel.blt(self.player_x, self.player_y, 0, 0, 0, 16 * m, 16, 5)
            self.hold_frame = pyxel.frame_count

        if self.eating:
            if self.hold_frame + self.eating_frame_count > pyxel.frame_count:
                pyxel.blt(self.player_x, self.player_y, 0, 0, 16, 16 * m, 16,
                          5)
            elif self.hold_frame + self.eating_frame_count * 2 > pyxel.frame_count:
                pyxel.blt(self.player_x, self.player_y, 0, 0, 32, 16 * m, 16,
                          5)
            else:
                self.eating = False
Exemplo n.º 23
0
    def draw(self):
        pyxel.cls(col=0)

        #Draw each cookie
        for c in self.cookies:
            pyxel.blt(c.x, c.y, BMP_COOKIE, 4, 4, 8, 8, 0)
            pyxel.pix(c.x, c.y, 11)

        #Draw number of cookies
        txt = "Score: " + str(self.score)
        pyxel.text(1, 1, txt, 3)

        #Draw santas hat
        pyxel.blt(self.hat.x, self.hat.y, BMP_HAT, 0, 7, 14, 11, 0)
        pyxel.pix(self.hat.x, self.hat.y, 11)
Exemplo n.º 24
0
	def render(self):
		global right_dragging, right_drag_x, right_drag_y
		if right_dragging:
			self.radius = sqrt((px.mouse_x-right_drag_x)**2+(px.mouse_y-right_drag_y)**2)
			px.circ(right_drag_x, right_drag_y, self.radius, self.color)
		elif left_dragging:
			px.circ(left_drag_x, left_drag_y, self.radius, self.color)
			_objs = np.array([Mass(obj.x, obj.y, obj.x_vec, obj.y_vec, obj.mass, "circle", 1) for obj in objs]+[Mass(
				x=left_drag_x+camera_x,
				y=left_drag_y+camera_y,
				x_vec=(px.mouse_x-left_drag_x)/25,
				y_vec=(px.mouse_y-left_drag_y)/25,
				mass=rtom(self.radius),
				color=8)])
			for tick in range(500):
				for self_obj in _objs:
					for other_obj in _objs:
						if other_obj == self_obj:
							continue
						try:
							self_obj.x_vec += -(4*other_obj.mass*(self_obj.x-other_obj.x))/(((self_obj.x-other_obj.x)**2+(self_obj.y-other_obj.y)**2)**(3/2))
						except ZeroDivisionError: pass
						try:
							self_obj.y_vec += -(4*other_obj.mass*(self_obj.y-other_obj.y))/(((self_obj.x-other_obj.x)**2+(self_obj.y-other_obj.y)**2)**(3/2))
						except ZeroDivisionError: pass

				for obj in _objs:
					obj.x += obj.x_vec
					obj.y += obj.y_vec

				for self_obj in _objs:
					for other_obj in _objs:
						if other_obj == self_obj:
							continue
						if sqrt((self_obj.x-other_obj.x)**2+(self_obj.y-other_obj.y)**2) < mtor(self_obj.mass)+mtor(other_obj.mass):
							#px.circb(self_obj.x-camera_x, self_obj.y-camera_y, mtor(self_obj.mass), self_obj.color)
							#px.circb(other_obj.x-camera_x, other_obj.y-camera_y, mtor(other_obj.mass), other_obj.color)
							other_obj.x_vec = other_obj.mass/(other_obj.mass+self_obj.mass) * other_obj.x_vec + self_obj.mass/(other_obj.mass+self_obj.mass) * self_obj.x_vec	
							other_obj.y_vec = other_obj.mass/(other_obj.mass+self_obj.mass) * other_obj.y_vec + self_obj.mass/(other_obj.mass+self_obj.mass) * self_obj.y_vec	
							other_obj.x = other_obj.mass/(other_obj.mass+self_obj.mass) * other_obj.x + self_obj.mass/(other_obj.mass+self_obj.mass) * self_obj.x	
							other_obj.y = other_obj.mass/(other_obj.mass+self_obj.mass) * other_obj.y + self_obj.mass/(other_obj.mass+self_obj.mass) * self_obj.y	
							other_obj.mass += self_obj.mass
							px.circb(other_obj.x-camera_x, other_obj.y-camera_y, mtor(other_obj.mass), other_obj.color)
							_objs = np.delete(_objs, np.where(_objs == self_obj), 0)
				for obj in _objs:
					px.pix(obj.x-camera_x, obj.y-camera_y, obj.color)
		else:
			px.circb(px.mouse_x, px.mouse_y, self.radius, self.color)
Exemplo n.º 25
0
    def draw(self):

        pyxel.cls(col=0)
        for star in self.stars:
            pyxel.pix(star.x, star.y, col=6)

        pyxel.blt(x=self.driftx,
                  y=self.drifty,
                  img=0,
                  sx=0,
                  sy=0,
                  w=WIDTH,
                  h=HEIGHT,
                  colkey=11)

        pyxel.blt(x=0, y=0, img=1, sx=0, sy=0, w=WIDTH, h=HEIGHT, colkey=11)
Exemplo n.º 26
0
 def draw(self, state):
     offx, offy = 48, 48
     pyxel.rect(offx - 5, offy - 5, 42, 42, 7)
     pyxel.rect(offx - 4, offy - 4, 40, 40, 0)
     pyxel.rect(offx - 2, offy - 2, 36, 36, 5)
     for x, y in state.visited:
         col = 7
         v = state.board.get(x, y)
         if is_door(v):
             col = 8 if is_locked(v) else 4
         elif is_wall(v):
             col = 1
         elif is_active_tile(v):
             col = 12
         pyxel.pix(offx + x, offy + y, col)
     x, y = state.player.pos
     pyxel.pix(offx + x, offy + y, 11)
Exemplo n.º 27
0
    def draw(self):
        pyxel.cls(0)
        # m_pos = (
        #     (pyxel.mouse_x - self._game.PYXEL_WIDTH_CENTER) * 0.01,
        #     (pyxel.mouse_y - self._game.PYXEL_HEIGHT_CENTER) * 0.01
        # )

        for position in self.particles:
            x, y, z = position
            # x += m_pos[0] / (z * 10)
            # y += m_pos[1] / (z * 10)

            pyxel.pix(int(x), int(y), self.particles_color + (6-z))

        if pyxel.frame_count // 30 % 2:
            pyxel.text(*self.text_pos, self.text, self.text_color)
        if pyxel.frame_count % 30 == 29:
            self.text_color = (self.text_color + 1) % 15 + 1
Exemplo n.º 28
0
    def draw(self):
        pyxel.cls(0)

        # パドルの描画
        pyxel.rect(self.paddle_x, self.paddle_y, PADDLE_WIDTH, PADDLE_HEIGHT,
                   1)

        # ブロックの描画
        block_index = 0
        for row in range(BLOCK_ROW):
            for col in range(BLOCK_COL):
                if self.blocks[block_index]:
                    pyxel.rect(col * (BLOCK_WIDTH + 5),
                               row * (BLOCK_HEIGHT + 5), BLOCK_WIDTH,
                               BLOCK_HEIGHT, 3)
                block_index += 1

        # ボールの描画
        pyxel.pix(self.ball_x, self.ball_y, 10)
Exemplo n.º 29
0
    def draw(self):
        # 画面のクリア
        pyxel.cls(1)

        # 描画テスト
        for i in range(10):
            # 矩形
            pyxel.rectb(
                random.randrange(0, pyxel.width),
                random.randrange(0, pyxel.height),
                random.randrange(0, pyxel.width),
                random.randrange(0, pyxel.height),
                random.randrange(0, 16))

            # 線
            pyxel.line(
                random.randrange(0, pyxel.width),
                random.randrange(0, pyxel.height),
                random.randrange(0, pyxel.width),
                random.randrange(0, pyxel.height),
                random.randrange(0, 16))

            # 点
            pyxel.pix(
                random.randrange(0, pyxel.width),
                random.randrange(0, pyxel.height),
                random.randrange(0, 16))

            # 円
            pyxel.circb(
                random.randrange(0, pyxel.width),
                random.randrange(0, pyxel.height),
                random.randrange(0, 16),
                random.randrange(0, 16))

            # パレットの入れ替え
            pyxel.pal(random.randrange(0, 16), random.randrange(0, 16))

        # 画像の描画
        pyxel.blt((pyxel.width - self.cat['width']) / 2, (pyxel.height - self.cat['height']) / 2, 0, 0, 0, self.cat['width'], self.cat['height'])

        # パレットを戻す
        pyxel.pal()
Exemplo n.º 30
0
 def update(self):
     x_base = (self.block_index // self.block_width) * BLOCK_SIZE
     y_base = (self.block_index % self.block_width) * BLOCK_SIZE
     for _x in range(BLOCK_SIZE):
         for _y in range(BLOCK_SIZE):
             x = x_base + _x
             y = y_base + _y
             if x >= SIZE or y >= SIZE:
                 break
             r = self.r[x * SIZE + y]
             i = self.i[x * SIZE + y]
             if r**2 + i**2 > 4:
                 continue
             cr = x * 4 / SIZE - 2
             ci = y * 4 / SIZE - 2
             nr = self.r[x * SIZE + y] = r * r - i * i + cr
             ni = self.i[x * SIZE + y] = 2 * r * i + ci
             if nr**2 + ni**2 > 4:
                 pyxel.pix(x, y, (self.color + 1) % 16)
     self.block_index += 1
     if self.block_index >= self.block_width * self.block_width:
         self.color += 1
         self.block_index -= (self.block_width * self.block_width)