def draw(): pyxel.cls(pyxel.COLOR_BLACK) pyxel.line(0, 90, 240, 90, pyxel.COLOR_PEACH) pyxel.line(120, 0, 120, 180, pyxel.COLOR_PEACH) for body in space.bodies: for shape in body.shapes: if isinstance(shape, Circle): x, y = body.position + shape.offset color = getattr(shape, 'color', pyxel.COLOR_WHITE) pyxel.circ(x, y, shape.radius, color) elif isinstance(shape, Segment): ax, ay = body.local_to_world(shape.a) bx, by = body.local_to_world(shape.b) pyxel.line(ax, ay, bx, by, pyxel.COLOR_RED) elif isinstance(shape, Poly): color = getattr(shape, 'color', pyxel.COLOR_WHITE) for tri in group_tri(shape.get_vertices()): coords = [] for v in tri: x, y = v.rotated(body.angle) + body.position coords.extend((x, y)) pyxel.tri(*coords, color) for cons in space.constraints: if isinstance(cons, (constraint.PivotJoint, constraint.GrooveJoint)): x, y = cons.b.local_to_world(cons.anchor_b) pyxel.circ(x, y, 2, pyxel.COLOR_YELLOW) if isinstance(cons, (constraint.PinJoint, constraint.SlideJoint, constraint.DampedSpring)): xa, ya = cons.a.local_to_world(cons.anchor_a) xb, yb = cons.b.local_to_world(cons.anchor_b) pyxel.line(xa, ya, xb, yb, pyxel.COLOR_YELLOW) pyxel.circ(xa, ya, 2, pyxel.COLOR_YELLOW) pyxel.circ(xb, yb, 2, pyxel.COLOR_YELLOW)
def draw(): pyxel.cls( pyxel.COLOR_NAVY if pyxel.btn(pyxel.KEY_SPACE) else pyxel.COLOR_PURPLE) pyxel.line(0, force_pos_y, pyxel.width, force_pos_y, pyxel.COLOR_WHITE) pyxel.line(force_pos_x, 0, force_pos_x, pyxel.height, pyxel.COLOR_WHITE) for body in space.bodies: for shape in body.shapes: if isinstance(shape, Circle): x, y = body.position + shape.offset color = getattr(shape, 'color', pyxel.COLOR_WHITE) pyxel.circ(x, y, shape.radius, color) elif isinstance(shape, Segment): ax, ay = body.position + shape.a bx, by = body.position + shape.b pyxel.line(ax, ay, bx, by, pyxel.COLOR_RED) elif isinstance(shape, Poly): color = getattr(shape, 'color', pyxel.COLOR_WHITE) for tri in group_tri(shape.get_vertices()): coords = [] for v in tri: x, y = v.rotated(body.angle) + body.position coords.extend((x, y)) pyxel.tri(*coords, color) obj = space.player pyxel.circ(*obj.position, 2, pyxel.COLOR_RED) pyxel.text(0, 160, f"angle: {obj.angle:.2f}", pyxel.COLOR_WHITE) pyxel.text(0, 170, f"omega: {obj.angular_velocity:.2f}", pyxel.COLOR_WHITE)
def draw(self): """ 描画に関することのみここでは書く。状態は変更しないこと。 """ if self.state == State.START: pyxel.cls(0) pyxel.text(0, 0, self.name, 7) pyxel.text(40, 64, "RANDOM MAP", 7) pyxel.text(40, 74, "PRESET MAP", 7) if self.use_random_map: pyxel.tri(32, 63, 38, 66, 32, 69, 7) else: pyxel.tri(32, 73, 38, 76, 32, 79, 7) elif self.state == State.MAIN: pyxel.cls(0) pyxel.text(0, 0, self.name, 7) pyxel.text(0, 7, f"SCORE: {self.total_score:08d} TON", 7) pyxel.text(0, 14, f"TIME: {int(pyxel.frame_count/15.)}", 7) # 迷路 self.draw_map() # 経路 self.draw_route_permission() # 自キャラ for car in self.cars: pyxel.rect(car.x, car.y + self.header, 1, 1, car.c) elif self.state == State.END: pyxel.cls(0) pyxel.text(0, 0, self.name, 7) pyxel.text(5, int(pyxel.height / 2.0), "GAME OVER", 7)
def draw(self): pyxel.cls(5) pyxel.text(6, 6, "tri(x1,y1,x2,y2,x3,y3,col)", 7) pyxel.text(6, 20, "trib(x1,y1,x2,y2,x3,y3,col)", 7) pyxel.tri(150, 0, 0, 100, 180, 100, 8) pyxel.trib(150, 100, 0, 140, 180, 140, 3)
def draw_points(self): for point in self.points: pyxel.circ(point.x, point.y, 2, 2) pyxel.circb(point.x, point.y, 10, point.color) pyxel.tri(point.x, point.y + 5, point.x - 10, point.y - 10, point.x + 10, point.y - 10, point.color) pyxel.tri(point.x - 10, point.y, point.x + 10, point.y, point.x, point.y - 15, point.color) #空
def draw_points(self): for point in self.points: pyxel.circ(point.x, point.y, 2, 2) pyxel.circb(point.x, point.y, 10, point.color) pyxel.tri(point.x, point.y+5, point.x-10, point.y-10, point.x+10, point.y-10, point.color) pyxel.tri(point.x-10, point.y, point.x+10, point.y, point.x, point.y-15, point.color) #空 #pyxel.text(point.x, point.y, f'Now is {self.color} color', self.color)# change pyxel.text(point.x, point.y, f'Now is {self.stack.size()} Number', self.color)## show the number of stack
def draw_trapezoid(x1, x2, y1, x3, x4, y2, col): """台形 p1-----p2 / \ / \ p3------------p4 p1(x1, y1) p2(x2, y1) p3(x3, y2) p4(x4, y2) """ pyxel.tri(x1, y1, x2, y1, x3, y2, col) pyxel.tri(x2, y1, x3, y2, x4, y2, col)
def draw(self): x = self.short_upper.x if self.short_upper.x < self.long_upper.x else self.long_upper.x _x = self.long_upper.x if self.short_upper.x < self.long_upper.x else self.short_upper.x y = self.short_upper.y width = abs(x - _x) height = self.short_lower.y - self.short_upper.y pyxel.rect(x, y, width, height, self.color) # 上半分の三角形 pyxel.tri(self.short_upper.x, self.short_upper.y, self.long_upper.x, self.long_upper.y, self.long_upper.x, self.short_upper.y, self.color) pyxel.tri(self.short_lower.x, self.short_lower.y, self.long_lower.x, self.long_lower.y, self.long_lower.x, self.short_lower.y, self.color)
def draw_triangle(x1, y1, x2, y2, x3, y3, n): if n == 0: return col = n + 7 if n % 2 == 0: pyxel.tri(x1, y1, x2, y2, x3, y3, col) else: pyxel.trib(x1, y1, x2, y2, x3, y3, col) h1 = (x1 + x2) / 2 w1 = (y1 + y2) / 2 h2 = (x2 + x3) / 2 w2 = (y2 + y3) / 2 h3 = (x3 + x1) / 2 w3 = (y3 + y1) / 2 triangles.append((x1, y1, h1, w1, h3, w3, n - 1)) triangles.append((h1, w1, x2, y2, h2, w2, n - 1)) triangles.append((h3, w3, h2, w2, x3, y3, n - 1))
def main_ui(cls): if not MainUI.main_ui_active: return # MAIN UI HEADER pyxel.rectb(0, 0, 256, 13, 1) pyxel.text(4, 4, f"Week {c.week}, Year {c.year}", 1) pyxel.text(113, 4, f"{c.curr_season}", 1) pyxel.rect(192, 2, 8, 9, 1) pyxel.text(195, 4, "P", 0) pyxel.rect(203, 2, 8, 9, 1) pyxel.tri(205, 4, 207, 6, 205, 8, 0) pyxel.rect(214, 2, 40, 9, 1) pyxel.text(217, 4, "NEXT TURN", 0) # MAIN UI LEFT pyxel.rectb(0, 16, 79, 200, 1) pyxel.rect(1, 17, 77, 9, 7) pyxel.text(4, 19, p.name, 1) pyxel.text( 4, 30, f"Pop: {int(p.population)}({p.employed})/{p.population_max}", 1) pyxel.text(4, 39, f"Prestige: {p.prestige}", 1) # MAIN UI MAP pyxel.rectb(82, 16, 174, 133, 1) # MAIN UI DIALOGUE BOX pyxel.rectb(82, 152, 174, 64, 1) # MAIN UI FOOTER pyxel.rect(0, 219, 256, 37, 1) pyxel.rectb(1, 220, 254, 35, 0) pyxel.rectb(10, 232, 46, 11, 0) pyxel.text(15, 235, "RESOURCES", 0) pyxel.rectb(72, 232, 29, 11, 0) pyxel.text(77, 235, "BUILD", 0) pyxel.rectb(119, 232, 29, 11, 0) pyxel.text(124, 235, "TASKS", 0) pyxel.rectb(167, 232, 26, 11, 0) pyxel.text(172, 235, "TECH", 0) pyxel.rectb(210, 232, 36, 11, 0) pyxel.text(215, 235, "WORSHIP", 0)
def draw(): pyxel.cls(0) for body in space.bodies: for shape in body.shapes: if isinstance(shape, Circle): x, y = body.position + shape.offset color = getattr(shape, 'color', pyxel.COLOR_WHITE) pyxel.circ(x, y, shape.radius, color) elif isinstance(shape, Segment): ax, ay = body.position + shape.a bx, by = body.position + shape.b pyxel.line(ax, ay, bx, by, pyxel.COLOR_RED) elif isinstance(shape, Poly): color = getattr(shape, 'color', pyxel.COLOR_WHITE) for tri in group_tri(shape.get_vertices()): coords = [] for v in tri: x, y = v.rotated(body.angle) + body.position coords.extend((x, y)) pyxel.tri(*coords, color)
def draw(self): # Draw a triangle shape around the player's position # pyxel.tri(self.x, self.y, self.x - 2, self.y + 2, self.x + 2, self.y + 2, pyxel.COLOR_DARKBLUE) if self.direction == 0: pyxel.tri(self.x, self.y, self.x - 2, self.y + 2, self.x + 2, self.y + 2, pyxel.COLOR_DARKBLUE) elif self.direction == 1: pyxel.tri(self.x, self.y, self.x - 2, self.y - 2, self.x - 2, self.y + 2, pyxel.COLOR_DARKBLUE) elif self.direction == 2: pyxel.tri(self.x, self.y, self.x + 2, self.y - 2, self.x - 2, self.y - 2, pyxel.COLOR_DARKBLUE) elif self.direction == 3: pyxel.tri(self.x, self.y, self.x + 2, self.y - 2, self.x + 2, self.y + 2, pyxel.COLOR_DARKBLUE)
def draw(): pyxel.cls(pyxel.COLOR_BLACK) pyxel.line(0, 90, 240, 90, pyxel.COLOR_PEACH) pyxel.line(120, 0, 120, 180, pyxel.COLOR_PEACH) for body in space.bodies: for shape in body.shapes: if isinstance(shape, Circle): x, y = body.position + shape.offset color = getattr(shape, 'color', pyxel.COLOR_WHITE) pyxel.circ(x, y, shape.radius, color) elif isinstance(shape, Segment): ax, ay = body.position + shape.a bx, by = body.position + shape.b pyxel.line(ax, ay, bx, by, pyxel.COLOR_RED) elif isinstance(shape, Poly): color = getattr(shape, 'color', pyxel.COLOR_WHITE) for tri in group_tri(shape.get_vertices()): coords = [] for v in tri: x, y = v.rotated(body.angle) + body.position coords.extend((x, y)) pyxel.tri(*coords, color) pyxel.text(5, 6, "U(x, y) =", pyxel.COLOR_WHITE) inpt.draw_widgets() # Energia obj = space.player K = obj.kinetic_energy x, y = obj.position - (120, 90) y *= -1 K = obj.mass * obj.velocity.length**2 / 2 pyxel.text(5, 150, f"K: {K:5.1f}", pyxel.COLOR_WHITE) pyxel.text(5, 160, f"U: {U(x, y):5.1f}", pyxel.COLOR_WHITE) pyxel.text(5, 170, f"E: {K + U(x, y):5.1f}", pyxel.COLOR_WHITE)
def draw(self): pyxel.cls(self.color_bg) # line for x in range(0, self.grid_num_h+1): _x = x*self.grid_size + self.padding pyxel.line(_x, self.padding, _x, self.padding + self.grid_size*self.grid_num_v, self.color_border) for y in range(0, self.grid_num_v+1): _y = y*self.grid_size + self.padding pyxel.line(self.padding, _y, self.padding + self.grid_size*self.grid_num_h, _y, self.color_border) # snake for y in range(self.grid_num_v): for x in range(self.grid_num_h): _x, _y = self.padding + x*self.grid_size + 1, self.padding + y*self.grid_size + 1 width, height = self.grid_size-1, self.grid_size-1 pyxel.rect(_x, _y, width, height, self.stage[y][x]) # snake joint area for i in range(len(self.snake_positions)-1): y1, x1 = self.snake_positions[i] y2, x2 = self.snake_positions[i+1] if x1 == x2: _x = x1*self.grid_size + self.padding+1 _y = max(y1, y2)*self.grid_size + self.padding pyxel.line(_x, _y, _x+self.grid_size-2, _y, self.color_snake_body) if y1 == y2: _x = max(x1, x2)*self.grid_size + self.padding _y = y1*self.grid_size + self.padding+1 pyxel.line(_x, _y, _x, _y+self.grid_size-2, self.color_snake_body) # text area x_left = self.padding + self.grid_size * self.grid_num_h + self.padding pyxel.text(x_left, 10, '-- state --', 13) pyxel.text(x_left, 20, self.game_states[self.game_state], self.color_text) pyxel.text(x_left, 40, '-- param --', 13) pyxel.text(x_left, 50, 'trial:' + str(self.trial), self.color_text) pyxel.text(x_left, 60, 'length:' + str(self.snake_length), self.color_text) # draw triangles pyxel.text(x_left, 85, '-- input --', 13) pyxel.text(x_left, 95, 'key:' + self.snake_direction_labels[self.snake_direction], self.color_text) pyxel.tri(190, 108, 197, 120, 183, 120, self.color_arrow_up) pyxel.tri(168, 130, 180, 137, 180, 123, self.color_arrow_left) pyxel.tri(212, 130, 200, 137, 200, 123, self.color_arrow_right) pyxel.tri(190, 152, 197, 140, 183, 140, self.color_arrow_down)
def draw(self): pyxel.cls(5) pyxel.tri(100, 0, 0, 100, 199, 100, 8)
def draw(self): pyxel.cls(0) #borders if self.freeze: pyxel.rectb(48, 60, 160, 160, 6) else: pyxel.rectb(48, 60, 160, 160, 7) #score pyxel.text(25, 20, "YOUR SCORE :", 7) if self.double_points: pyxel.text(80, 20, str(self.score), 10) else: pyxel.text(80, 20, str(self.score), 8) #info text pyxel.text(35, 235, "Try to dodge the", 7) pyxel.text(103, 235, "balls", 8) pyxel.text(127, 235, "and collect", 7) pyxel.text(175, 235, "superpowers ", 14) #player pyxel.rect(self.posx, self.posy, 10, 10, 7) #superpower pyxel.text(150, 20, "SUPERPOWER :", 7) #double points if self.double_points: pyxel.text(200, 12, "POINTS x2", 10) pyxel.rect(240, 10, 10, 10, 10) pyxel.text(243, 13, str(self.dp_timer), 0) #freeze if self.freeze: pyxel.text(200, 27, "FREEZE", 6) pyxel.rect(234, 24, 10, 10, 6) pyxel.text(237, 27, str(self.fr_timer), 0) #shield if self.shield: pyxel.text(200, 20, "SHIELD", 3) if self.shield >= 1: pyxel.rectb(self.posx, self.posy, 10, 10, 3) if self.shield >= 2: pyxel.rectb(self.posx + 2, self.posy + 2, 6, 6, 3) if self.shield >= 3: pyxel.rect(self.posx + 4, self.posy + 4, 2, 2, 3) if self.shield >= 4: pyxel.rect(self.posx + 3, self.posy + 3, 4, 4, 3) if self.shield >= 5: pyxel.rect(self.posx + 1, self.posy + 1, 8, 8, 3) pyxel.text(50, 51, 'MAX SHIELD LEVEL', 3) #blaster if self.blaster: pyxel.text(200, 36, "BLASTER", 14) pyxel.rect(234, 35, 10, 10, 14) pyxel.text(237, 38, str(self.blaster), 0) pyxel.text(122, 51, 'PRESS SPACE TO BLAST !', 14) #blasters for blaster in self.blasters: pyxel.rect(blaster.position.x, blaster.position.y, 10, 10, 14) #packages for package in self.packages: pyxel.rect(package.position.x, package.position.y, package.sizexy, package.sizexy, 14) pyxel.text(package.position.x + 4, package.position.y + 3, "S", 0) #balls for ball in self.balls: pyxel.circ(ball.position.x, ball.position.y, ball.radius, ball.color) #GAMEOVER if self.is_gameover: pyxel.cls(0) pyxel.rectb(60, 60, 136, 136, 8) pyxel.text(105, 80, " GAME OVER ", 8) pyxel.tri(80, 120, 80, 126, 86, 123, 8) pyxel.tri(80, 140, 80, 146, 86, 143, 7) pyxel.tri(80, 160, 80, 166, 86, 163, 10) pyxel.text(106, 120, "YOUR SCORE : ", 8) pyxel.text(160, 120, str(self.score), 8) pyxel.text(106, 140, "Press Q to Quit ", 7) pyxel.text(106, 160, "Pls give me star", 10) pyxel.text(106, 170, "on Github ", 10)
def __drawMaze(self, num): if num == 0: pyxel.rect(154 + 8, 40, 16, 16, 12) pyxel.tri(154 + 24, 40, 154 + 40, 48, 154 + 24, 55, 1) elif num == 1: pyxel.rect(154 + 24, 40, 16, 16, 12) pyxel.tri(154 + 40, 40, 154 + 48, 48, 154 + 40, 55, 1) elif num == 2: pyxel.rect(154 + 72, 40, 16, 16, 12) pyxel.tri(154 + 71, 40, 154 + 71, 55, 154 + 56, 48, 1) elif num == 3: pyxel.rect(154 + 56, 40, 16, 16, 12) pyxel.tri(154 + 55, 40, 154 + 55, 55, 154 + 48, 48, 1) elif num == 4: pyxel.rect(154 + 40, 40, 16, 16, 12) elif num == 5: pyxel.rect(154 + 0, 24, 24, 48, 12) pyxel.rect(154 + 24, 40, 16, 16, 1) pyxel.tri(154 + 24, 24, 154 + 39, 39, 154 + 24, 40, 1) pyxel.tri(154 + 24, 56, 154 + 39, 56, 154 + 24, 71, 1) elif num == 6: pyxel.rect(154 + 72, 24, 24, 48, 12) pyxel.rect(154 + 56, 40, 16, 16, 1) pyxel.tri(154 + 71, 24, 154 + 56, 39, 154 + 71, 39, 1) pyxel.tri(154 + 71, 56, 154 + 56, 56, 154 + 71, 71, 1) elif num == 7: pyxel.rect(154 + 24, 24, 48, 48, 12) elif num == 8: pyxel.rect(154 + 0, 8, 8, 80, 12) pyxel.rect(154 + 8, 24, 16, 48, 1) pyxel.tri(154 + 8, 8, 154 + 23, 23, 154 + 8, 23, 1) pyxel.tri(154 + 8, 87, 154 + 23, 72, 154 + 8, 72, 1) elif num == 9: pyxel.rect(154 + 88, 8, 8, 80, 12) pyxel.rect(154 + 72, 24, 16, 48, 1) pyxel.tri(154 + 87, 8, 154 + 87, 23, 154 + 72, 23, 1) pyxel.tri(154 + 87, 87, 154 + 87, 72, 154 + 72, 72, 1) elif num == 10: pyxel.rect(154 + 8, 8, 80, 80, 12) elif num == 11: pyxel.rect(154 + 0, 8, 8, 80, 1) pyxel.tri(154 + 0, 0, 154 + 7, 7, 154 + 0, 7, 1) pyxel.tri(154 + 0, 95, 154 + 7, 88, 154 + 0, 88, 1) elif num == 12: pyxel.rect(154 + 88, 8, 8, 80, 1) pyxel.tri(154 + 95, 0, 154 + 88, 7, 154 + 95, 7, 1) pyxel.tri(154 + 95, 95, 154 + 88, 88, 154 + 95, 88, 1) elif num == 13: pyxel.rect(154 + 0, 0, 96, 96, 12)
pyxel.rect(0, 120, 200, 30, 3) for x in range(0, 230, 4): pyxel.line(x - 30, 150, x, 120, 11) # Cerca pyxel.rect(0, 135, 200, 3, 2) pyxel.rect(0, 145, 200, 3, 2) for x in range(0, 200, 15): pyxel.rect(x, 130, 3, 20, 2) # Casa pyxel.rect(90, 90, 70, 35, 15) # Porta pyxel.rect(97, 100, 15, 25, 2) pyxel.circ(99, 112, 1, 1) # Janelas pyxel.rect(117, 100, 15, 15, 2) pyxel.rect(119, 102, 11, 11, 5) pyxel.rect(137, 100, 15, 15, 2) pyxel.rect(139, 102, 11, 11, 5) # Telhado pyxel.rect(95, 70, 60, 21, 4) pyxel.tri(85, 90, 95, 90, 95, 70, 4) pyxel.tri(155, 90, 165, 90, 155, 70, 4) # Mostra a cena pyxel.show()
def tri(self, x1, y1, x2, y2, x3, y3, col): pyxel.tri(*self.transform(x1, y1), *self.transform(x2, y2), *self.transform(x3, y3), col)
def draw_wall(self, _idx, _data): ''' 迷路を表示する。\n drawMazeクラスからの利用を想定し、他のモジュールからの使用は想定していない。\n 描画番号とマップの地形情報に従って壁を描画する ''' # dataが0の場合は壁を描画しないので抜ける if _data == 0: return # idxとの値により壁を描画する # |0|1|4|3|2| # |5|7|6| # |8|A|9| # |B|D|C| if _idx == 1: if _data & 0b000000000111 != 0: _color = _data & 0b000000000111 _y = 0 if (self.isOuter() and _color == 3) else 39 _h = 38 if (self.isOuter() and _color == 3) else 1 pyxel.rect(35 + self.DRAW_OFFSET_X, _y + self.DRAW_OFFSET_Y, 3, _h, self.WALLCOLOR_FRONT[_color]) if _idx == 3: if _data & 0b000000000111 != 0: _color = _data & 0b000000000111 _y = 0 if (self.isOuter() and _color == 3) else 39 _h = 38 if (self.isOuter() and _color == 3) else 1 pyxel.rect(41 + self.DRAW_OFFSET_X, _y + self.DRAW_OFFSET_Y, 3, _h, self.WALLCOLOR_FRONT[_color]) if _idx == 4: if _data & 0b000000000111 != 0: _color = _data & 0b000000000111 _y = 0 if (self.isOuter() and _color == 3) else 39 _h = 38 if (self.isOuter() and _color == 3) else 1 pyxel.rect(38 + self.DRAW_OFFSET_X, _y + self.DRAW_OFFSET_Y, 3, _h, self.WALLCOLOR_FRONT[_color]) if _data & 0b000000111000 != 0: _color = (_data >> 3) & 0b000000000111 _y = 0 if (self.isOuter() and _color == 3) else 39 _h = 38 if (self.isOuter() and _color == 3) else 1 pyxel.tri(43 + self.DRAW_OFFSET_X, 36 + self.DRAW_OFFSET_Y, 41 + self.DRAW_OFFSET_X, 38 + self.DRAW_OFFSET_Y, 43 + self.DRAW_OFFSET_X, 38 + self.DRAW_OFFSET_Y, self.WALLCOLOR_SIDE[_color]) pyxel.tri(41 + self.DRAW_OFFSET_X, 40 + self.DRAW_OFFSET_Y, 43 + self.DRAW_OFFSET_X, 40 + self.DRAW_OFFSET_Y, 43 + self.DRAW_OFFSET_X, 42 + self.DRAW_OFFSET_Y, self.WALLCOLOR_SIDE[_color]) pyxel.rect(41 + self.DRAW_OFFSET_X, _y + self.DRAW_OFFSET_Y, 3, _h, self.WALLCOLOR_SIDE[_color]) if _data & 0b111000000000 != 0: _color = (_data >> 9) & 0b000000000111 _y = 0 if (self.isOuter() and _color == 3) else 39 _h = 38 if (self.isOuter() and _color == 3) else 1 pyxel.tri(35 + self.DRAW_OFFSET_X, 36 + self.DRAW_OFFSET_Y, 37 + self.DRAW_OFFSET_X, 38 + self.DRAW_OFFSET_Y, 35 + self.DRAW_OFFSET_X, 38 + self.DRAW_OFFSET_Y, self.WALLCOLOR_SIDE[_color]) pyxel.tri(35 + self.DRAW_OFFSET_X, 40 + self.DRAW_OFFSET_Y, 37 + self.DRAW_OFFSET_X, 40 + self.DRAW_OFFSET_Y, 35 + self.DRAW_OFFSET_X, 42 + self.DRAW_OFFSET_Y, self.WALLCOLOR_SIDE[_color]) pyxel.rect(35 + self.DRAW_OFFSET_X, _y + self.DRAW_OFFSET_Y, 3, _h, self.WALLCOLOR_SIDE[_color]) if _idx == 5: if _data & 0b000000000111 != 0: _color = _data & 0b000000000111 _y = 0 if (self.isOuter() and _color == 3) else 36 _h = 43 if (self.isOuter() and _color == 3) else 7 pyxel.rect(26 + self.DRAW_OFFSET_X, _y + self.DRAW_OFFSET_Y, 9, _h, self.WALLCOLOR_FRONT[_color]) if _idx == 6: if _data & 0b000000000111 != 0: _color = _data & 0b000000000111 _y = 0 if (self.isOuter() and _color == 3) else 36 _h = 43 if (self.isOuter() and _color == 3) else 7 pyxel.rect(44 + self.DRAW_OFFSET_X, _y + self.DRAW_OFFSET_Y, 9, _h, self.WALLCOLOR_FRONT[_color]) if _idx == 7: if _data & 0b000000000111 != 0: _color = _data & 0b000000000111 _y = 0 if (self.isOuter() and _color == 3) else 36 _h = 43 if (self.isOuter() and _color == 3) else 7 pyxel.rect(35 + self.DRAW_OFFSET_X, _y + self.DRAW_OFFSET_Y, 9, _h, self.WALLCOLOR_FRONT[_color]) if _data & 0b000000111000 != 0: _color = (_data >> 3) & 0b000000000111 _y = 0 if (self.isOuter() and _color == 3) else 36 _h = 43 if (self.isOuter() and _color == 3) else 7 pyxel.tri(50 + self.DRAW_OFFSET_X, 29 + self.DRAW_OFFSET_Y, 44 + self.DRAW_OFFSET_X, 35 + self.DRAW_OFFSET_Y, 50 + self.DRAW_OFFSET_X, 35 + self.DRAW_OFFSET_Y, self.WALLCOLOR_SIDE[_color]) pyxel.tri(44 + self.DRAW_OFFSET_X, 43 + self.DRAW_OFFSET_Y, 50 + self.DRAW_OFFSET_X, 43 + self.DRAW_OFFSET_Y, 50 + self.DRAW_OFFSET_X, 49 + self.DRAW_OFFSET_Y, self.WALLCOLOR_SIDE[_color]) pyxel.rect(44 + self.DRAW_OFFSET_X, _y + self.DRAW_OFFSET_Y, 7, _h, self.WALLCOLOR_SIDE[_color]) if _data & 0b111000000000 != 0: _color = (_data >> 9) & 0b000000000111 _y = 0 if (self.isOuter() and _color == 3) else 36 _h = 43 if (self.isOuter() and _color == 3) else 7 pyxel.tri(28 + self.DRAW_OFFSET_X, 29 + self.DRAW_OFFSET_Y, 34 + self.DRAW_OFFSET_X, 35 + self.DRAW_OFFSET_Y, 28 + self.DRAW_OFFSET_X, 35 + self.DRAW_OFFSET_Y, self.WALLCOLOR_SIDE[_color]) pyxel.tri(28 + self.DRAW_OFFSET_X, 43 + self.DRAW_OFFSET_Y, 34 + self.DRAW_OFFSET_X, 43 + self.DRAW_OFFSET_Y, 28 + self.DRAW_OFFSET_X, 49 + self.DRAW_OFFSET_Y, self.WALLCOLOR_SIDE[_color]) pyxel.rect(28 + self.DRAW_OFFSET_X, _y + self.DRAW_OFFSET_Y, 7, _h, self.WALLCOLOR_SIDE[_color]) if _idx == 8: if _data & 0b000000000111 != 0: _color = _data & 0b000000000111 _y = 0 if (self.isOuter() and _color == 3) else 29 _h = 50 if (self.isOuter() and _color == 3) else 21 pyxel.rect(5 + self.DRAW_OFFSET_X, _y + self.DRAW_OFFSET_Y, 23, _h, self.WALLCOLOR_FRONT[_color]) if _idx == 9: if _data & 0b000000000111 != 0: _color = _data & 0b000000000111 _y = 0 if (self.isOuter() and _color == 3) else 29 _h = 50 if (self.isOuter() and _color == 3) else 21 pyxel.rect(51 + self.DRAW_OFFSET_X, _y + self.DRAW_OFFSET_Y, 23, _h, self.WALLCOLOR_FRONT[_color]) if _idx == 10: if _data & 0b000000000111 != 0: _color = _data & 0b000000000111 _y = 0 if (self.isOuter() and _color == 3) else 29 _h = 50 if (self.isOuter() and _color == 3) else 21 pyxel.rect(28 + self.DRAW_OFFSET_X, _y + self.DRAW_OFFSET_Y, 23, _h, self.WALLCOLOR_FRONT[_color]) if _data & 0b000000111000 != 0: _color = (_data >> 3) & 0b000000000111 _y = 0 if (self.isOuter() and _color == 3) else 29 _h = 50 if (self.isOuter() and _color == 3) else 21 pyxel.tri(69 + self.DRAW_OFFSET_X, 10 + self.DRAW_OFFSET_Y, 51 + self.DRAW_OFFSET_X, 28 + self.DRAW_OFFSET_Y, 69 + self.DRAW_OFFSET_X, 28 + self.DRAW_OFFSET_Y, self.WALLCOLOR_SIDE[_color]) pyxel.tri(51 + self.DRAW_OFFSET_X, 50 + self.DRAW_OFFSET_Y, 69 + self.DRAW_OFFSET_X, 50 + self.DRAW_OFFSET_Y, 69 + self.DRAW_OFFSET_X, 68 + self.DRAW_OFFSET_Y, self.WALLCOLOR_SIDE[_color]) pyxel.rect(51 + self.DRAW_OFFSET_X, _y + self.DRAW_OFFSET_Y, 19, _h, self.WALLCOLOR_SIDE[_color]) if _data & 0b111000000000 != 0: _color = (_data >> 9) & 0b000000000111 _y = 0 if (self.isOuter() and _color == 3) else 29 _h = 50 if (self.isOuter() and _color == 3) else 21 pyxel.tri(9 + self.DRAW_OFFSET_X, 10 + self.DRAW_OFFSET_Y, 27 + self.DRAW_OFFSET_X, 28 + self.DRAW_OFFSET_Y, 9 + self.DRAW_OFFSET_X, 28 + self.DRAW_OFFSET_Y, self.WALLCOLOR_SIDE[_color]) pyxel.tri(9 + self.DRAW_OFFSET_X, 50 + self.DRAW_OFFSET_Y, 27 + self.DRAW_OFFSET_X, 50 + self.DRAW_OFFSET_Y, 9 + self.DRAW_OFFSET_X, 68 + self.DRAW_OFFSET_Y, self.WALLCOLOR_SIDE[_color]) pyxel.rect(9 + self.DRAW_OFFSET_X, _y + self.DRAW_OFFSET_Y, 19, _h, self.WALLCOLOR_SIDE[_color]) if _idx == 11: if _data & 0b000000000111 != 0: _color = _data & 0b000000000111 _y = 0 if (self.isOuter() and _color == 3) else 10 _h = 69 if (self.isOuter() and _color == 3) else 59 pyxel.rect(0 + self.DRAW_OFFSET_X, _y + self.DRAW_OFFSET_Y, 10, _h, self.WALLCOLOR_FRONT[_color]) if _idx == 12: if _data & 0b000000000111 != 0: _color = _data & 0b000000000111 _y = 0 if (self.isOuter() and _color == 3) else 10 _h = 69 if (self.isOuter() and _color == 3) else 59 pyxel.rect(69 + self.DRAW_OFFSET_X, _y + self.DRAW_OFFSET_Y, 10, _h, self.WALLCOLOR_FRONT[_color]) if _idx == 13: if _data & 0b000000000111 != 0: _color = _data & 0b000000000111 _y = 0 if (self.isOuter() and _color == 3) else 10 _h = 69 if (self.isOuter() and _color == 3) else 59 pyxel.rect(10 + self.DRAW_OFFSET_X, _y + self.DRAW_OFFSET_Y, 59, _h, self.WALLCOLOR_FRONT[_color]) if _data & 0b00000011 == 0b00000010: pyxel.circ(17 + self.DRAW_OFFSET_X, 40 + self.DRAW_OFFSET_Y, 2, pyxel.COLOR_BLACK) if _data & 0b000000111000 != 0: _color = (_data >> 3) & 0b000000000111 _y = 0 if (self.isOuter() and _color == 3) else 10 _h = 69 if (self.isOuter() and _color == 3) else 59 pyxel.tri(78 + self.DRAW_OFFSET_X, 1 + self.DRAW_OFFSET_Y, 69 + self.DRAW_OFFSET_X, 10 + self.DRAW_OFFSET_Y, 78 + self.DRAW_OFFSET_X, 10 + self.DRAW_OFFSET_Y, self.WALLCOLOR_SIDE[_color]) pyxel.tri(69 + self.DRAW_OFFSET_X, 68 + self.DRAW_OFFSET_Y, 78 + self.DRAW_OFFSET_X, 68 + self.DRAW_OFFSET_Y, 78 + self.DRAW_OFFSET_X, 77 + self.DRAW_OFFSET_Y, self.WALLCOLOR_SIDE[_color]) pyxel.rect(69 + self.DRAW_OFFSET_X, _y + self.DRAW_OFFSET_Y, 10, _h, self.WALLCOLOR_SIDE[_color]) if _data & 0b111000000000 != 0: _color = (_data >> 9) & 0b000000000111 _y = 0 if (self.isOuter() and _color == 3) else 10 _h = 69 if (self.isOuter() and _color == 3) else 59 pyxel.tri(0 + self.DRAW_OFFSET_X, 1 + self.DRAW_OFFSET_Y, 9 + self.DRAW_OFFSET_X, 10 + self.DRAW_OFFSET_Y, 0 + self.DRAW_OFFSET_X, 10 + self.DRAW_OFFSET_Y, self.WALLCOLOR_SIDE[_color]) pyxel.tri(0 + self.DRAW_OFFSET_X, 68 + self.DRAW_OFFSET_Y, 9 + self.DRAW_OFFSET_X, 68 + self.DRAW_OFFSET_Y, 0 + self.DRAW_OFFSET_X, 77 + self.DRAW_OFFSET_Y, self.WALLCOLOR_SIDE[_color]) pyxel.rect(0 + self.DRAW_OFFSET_X, _y + self.DRAW_OFFSET_Y, 10, _h, self.WALLCOLOR_SIDE[_color])
def draw(self): # Draw a triangle shape around the player's position pyxel.tri(self.x, self.y, self.x - 2, self.y + 2, self.x + 2, self.y + 2, pyxel.COLOR_DARKBLUE)
def draw_arrow(arrow_x, arrow_y): pyxel.rect(arrow_x - 1, arrow_y, 5, 10, 9) pyxel.tri(arrow_x - 4, arrow_y + 10, arrow_x + 6, arrow_y + 10, arrow_x + 1, arrow_y + 15, 9)
import pyxel as P P.init(128, 128, scale=1), P.run( lambda: 0, lambda: [P.cls(5), P.tri(64, 0, 0, 64, 128, 128, 8)])