def draw(self): pyxel.cls(0) pyxel.circ(self.x2, self.y2, 6, 6) # วาดวงกลม (x,y,รัศมี,สี) pyxel.rect(self.x, self.y, self.x + 7, self.y + 7, 9) s = 'SCORE {:>4}'.format(self.score) pyxel.text(5, 4, s, 1) pyxel.text(4, 4, s, 7)
def draw(self): pyxel.cls(0) pyxel.line(pyxel.width / 2, 1, pyxel.width / 2, pyxel.height, 1) pyxel.line(self.p1x, self.p1y, self.p1x, self.p1y + self.pLength, 7) pyxel.line(self.p2x, self.p2y, self.p2x, self.p2y + self.pLength, 7) # draw p1 score s = f'SCORE {self.p1Score}' pyxel.text(self.border, 4, s, 1) pyxel.text(self.border, 4, s, 7) # draw p2 score s = f'SCORE {self.p2Score}' pyxel.text(pyxel.width - self.border * 2, 4, s, 1) pyxel.text(pyxel.width - self.border * 2, 4, s, 7) if self.isRoundActive: pyxel.circ(self.Bx, self.By, self.Br, 7) else: pyxel.text(1, pyxel.width - self.border, "Press Enter to continue", 2) if self.hasGameEnded: s = f'You Won!!!' if self.p1Score > self.p2Score: pyxel.text(self.border, 20, s, 1) pyxel.text(self.border, 20, s, 7) else: pyxel.text(pyxel.width - self.border * 2, 20, s, 1) pyxel.text(pyxel.width - self.border * 2, 20, s, 7)
def draw(self): pyxel.circ( self.position.x, self.position.y, Ball.RADIUS, Color.WHITE, )
def draw (self): self.particles.draw(self.particles.space.camera, pyxel.COLOR_RED) pyxel.circ( self.position[0], self.position[1], self.radius, self.color)
def draw(): global player, ball, counter pyxel.cls(12) pyxel.circ(player[0], player[1], 10, 2) for b in balls: b.draw() pyxel.text(5, 4, str(counter), 1)
def draw(self): pyxel.cls(0) pyxel.text(15, 40, 'H: LEFT, J: DOWN, K: UP, L: RIGHT', 10) pyxel.text(15, 50, 'F: SHOOT BUBBLES', pyxel.frame_count % 16) pyxel.text(15, 60, 'Q: QUIT', 10) # ビール描画 if self.beer.vec_x > 0: pyxel.blt(self.beer.pos.x, self.beer.pos.y, self.beer.img_beer, 0, 0, -BEER_W, BEER_H) else: pyxel.blt(self.beer.pos.x, self.beer.pos.y, self.beer.img_beer, 0, 0, BEER_W, BEER_H) # 泡描画 for bubble in self.Bubbles: pyxel.circ(bubble.pos.x, bubble.pos.y, bubble.size, bubble.color) # ゾンビ描画 for zombie in self.Zombies: if zombie.vec_x > 0: pyxel.blt(zombie.pos.x, zombie.pos.y, zombie.img_zombie, 0, 0, -ZOMBIE_W, ZOMBIE_H) else: pyxel.blt(zombie.pos.x, zombie.pos.y, zombie.img_zombie, 0, 0, ZOMBIE_W, ZOMBIE_H) # ゲームオーバー if self.game_over == 1: pyxel.text(self.beer.pos.x - 10, self.beer.pos.y - 8, 'I WAS DRUNK!', 7)
def draw(self): pyxel.cls(0) # 背景 pyxel.blt(self.IMG_ID0_X, self.IMG_ID0_Y, self.IMG_ID0, 0, 0, 38, 16) # draw cat if self.mcat.vec > 0: pyxel.blt(self.mcat.pos.x, self.mcat.pos.y, self.mcat.img_cat, 0, 0, -CAT_W, CAT_H, 5) else: pyxel.blt(self.mcat.pos.x, self.mcat.pos.y, self.mcat.img_cat, 0, 0, CAT_W, CAT_H, 5) # draw Balls for ball in self.Balls: pyxel.circ(ball.pos.x, ball.pos.y, ball.size, ball.color) # draw Enemy for enemy in self.Enemies: if enemy.vec > 0: pyxel.blt(enemy.pos.x, enemy.pos.y, enemy.img_enemy, 0, 0, -ENEMY_W, ENEMY_H, 11) else: pyxel.blt(enemy.pos.x, enemy.pos.y, enemy.img_enemy, 0, 0, ENEMY_W, ENEMY_H, 11) if self.GameOver_flag == 1: pyxel.text(self.mcat.pos.x -10, self.mcat.pos.y -5, "GAME OVER", 8) # スコア pyxel.text(0 + 5 , WINDOW_H - 10, "SCORE:" + str(self.score), 7)
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): pyxel.cls(0) # The player object pyxel.circ(self.player_x, self.player_y, 1, 10) self.coords()
def draw(self): pyxel.cls(0) if self.FLAG == 0: pyxel.text(64, 45, "N E O N", pyxel.frame_count % 16) self.title_circ(63, 64) if (pyxel.frame_count % 60 < 30): pyxel.text(34, 80, "press spacebar to start", 5) elif self.FLAG == 1: self.TIME -= 1 pyxel.circ(self.x, self.y, self.r, self.color) pyxel.circb(self.x, self.y, self.r2, self.color) pyxel.text(10, 10, "score " + str(self.SCORE), 7) pyxel.text(10, 20, "life " + str(self.LIFE), 7) pyxel.text(10, 30, "level " + str(self.LEVEL), 7) pyxel.text(10, 40, "time " + str(self.TIME), 7) pyxel.text(110, 10, "best " + str(self.BESTSCORE), 7) if self.r < self.r2: self.r += 1 else: self.reset() elif self.FLAG == 2: pyxel.text(64, 45, "GAME OVER", pyxel.frame_count % 16) pyxel.text(61, 55, "score : " + str(self.SCORE), 7) if (pyxel.frame_count % 60 < 30): if self.SCORE == self.BESTSCORE: pyxel.text(61, 65, "BEST SCORE!", 7) pyxel.text(30, 90, "press spacebar to restart", 5) else: pyxel.text(64, 45, "LEVEL UP!", pyxel.frame_count % 16) if (pyxel.frame_count % 60 < 30): pyxel.text(30, 80, "press spacebar to continue", 5)
def draw(): draw_stars() if pyxel.btn(pyxel.MOUSE_LEFT_BUTTON): pyxel.circ(pyxel.mouse_x, pyxel.mouse_y, 2, pyxel.COLOR_RED) else: pyxel.pset(pyxel.mouse_x, pyxel.mouse_y, pyxel.COLOR_WHITE) sp.draw()
def draw(self): for y in range(Board.TileNum): for x in range(Board.TileNum): if self.__stones[y][x] == 0: continue pyxel.circ(x * Board.TileSize + self.R, y * Board.TileSize + self.R, self.R, self.__get_color(self.__stones[y][x]))
def draw(self): # Draw our splat pyxel.circ(self.x, self.y, self.radius, self.color) # Slowly decrease our radius every 30 frames. if pyxel.frame_count % 30 == 0 and self.radius > 0: self.radius -= 1
def draw(self): """ You can draw anything in here. I'm using circles, but particles can be sprites, text, et cetera. """ colour = 7 - int(3 * self.age / self.life) # Pick white/grey/dark-grey based on age. pyxel.circ(self.x, self.y, 1, colour)
def draw(self): pyxel.cls(0) pyxel.text(55, 40, "Mouse Panic !", pyxel.frame_count % 16) pyxel.blt(self.IMG_ID0_X, self.IMG_ID0_Y, self.IMG_ID0, 0, 0, 38, 16) # ====== draw score ====== score_x = 2 score_y = WINDOW_H-8 score = "SCORE:" + str(self.Score) pyxel.text(score_x, score_y, score, pyxel.frame_count % 16) # ======= draw cat ======== if self.mcat.vec > 0: pyxel.blt(self.mcat.pos.x, self.mcat.pos.y, self.IMG_ID1, 0, 0, -CAT_W, CAT_H, 5) else: pyxel.blt(self.mcat.pos.x, self.mcat.pos.y, self.IMG_ID1, 0, 0, CAT_W, CAT_H, 5) # ====== draw Balls ====== for ball in self.Balls: pyxel.circ(ball.pos.x, ball.pos.y, ball.size, ball.color) # ====== draw enemy ====== for enemy in self.Enemies: if enemy.vec > 0: pyxel.blt(enemy.pos.x, enemy.pos.y, enemy.img_enemy, 0, 0, -ENEMY_W, ENEMY_H, 11) else: pyxel.blt(enemy.pos.x, enemy.pos.y, enemy.img_enemy, 0, 0, ENEMY_W, ENEMY_H, 11) # ====== draw game over ====== if self.GameOver_flag == 1: pyxel.text(self.mcat.pos.x - 10, self.mcat.pos.y - 5, "GAME OVER", 8)
def drawCave(self): pyxel.rect(10, 10, 20, 20, 5) #cave middle pyxel.rect(5, 15, 25, 20, 5) #cave bottom pyxel.circ(9, 14, 3, 5) #cave right pyxel.circ(21, 14, 3, 5) #cave left pyxel.rect(14, 16, 16, 20, 0) #opening middle pyxel.rect(12, 18, 18, 20, 0) #opening bottom
def draw(self): pyxel.cls(0) pyxel.text(55, 41, "Hello, Pyxel!", pyxel.frame_count % 16) pyxel.blt(self.IMG_ID0_X, self.IMG_ID0_Y, self.IMG_ID0, 0, 0, 38, 16) # catのベクトル if self.mcat.vec > 0: pyxel.blt(self.mcat.pos.x, self.mcat.pos.y, self.IMG_ID1, 0, 0, -CAT_W, CAT_H, 13) else: pyxel.blt(self.mcat.pos.x, self.mcat.pos.y, self.IMG_ID1, 0, 0, CAT_W, CAT_H, 13) # ====== draw Balls ====== for ball in self.Balls: pyxel.circ(ball.pos.x, ball.pos.y, ball.size, ball.color) # ====== draw enemy ====== for enemy in self.Enemies: if enemy.vec > 0: pyxel.blt(enemy.pos.x, enemy.pos.y, enemy.img_enemy, 0, 0, -ENEMY_W, ENEMY_H, 7) else: pyxel.blt(enemy.pos.x, enemy.pos.y, enemy.img_enemy, 0, 0, ENEMY_W, ENEMY_H, 7) # ====== draw game over ====== if self.GameOver_flag == 1: pyxel.text(self.mcat.pos.x - 10, self.mcat.pos.y - 5, "GAME OVER", 8)
def draw(self): """ Clear the screen and redraw objects """ pyxel.cls(0) # 0 is black in the 16 colour pallete # below: draw the ball pyxel.circ( self.ball.position.x, # x starting point self.ball.position.y, # y starting point config.BALL_SIZE, # size of the ball 9 # color of the ball ) # below: draw the bats for bat in self.bats: pyxel.rect( bat.hitBox.x1, bat.hitBox.y1, bat.hitBox.x2, bat.hitBox.y2, 12 ) pyxel.text( config.SCREEN_WIDTH / 2, # x-position of the text config.SCREEN_HEIGHT / 12, # y position of the text str(self.score), # displayed text as string 7 # text color ) pyxel.text( config.SCREEN_WIDTH / 2, config.SCREEN_HEIGHT - 10, str("q = Quit, r = Restart"), 7 )
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)
def draw(self): """ Aspect of the projectile """ if self.owner == "player": pyxel.circ(self.x, self.y, 1, 7) else: pyxel.circ(self.x, self.y, 1, 11)
def test_circ(self, x, y): pyxel.text(x, y, "circ(x,y,r,col)", 7) x += 4 y += 15 for i in range(8): pyxel.circ(x + i * 8, y, i, i + 8)
def draw(): pyxel.cls(0) # labda pyxel.circ(labdax, labday, 4, 8) # ütő pyxel.rect(0, utoy - 20 / 2, 3, 20, 9)
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(self): cycled_color = ((pyxel.frame_count//20) % 15) + 1 pyxel.cls(0) # pyxel.tri(ball_list[0].x, ball_list[0].y, ball_list[1].x, ball_list[1].y, ball_list[2].x, # ball_list[2].y, # cycled_color) for ball in ball_list: pyxel.circ(ball.x, ball.y, ball.radius, ball.color)
def draw(self): pyxel.cls(0) pyxel.circ(pyxel.mouse_x, pyxel.mouse_y, 1, 9) # THE MOUSE Highlight.hbox() npc.draw_npcs() npc.select_npc() npc.move_npc()
def draw(self): pyxel.cls(0) # 円の描画 pyxel.circ(self.x, self.y, 8, 9) # テキスト描画 pyxel.text(0, 0, "SPEED: %f" % self.speed, 7) pyxel.text(0, 8, "INTENSITY: %f" % self.intensity, 7)
def draw(self): pyxel.cls(0) for bubble in self.bubbles: pyxel.circ(bubble.pos.x, bubble.pos.y, bubble.r, bubble.color) if not self.is_exploded and pyxel.frame_count % 20 < 10: pyxel.text(96, 50, "CLICK ON BUBBLE", pyxel.frame_count % 15 + 1)
def update(self): self.pos.x += self.vel.x self.pos.y += self.vel.y self.pos.x = math.cos(self.step) * self.amp self.pos.y = -1 * math.sin(self.step) * self.amp pyxel.circ(CENTER + x_pos, CENTER + y_pos, 4, 12) self.step += 0.03
def draw(self): pyxel.cls(0) for bubble in self.bubbles: pyxel.circ(bubble.pos.x, bubble.pos.y, bubble.r, bubble.color) if (not self.first_exploded) and ((pyxel.frame_count // 10) % 2): pyxel.text(100, 50, "CLICK ON BUBBLES", pyxel.frame_count % 16)
def debug_draw_circle(pos, angle, radius, outline_color, fill_color, data=None): pyxel.circ(*pos, r=radius - 1, col=fill_color) pyxel.circb(*pos, r=radius, col=outline_color)