Beispiel #1
0
 def hungryCat(self):
     if (self.count < 200):
         pyxel.rect(40, 40, 120, 65, 7)
         pyxel.rectb(40, 40, 120, 65, 0)
         pyxel.text(44, 45, "You hear pained", 0)
         pyxel.text(44, 55, "yollowing inside!", 0)
         self.count += 1
Beispiel #2
0
    def draw(self):
        pyxel.cls(1)

        pyxel.text(6, 6, 'sound(snd).set(note,tone,volume,effect,speed)', 7)
        pyxel.rect(12, 16, 188, 52, 2)
        pyxel.text(16, 20, 'note  :[CDEFGAB] + [ #-] + [0-4] or [R]', 9)
        pyxel.text(16, 28, 'tone  :[T]riangle [S]quare [P]ulse [N]oise', 9)
        pyxel.text(16, 36, 'volume:[0-7]', 9)
        pyxel.text(16, 44, 'effect:[N]one [S]lide [V]ibrato [F]adeOut', 9)

        pyxel.text(6, 62, 'play(ch,snd,loop=False)', 7)
        pyxel.text(6, 76, 'stop(ch)', 7)

        pyxel.rectb(6, 97, 193, 143, 14)
        pyxel.rect(6, 91, 34, 97, 14)
        pyxel.text(7, 92, 'CONTROL', 1)

        pyxel.text(12, 102, '1: Play all channels', 14)
        pyxel.text(12, 110, '2: Play channel #0 (Melody)', 14)
        pyxel.text(12, 118, '3: Play channel #1 (Bass)', 14)
        pyxel.text(12, 126, '4: Play channel #2 (Drums)', 14)
        pyxel.text(12, 134, '5: Stop playing', 14)

        for i, v in enumerate(self.is_playing):
            pyxel.pal(1, v and 15 or 13)
            pyxel.blt(140 + i * 16,
                      116 + math.sin(pyxel.frame_count * 0.1 + i * 2.1) * 5, 0,
                      0, 0, 8, 8, 0)
        pyxel.pal()
Beispiel #3
0
 def draw(self, cam: 'Camera'):
     pyxel.rect(0, 128, SCREEN_WIDTH, 16, 0)
     pyxel.blt(8, 132, 0, 0, 48, 8, 8, 0)
     pyxel.text(
         20, 134,
         f"{self.game_ref.score} / {len(self.game_ref.game_objects['switch'])}",
         7)
Beispiel #4
0
 def worship_ui(cls):
     # tasks_text_y = 60
     if not MainUI.main_ui_active:
         return
     if MainUI.worship:
         pyxel.rect(1, 48, 77, 9, 7)
         pyxel.text(4, 50, "WORSHIP", 1)
Beispiel #5
0
    def draw(self):
        roof_x = self.x
        roof_y = self.y
        roof_u = 16 * self.roof
        roof_v = 16
        roof_width = 16
        roof_height = 8

        color_x1 = self.x + 2
        color_y1 = self.y + 8
        color_x2 = color_x1 + 11
        color_y2 = color_y1 + 8

        door_x = self.x
        door_y = self.y + 8
        door_u = 16 * self.door
        door_v = 24
        door_width = 16
        door_height = 8

        pyxel.rect(color_x1, color_y1, color_x2, color_y2, self.color)
        pyxel.blt(roof_x, roof_y, 0, roof_u, roof_v, roof_width, roof_height,
                  0)
        pyxel.blt(door_x, door_y, 0, door_u, door_v, door_width, door_height,
                  0)
 def draw_hint_window(self, i):
     pyxel.rect(64 - i, 19, 64 + i, 20, 9)  # yellow top frame
     pyxel.rect(64 - i, 20, 64 + i, 50, 1)  # center
     pyxel.rect(64 - i, 50, 64 + i, 50, 9)  # yellow bottom frame
     if Battle.anim_frame_hint_window == 56:
         pyxel.rect(63 - i, 20, 63 - i, 49, 9)  # yellow side frame
         pyxel.rect(65 + i, 20, 65 + i, 49, 9)
    def draw(self):
        pyxel.cls(0)

        # Useful for aligning text
        # pyxel.line(pyxel.width//4, 0, pyxel.width//4, pyxel.height, 7)
        # pyxel.line(pyxel.width//2, 0, pyxel.width//2, pyxel.height, 7)
        # pyxel.line(pyxel.width//4*3, 0, pyxel.width//4*3, pyxel.height, 7)

        if (self.game_state == 'title'):
            pyxel.text(93, pyxel.height//2 - 8, 'PASTEL STALACTITES', self.rotating_font_color)
            pyxel.text(118, pyxel.height//2, self.version, self.rotating_font_color)
            pyxel.text(100, pyxel.height//2 + 8, 'by Matt Niznik', 11)
            pyxel.text(85, pyxel.height//2 + 24, '(press SPACE to start)', 7)
        elif (self.game_state == 'gameover'):
            pyxel.text(self.game_over_message['x'], pyxel.height//2 - 8, self.game_over_message['msg'], self.rotating_font_color)
            pyxel.text(80, pyxel.height//2 + 8, 'Score: ' + str(int(self.score)), 7)
            pyxel.text(80, pyxel.height//2 + 16, 'Distance: ' + str(self.distance), 7)
            pyxel.text(80, pyxel.height//2 + 24, 'Score/100 px: ' + str(self.ppd), 7)
            pyxel.text(80, pyxel.height//2 + 40, '(press SPACE to continue)', 7)
        else:
            pyxel.rect(self.hero_x, pyxel.height-self.hero_height, self.hero_width, self.hero_height, self.hero_color)
            pyxel.rectb(self.hero_x, pyxel.height-self.hero_height, self.hero_width, self.hero_height, 7)

            pyxel.text(40, pyxel.height - 30, 'Score: ' + str(int(self.score)), 7)
            pyxel.text(40, pyxel.height - 20, 'Distance: ' + str(self.distance), 7)
            pyxel.text(40, pyxel.height - 10, 'Score/100 px: ' + str(self.ppd), 7)

            for i in range(0, len(self.stals)):
                stal = self.stals[i]
                pyxel.rect(stal['x'], 0, self.stal_width, stal['height'], stal['color'])
                pyxel.rectb(stal['x'], 0, self.stal_width, stal['height'], 7)
Beispiel #8
0
    def draw(self):
        self.check_fuel()
        self.make_fuel = True
        pyxel.cls(0)
        pyxel.bltm(0, 10, 0, 0, 0, 30, self.side_scroll_y, True)
        player = pyxel.blt(self.x, self.y, 0, 32, 0, 16, 16, pyxel.COLOR_WHITE)
        ##      player movements
        if pyxel.btn(pyxel.KEY_RIGHT) or pyxel.btn(pyxel.KEY_E):
            player = pyxel.blt(self.x, self.y, 0, 0, 0, 16, 16,
                               pyxel.COLOR_WHITE)
            self.score += 10
        elif pyxel.btn(pyxel.KEY_LEFT) or pyxel.btn(pyxel.KEY_Q):
            player = pyxel.blt(self.x - 1, self.y, 0, 16, 0, 16, 16,
                               pyxel.COLOR_WHITE)
            self.score += 10


##      print the score, position, and fuel, clearing the screen stops overwriting
        pyxel.rect(0, 0, SCREEN_WIDTH, 10, pyxel.COLOR_BLACK)
        s = "SCORE:{:04}".format(self.score)
        pyxel.text(0, 0, s, 6)
        f = "FUEL:{:02}".format(self.fuel)
        pyxel.text(120, 0, f, 6)
        self.show_fuel()
        self.check_fuel()
Beispiel #9
0
def draw_frame(x,
               y,
               w,
               h,
               col=0):  # col 0: white 1:yellow 2:red x,yは枠の左上ではない。中のテキストの左上
    A, B, C = 5, -2, -1  # (x,y)からA:左上に、B:右、C:下の調節
    pyxel.blt(g_offset_x + x - A, g_offset_y + y - A, 0, col * 8, 16, A, A, 15)
    pyxel.blt(g_offset_x + x + w + B, g_offset_y + y - A, 0, col * 8, 16, -A,
              A, 15)
    pyxel.blt(g_offset_x + x - A, g_offset_y + y + h + C, 0, col * 8, 16, A,
              -A, 15)
    pyxel.blt(g_offset_x + x + w + B, g_offset_y + y + h + C, 0, col * 8, 16,
              -A, -A, 15)
    [
        pyxel.blt(g_offset_x + x + i, g_offset_y + y - A, 0, col * 8 + 7, 16,
                  1, A, 15) for i in range(w + B)
    ]
    [
        pyxel.blt(g_offset_x + x + i, g_offset_y + y + h + C, 0, col * 8 + 7,
                  16, 1, -A, 15) for i in range(w + B)
    ]
    [
        pyxel.blt(g_offset_x + x - A, g_offset_y + y + j, 0, col * 8, 16 + 7,
                  A, 1, 15) for j in range(h + C)
    ]
    [
        pyxel.blt(g_offset_x + x + w + B, g_offset_y + y + j, 0, col * 8,
                  16 + 7, -A, 1, 15) for j in range(h + C)
    ]
    pyxel.rect(g_offset_x + x, g_offset_y + y, w + B, h + C, 0)
Beispiel #10
0
 def draw(self):
     for tile in self.tiles:
         tile.show()
     pyxel.rect(0,215,210,255,3)
     pyxel.rect(0,210,210,215,2)
     pyxel.text(80,225,"SCORE: "+str(self.score),15)        
     pyxel.text(80,235,"HIGH SCORE: "+str(self.high_score),15)
Beispiel #11
0
    def __on_draw(self):
        pyxel.rect(self.x, self.y, self.x + self.width - 1,
                   self.y + self.height - 1, 6)

        x = self.x + 1
        y = self.y + 1 + (3 - self.parent.octave) * 24
        pyxel.rect(x, y, x + 1, y + 46, 13)
Beispiel #12
0
 def foundBell(self):
     if (self.count < 200):
         pyxel.rect(40, 40, 120, 65, 7)
         pyxel.rectb(40, 40, 120, 65, 0)
         pyxel.text(44, 45, "You've obtained the", 0)
         pyxel.text(50, 55, "Bell of Jingles!", 0)
         self.count += 1
Beispiel #13
0
 def jingleCat(self):
     if (self.count < 200):
         pyxel.rect(40, 40, 122, 65, 7)
         pyxel.rectb(40, 40, 122, 65, 0)
         pyxel.text(44, 45, "You jingle the bell!", 0)
         pyxel.text(44, 55, "Something is coming!", 0)
         self.count += 1
Beispiel #14
0
 def feedCat(self):
     if (self.count < 200):
         pyxel.rect(40, 40, 123, 65, 7)
         pyxel.rectb(40, 40, 123, 65, 0)
         pyxel.text(44, 45, "You toss fish in!", 0)
         pyxel.text(44, 55, "You hear purring!", 0)
         self.count += 1
Beispiel #15
0
    def draw(self):
        pyxel.cls(0)
        # pyxel.rect(230, 135, 2, 2, 13)
        for i in range(32):
            if (self.score>>i)&1:
                x, y = 230-4*i, 135
                pyxel.rect(x, y, 2, 2, 3)

        for rx, ry, col in self.rect_effects:
            pyxel.rect(rx, ry, 2, 2, col)

        kx, ky = self.keys_pos
        for i, key in enumerate(self.keys):
            flag = self.key_flags[i]
            char, (x, y) = key
            pyxel.rectb(kx+x, ky+y, 12, 12, [13, 5][flag])
            pyxel.text(kx+2+x, ky+2+y, str.upper(char), [0, 6][flag])
        # pyxel.blit(20, 10)
        pyxel.text(20, 20, f"score: {self.score}", 7)
        pyxel.text(80, 30, (f"{self.before_question}"), 1)

        pyxel.text(80, 40, ":", 13)
        pyxel.text(80+4, 40, (f"{self.question}"), 12)

        pyxel.text(80, 50, ":", 13)
        pyxel.text(80+4, 50, self.answer, 13)

        self.score_before = self.score
Beispiel #16
0
 def draw(self):
     pyxel.cls(0)
     for y in range(self.Height):
         for x in range(self.Width):
             pyxel.rect(
                 x, y, 1, 1,
                 self.Colors[1] if self.Cells[y][x] else self.Colors[0])
Beispiel #17
0
    def draw(self):
        pyxel.cls(0)
        if pyxel.frame_count % 5 == 0:
            self.tipo_rabo = not self.tipo_rabo
        for i, segmento in enumerate(self.cobra):
            if i == 0:
                if self.direcao == ESQUERDA:
                    pyxel.blt(segmento.x, segmento.y, 0, 32, 16, 8, 8, 0)
                elif self.direcao == DIREITA:
                    pyxel.blt(segmento.x, segmento.y, 0, 0, 16, 8, 8, 0)
                elif self.direcao == BAIXO:
                    pyxel.blt(segmento.x, segmento.y, 0, 16, 16, 8, 8, 0)
                elif self.direcao == CIMA:
                    pyxel.blt(segmento.x, segmento.y, 0, 32, 0, 8, 8, 0)
            else:
                if i + 1 < len(self.cobra):
                    #if self.
                    pyxel.rect(segmento.x, segmento.y,
                               segmento.x + self.tamanho_segmento,
                               segmento.y + self.tamanho_segmento, 3)
                else:  # pintar rabinho
                    if self.tipo_rabo:
                        pyxel.blt(segmento.x, segmento.y, 0, 0, 32, 8, 8, 0)
                    else:
                        pyxel.blt(segmento.x, segmento.y, 0, 8, 32, 8, 8, 0)

        pyxel.blt(self.comida[0], self.comida[1], 0, 0, 0, 8, 8)
        pyxel.text(10, 10, 'SCORE {}'.format(self.score), 7)
Beispiel #18
0
 def drawCells(self):
     for y in range(CANVAS_HEIGHT):
         for x in range(CANVAS_WIDTH):
             draw_x = x * CELL_WIDTH
             draw_y = y * CELL_HEIGHT
             pyxel.rect(draw_x, draw_y, CELL_WIDTH / 1.001,
                        CELL_HEIGHT / 1.001, self.getCellColor(x, y))
Beispiel #19
0
    def draw_ui(self):
        """
            Draw everything but mobs
        """
        # Right rect for score, etc
        pyxel.rect(self.height + 6, 3, self.width - 4, self.height - 4, 1)

        # Logo
        pyxel.blt(self.height + 11, 6, 0, 0, 0, 32, 16)

        # Help text, current level and score
        pyxel.text(self.height + 11, 32, "Press R\nto start\n\n"
                   "Press Q\nto quit", 7)
        pyxel.text(self.height + 11, 80, "Level {}".format(self.level + 1), 7)
        pyxel.text(self.height + 11, 96, "Score :\n{}".format(self.score), 7)

        # Outter hexagon
        self.draw_hexagon(
            self.center_x,
            self.center_y,
            self.radius,
        )

        # Inner hexagon
        self.draw_hexagon(
            self.center_x,
            self.center_y,
            self.inner_radius,
        )
Beispiel #20
0
    def __on_draw(self):
        pyxel.cls(WIDGET_BACKGROUND_COLOR)
        pyxel.rect(0, 0, 239, 8, WIDGET_PANEL_COLOR)
        pyxel.line(0, 9, 239, 9, WIDGET_SHADOW_COLOR)

        pyxel.text(93, 2, self.help_message, 13)
        self.help_message = ""
Beispiel #21
0
 def tech_ui(cls):
     # tasks_text_y = 60
     if not MainUI.main_ui_active:
         return
     if MainUI.tech:
         pyxel.rect(1, 48, 77, 9, 7)
         pyxel.text(4, 50, "TECH", 1)
 def draw_next(self):
     for m, mino in enumerate(self.__gen.Nexts):
         for i in range(len(mino.blocks)):
             if 0 == mino.blocks[i]: continue
             y = i // 4 + (4 * m)
             x = i % 4
             pyxel.rect((Block.Size*x)+((Box.WIDTH)*Block.Size)+Block.Size//2, Block.Size*y, Block.Size, Block.Size, mino.blocks[i])
Beispiel #23
0
 def draw_block(self, x, y, small = False):
     if self == self.__class__.BLANK:
         pyxel.rect(x, y, 8, 8, pyxel.COLOR_BLACK)
     elif small:
         pyxel.blt(x, y, 0, self.value * 6, 8, 6, 6)
     else:
         pyxel.blt(x, y, 0, self.value * 8, 0, 8, 8)
Beispiel #24
0
def draw():
    # Mostra ponto inicial e legenda.
    if pyxel.frame_count == 0:
        pyxel.text(10, 160, "t positivo", pyxel.COLOR_GREEN)
        pyxel.text(10, 170, "t negativo", pyxel.COLOR_RED)
        x, y = pyxel.R0
        pyxel.text(x, pyxel.height - y, str(list(pyxel.R0)), pyxel.COLOR_WHITE)

    # Marca pontos na tela a partir da parametrização da reta.
    dt = pyxel.dt / pyxel.steps
    R0, n = pyxel.R0, pyxel.n

    for i in range(pyxel.steps):
        t = pyxel.time + dt * i

        x1, y1 = R0 + n * t
        x2, y2 = R0 - n * t

        pyxel.pset(x1, pyxel.height - y1, pyxel.COLOR_GREEN)
        pyxel.pset(x2, pyxel.height - y2, pyxel.COLOR_RED)

    # Desenha tempo decorrido no canto inferior direito
    pyxel.time += pyxel.dt
    x, y = (pyxel.width - pyxel.FONT_WIDTH * 14,
            pyxel.height - pyxel.FONT_HEIGHT)
    pyxel.rect(x, y, pyxel.FONT_WIDTH * 14, pyxel.FONT_HEIGHT,
               pyxel.COLOR_BLACK)
    pyxel.text(x, y, ("t = %.1f" % pyxel.time).rjust(10), pyxel.COLOR_WHITE)
Beispiel #25
0
    def draw_death(self):
        """Draw the display text for the end of the game with the score."""
        display_text = ["YOU DIED"]
        display_text.append("Your score is {:04}".format(
            Asteroid.asteroid_score))
        if Asteroid.asteroid_score == self.high_score:
            display_text.append("YOU HAVE A NEW HIGH SCORE!")
        else:
            display_text.append("The high score is {:04}".format(
                self.high_score))
        display_text.append("(Q)uit or (R)estart")

        text_area_height = len(display_text) * (pyxel.FONT_HEIGHT + 2) - 2
        pyxel.rect(
            x=0,
            y=constants.DEATH_HEIGHT - 2,
            w=pyxel.width,
            h=text_area_height + 4,
            col=constants.DEATH_STRIP_COLOUR,
        )

        for i, text in enumerate(display_text):
            y_offset = (pyxel.FONT_HEIGHT + 2) * i
            text_x = center_text(text, pyxel.width, pyxel.FONT_WIDTH)
            pyxel.text(
                text_x,
                constants.DEATH_HEIGHT + y_offset,
                text,
                constants.DEATH_TEXT_COLOUR,
            )
Beispiel #26
0
 def draw_field(self):
     for i, cell in enumerate(self.board):
         x, y = i % 3, i // 3
         if cell == 1:
             pyxel.rect(
                 x * BLOCK_SIZE , y * BLOCK_SIZE, 
                 BLOCK_SIZE, BLOCK_SIZE,
                 1
             )
             pyxel.line(
                 (x + 0) * BLOCK_SIZE,     (y + 0) * BLOCK_SIZE,
                 (x + 1) * BLOCK_SIZE - 1, (y + 1) * BLOCK_SIZE - 1,
                 12
             )
             pyxel.line(
                 (x + 0) * BLOCK_SIZE,     (y + 1) * BLOCK_SIZE - 1,
                 (x + 1) * BLOCK_SIZE - 1, (y + 0) * BLOCK_SIZE,
                 12
             )
         elif cell == 2:
             pyxel.rect(
                 x * BLOCK_SIZE , y * BLOCK_SIZE, 
                 BLOCK_SIZE, BLOCK_SIZE,
                 2
             )
             pyxel.rectb(
                 x * BLOCK_SIZE , y * BLOCK_SIZE, 
                 BLOCK_SIZE, BLOCK_SIZE,
                 14
             )
Beispiel #27
0
    def draw(self):
        global onoff
        global now
        global vol

        if onoff:
            pyxel.cls(channelToImage(self.channel[now]))
            if self.range < int(pyxel.height / 2):
                pyxel.rect(0,
                           int(pyxel.height / 2) - self.range, pyxel.width,
                           self.range * 2, 7)
                self.range += 5
            pyxel.text(5, 5, str(self.channel[now]), 0)

        else:
            pyxel.cls(0)
            if 0 < self.range:
                pyxel.rect(0,
                           int(pyxel.height / 2) - self.range, pyxel.width,
                           self.range * 2, 7)
                self.range -= 5

        if self.volcon > 0:
            pyxel.text(int(pyxel.width / 2),
                       int(pyxel.height) - 5, "vol:{}".format(vol), 0)
            self.volcon -= 1
Beispiel #28
0
    def __on_draw(self):
        pyxel.text(self.x - 13, self.y + 1, "TON", 6)
        pyxel.text(self.x - 13, self.y + 9, "VOL", 6)
        pyxel.text(self.x - 13, self.y + 17, "EFX", 6)
        pyxel.blt(self.x, self.y, 3, EDITOR_IMAGE_X, EDITOR_IMAGE_Y + 79, 193,
                  23)

        data_str = []
        data_str.append("".join(["TSPN"[v] for v in self.parent.get_data(1)]))
        data_str.append("".join([str(v) for v in self.parent.get_data(2)]))
        data_str.append("".join(["NSVF"[v] for v in self.parent.get_data(3)]))

        for i in range(3):
            pyxel.text(31, 150 + i * 8, data_str[i], 1)

        cursor_y = self.parent.field_cursor.y
        cursor_x = self.parent.field_cursor.x

        if self.parent.is_playing or cursor_y == 0:
            return

        x = cursor_x * 4 + 31
        y = cursor_y * 8 + 142

        pyxel.rect(x, y - 1, x + 2, y + 5, 1)

        if cursor_x < len(data_str[cursor_y - 1]):
            pyxel.text(x, y, data_str[cursor_y - 1][cursor_x], 7)
Beispiel #29
0
    def __on_draw(self):
        30, 149
        pyxel.text(self.x - 13, self.y + 1, "TON", 6)
        pyxel.text(self.x - 13, self.y + 9, "VOL", 6)
        pyxel.text(self.x - 13, self.y + 17, "EFX", 6)
        pyxel.blt(self.x, self.y, 3, EDITOR_IMAGE_X, EDITOR_IMAGE_Y + 79, 193,
                  23)

        cursor_x = self.parent.field_cursor.x
        cursor_y = 0 if self.parent.is_playing else self.parent.field_cursor.y

        if cursor_y > 0:
            x = cursor_x * 4 + 31
            y = cursor_y * 8 + 142
            pyxel.rect(x, y - 1, x + 2, y + 5, 1)

        for i, tone in enumerate(self.parent.get_data(1)):
            col = 7 if cursor_y == 1 and cursor_x == i else 1
            pyxel.text(31 + i * 4, 150, "TSPN"[tone], col)

        for i, volume in enumerate(self.parent.get_data(2)):
            col = 7 if cursor_y == 2 and cursor_x == i else 1
            pyxel.text(31 + i * 4, 158, str(volume), col)

        for i, effect in enumerate(self.parent.get_data(3)):
            col = 7 if cursor_y == 3 and cursor_x == i else 1
            pyxel.text(31 + i * 4, 166, "NSVF"[effect], col)
Beispiel #30
0
 def caughtFish(self):
     if (self.count < 200):
         pyxel.rect(40, 40, 120, 65, 7)
         pyxel.rectb(40, 40, 120, 65, 0)
         pyxel.text(44, 45, "You've obtained the", 0)
         pyxel.text(44, 55, "catch of the day!", 0)
         self.count += 1