def draw(self): if not all(self.build_state): x, y = self.x_buffer2, self.y_buffer2 else: x, y = self.x_buffer, self.y_buffer pyxel.text(viewport['x'] + self.x, viewport['y'] + self.y, self.symbol, self.colour) pyxel.blt(viewport['x'] + self.x, viewport['y'] + self.y, 0, x, y, self.width, self.height) if len(self.workers): mask_count = 0 for mask_x in range(self.width): for mask_y in range(self.height): if not self.build_state[mask_count]: pyxel.rect(self.x + mask_x + viewport['x'], self.y + mask_y + viewport['y'], 1, 1, 0) mask_count += 1
def draw(self): # 画面消去 pyxel.cls(pyxel.COLOR_BLACK) # 表示中オブジェクトリスト全件に対して処理 for _item in self.disp_objects: # 表示オブジェクトの情報を取得 _x = _item[1] _cmd = _item[2] _value = _item[3] # "text" = 文字列を指定色で表示 if _cmd == "text": pyxel.text(_x, _item[0], _value["value"], _value["color"]) # "img" = イメージバンクの指定座標のイメージを表示 elif _cmd == "img": pyxel.blt(_x, _item[0], _value["img"], _value["u"], _value["v"], _value["w"], _value["h"])
def draw_monolith(self): for monolith in self.Monolith: # Monolith's animation (extend). pyxel.rect(monolith.x1, monolith.y1, monolith.x2, monolith.y2, monolith.disp_color) # Draw detail information (already extend). if monolith.x1 <= monolith.max_size_x1: pyxel.rectb(monolith.max_size_x1 + 5, monolith.max_size_y1 + 10, monolith.max_size_x2 - 5, monolith.max_size_y2, self.utility.color_7) # Extract message from Target or Attacker. message = [] if monolith.target_type == 'Target': message = self.create_detail_info( self.Target[monolith.target_id].system_info, self.Target[monolith.target_id].vuln_info, self.Target[monolith.target_id].other_info) else: message = self.create_detail_info( self.Attacker[monolith.target_id].system_info, self.Attacker[monolith.target_id].vuln_info, self.Attacker[monolith.target_id].other_info) # Write message. monolith.update(max_page=len(message)) # Write title. msg = '{} Information. [{}/{}]'.format( monolith.disp_hostname, monolith.page_count, monolith.max_page) pyxel.text(monolith.x1 + 10, monolith.y1 + 4, msg, pyxel.frame_count % 15) if monolith.max_page != 0: for idx, msg_line in enumerate( message[monolith.page_count - 1]): pyxel.text(monolith.x1 + 12, monolith.y1 + 17 + (idx * 8), msg_line, monolith.info_color)
def draw_game(self): # メインのゲーム描画 self.screen = 1 pyxel.cls(0) pyxel.rect(0, 80, 160, 120, 3) xy = "CAT: [X: {}][Y: {}][DIR: {}]".format( self.cat_x, self.cat_y, "LEFT" if self.cat_direction_left else "RIGHT") pyxel.text(5, 110, xy, 10) mouse = "MOUSE:[X: {}][Y: {}]".format(pyxel.mouse_x, pyxel.mouse_y) pyxel.text(5, 100, mouse, 10) pyxel.blt( self.cat_x, self.cat_y, 0, 0, 0, 16 if self.cat_direction_left else -16, 16, 5, )
def draw(self): pyxel.cls(0) pyxel.rect(0, 0, 240, 9, 0) pyxel.line(0, 9, 239, 9, 0) # pyxel.text(93, 2, self.help_message, 13) # self.help_message = "" if self._appstate == AppState.BROWSE: y = 13 for dir in self.dirs: pyxel.text(16, y, dir, 13) y = y + 16 y = (self.cursorpos+1) *16 #rect(x1: int, y1: int, x2: int, y2: int, col: int) pyxel.circ(7, y , 2, 14) # pyxel.rect(7, y, 14,14, 14) elif self._appstate == AppState.LAUNCHING: pyxel.text(16, 50, "Launching App...", 20)
def __on_draw(self): self.draw_panel(self.x, self.y, self.width, self.height, with_shadow=self._with_shadow) # Draw colors for yi in range(2): for xi in range(8): pyxel.rect(self.x + xi * 8 + 1, self.y + yi * 8 + 1, 7, 7, yi * 8 + xi) # Draw cursor col = self.value_var pyxel.text( self.x + (col % 8) * 8 + 3, self.y + (col // 8) * 8 + 2, "+", 7 if col < 6 else 0, )
def fill_obj(self, str, x, y, xx=0, yy=0, reset=False, cls_color=BLACK, line_color=BLACK, bg_color=DARK_GRAY, font_color=WHITE): if(reset): pyxel.cls(0) # reset display color obj_map = { "line_x1" : x - 1 - (xx), "line_y1" : y - 1 - (yy), "line_x2" : x + self.width + 0 + (xx), "line_y2" : y + self.height + 1 + (yy), "fill_x1" : x - 0 - (xx), "fill_y1" : y - 0 - (yy), "fill_x2" : x + self.width - 1 + (xx), "fill_y2" : y + self.height + 0 + (yy), "str_x" : x + self.mright, "str_y" : y + self.mright } pyxel.rect(obj_map["line_x1"], obj_map["line_y1"], obj_map["line_x2"], obj_map["line_y2"], line_color) pyxel.rect(obj_map["fill_x1"], obj_map["fill_y1"], obj_map["fill_x2"], obj_map["fill_y2"], bg_color) pyxel.text(obj_map["str_x"], obj_map["str_y"], str, font_color) # x, y, string, color return True
def _draw(self): def part(y): pyxel.cls(0) draw_score() pyxel.blt(40, y, 2, 0, 0, 160, 68, 0) for y in range(256, 32, -6): part(y) yield if btnpA(): # skip animation break blink = itertools.cycle([True]*18+[False]*18).__next__ for c in range(250): part(32) if blink(): pyxel.text(85, 100, "Push A Button", 7) yield if btnpA(): pyxel.play(3, 1) GameState() yield DemoState()
def draw(self): def rect(x, y, w, h, c): pyxel.rect(x + self.offset_x, y + self.offset_y, w, h, c) rect(self.OX, 0, pyxel.width // 2, pyxel.height + 5, 1) # @pyxel.bug? heightでは下まで塗られない rect(self.OX, 0, 5, pyxel.height + 5, 12) rect(pyxel.width // 2 - 5 + self.OX, 0, 5, pyxel.height + 5, 12) [ rect(x + self.OX, y - self.scroll_y, Game.W, Game.H - 1, 12) for x, y in self.floors ] rect(self.mx + self.OX, self.my - self.scroll_y, Game.MW, Game.MH, 8) # player pyxel.text(70 + self.OX, 0, f"{int(-self.scroll_y) // 20+1: 7} F", 7) pyxel.rect((pyxel.width // 2 - self.EnergyMax - 2) // 2 + self.OX, pyxel.height - 5, self.EnergyMax + 2, 4, 0) pyxel.rectb((pyxel.width // 2 - self.EnergyMax - 2) // 2 + self.OX, pyxel.height - 5, self.EnergyMax + 2, 4, 7) pyxel.rect((pyxel.width // 2 - self.EnergyMax - 2) // 2 + 1 + self.OX, pyxel.height - 5 + 1, self.energy, 4 - 2, 10)
def draw(self): pyxel.cls(0) if self.setomaru.is_dead: pyxel.text(100, 128, "GAME OVER", 7) pyxel.text(120, 158, "puress R key", 3) return for shark in self.sharks: if shark.is_dead: pyxel.text(shark.pos.x + 20, shark.pos.y + 25, "+1", 11) else: pyxel.blt(shark.pos.x, shark.pos.y, 1, 0, 0, 50, 50, 0) pyxel.blt(self.setomaru.pos.x, self.setomaru.pos.y, 0, 0, 0, 50, 50, 0) pyxel.circb(pyxel.mouse_x, pyxel.mouse_y, 10, 8) if pyxel.frame_count % 50 < 10: pyxel.text(100, 128, "BIWA SHARK", pyxel.frame_count % 15 + 1) pyxel.text(100, 140, "score :" + str(self.score), 12)
def construction_ui(cls): building_text_y = 60 if not MainUI.main_ui_active: return if MainUI.construction: pyxel.rect(1, 48, 77, 9, 7) pyxel.text(4, 50, "BUILDINGS", 1) for building in buildings.build_list: pyxel.text(4, building_text_y, f"{building.name[0:6]}: {building.built} - [B]", 1) building_text_y += 8 if pyxel.btnr(pyxel.MOUSE_LEFT_BUTTON) and 56 < pyxel.mouse_y < 60: buildings.construct(buildings.hut) elif pyxel.btnr( pyxel.MOUSE_LEFT_BUTTON) and 64 < pyxel.mouse_y < 68: buildings.construct(buildings.clay_house) elif pyxel.btnr( pyxel.MOUSE_LEFT_BUTTON) and 72 < pyxel.mouse_y < 76: buildings.construct(buildings.grain_field)
def draw_game(self): self.check_fuel() self.make_fuel = True 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 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()
def __on_draw(self): x1 = self.x y1 = self.y x2 = x1 + self.width - 1 y2 = y1 + self.height - 1 pyxel.rect(x1 + 1, y1, x2 - 1, y2, WIDGET_BASE_COLOR) pyxel.rect(x1, y1 + 1, x2, y2 - 1, WIDGET_BASE_COLOR) for i in range(2): for j in range(8): x1 = self.x + j * 8 + 1 y1 = self.y + i * 8 + 1 x2 = x1 + 6 y2 = y1 + 6 col = i * 8 + j pyxel.rect(x1, y1, x2, y2, col) x = self.x + (self.value % 8) * 8 + 3 y = self.y + (self.value // 8) * 8 + 2 col = 7 if self.value < 6 else 0 pyxel.text(x, y, "+", col)
def draw(self): #pyxel.cls(15) pyxel.bltm(0, 0, 0, 0, 0, MAP_X, MAP_Y) #pyxel.text(55, 41, "Hello World!", pyxel.frame_count % 16) # draw player pyxel.blt(self.player_x, self.player_y, 0, 0, 0, 16 * (1 - (self.atr << 1)), 16, 12) #pyxel.blt(10, 10, 0, 0 , 0, 16, 16, 12) # draw floors #for x, y, is_active in self.floor: #pyxel.blt(0, 90, 0, 0, 40, 160, 5, 12) for x, y, is_active in self.movefloor: pyxel.blt(x, y, 0, 0, 16, 40, 8, 12) # draw fruits for x, y, kind, is_active in self.fruit: if is_active: pyxel.blt(x, y, 0, 32 + kind * 16, 0, 16, 16, 12) # draw item for x, y, is_active in self.item: pyxel.blt(x, y, 0, 0, 24, 8, 8, 12) # draw score s = "SCORE {:>4}".format(self.score) pyxel.text(5, 4, s, 1) pyxel.text(4, 4, s, 7) #ゲームオーバー中央表示 if self.gameover: pyxel.text((MAP_X >> 1) - 20, (MAP_Y >> 1) + 5, "GAME OVER", 7)
def draw(self): offset = abs(round(math.sin(pyxel.frame_count * 0.1) * 3)) pyxel.cls(13) # Head pyxel.circ(self.x, self.y, 10, 14) # Eyes pyxel.circ(self.x - 4, self.y - 5, 2, 7) pyxel.circ(self.x + 4, self.y - 5, 2, 7) pyxel.rect(self.x - 3, self.y - 4, self.x - 4, self.y - 5, 12) pyxel.rect(self.x + 3, self.y - 4, self.x + 4, self.y - 5, 12) idle_slices = [ (0, 0), (50, 0), (100, 0), (150, 0), ] # Land # rect(x1, y1, x2, y2, col) pyxel.rect(0, 136, 100, 200, 11) pyxel.rect(100, 136, 200, 200, 11) # Animation pyxel.blt(20, 100, 0, idle_slices[offset][0], idle_slices[offset][1], 50, 37, 0) if time.time() - START < 5: pyxel.text(35, 6, "Welcome to dope squares!", randint(1, 15)) pyxel.text(10, 190, f"center: x:{self.x} y:{self.y}", 7) pyxel.text(10, 180, f"offset: {offset}", 7)
def desenhar(): """ Desenha elementos na tela. """ # Fundo azul pyxel.cls(12) # Canos: cada cano é representado por uma tupla (x, y), com a posição do # em x e a altura do cano for (x, y) in canos: pyxel.blt(x, y, 1, 0, 0, 25, 150, 0) pyxel.blt(x, y + ABERTURA, 1, 0, 0, -25, -150, 0) # Chão: desenhamos duas texturas separadas pela largura da tela que # se deslocam 1 pixel por frame offset = -pyxel.frame_count % LARGURA pyxel.bltm(offset, ALTURA - 16, 0, 0, 0, 32, 3) pyxel.bltm(offset - LARGURA, ALTURA - 16, 0, 0, 0, 32, 3) # Flappy frame = (pyxel.frame_count // 4) % 3 pyxel.blt(flappy_x, flappy_y, 0, 0, frame * 16, 17, 13, 0) # Desenha instruções na tela e placar if not ativo: msg = "APERTE ESPACO OU SETA PARA CIMA PARA COMECAR" pyxel.text(LARGURA / 2 - len(msg) * 2, ALTURA / 3, msg, 7) else: pyxel.text(LARGURA // 2, ALTURA // 3, str(score), 7) if morto: msg = "Aperte R para reiniciar" pyxel.text(LARGURA // 2 - len(msg) * 2, ALTURA // 2, msg, 7)
def demoPlay(self): if self.ship.left() == 0: pyxel.text(BEGIN_X + 58, 80, "GAME OVER", 8) pyxel.text(BEGIN_X + 50, 100, "Pyxel Glaxian", 7) pyxel.text(BEGIN_X + 45, 116, "START:SPACE KEY", 7) pyxel.text(BEGIN_X + 50, 132, "HIGH SCORE{}".format(self.score.hi_value()), 7) if pyxel.btnp(pyxel.KEY_SPACE): self.demoMode = False self.alian.stopAttack() self.score.init() self.ship.init() self.scene = 0 self.init()
def draw(self): pyxel.cls(0) pyxel.text(40, 41, self.title, pyxel.frame_count % 16) pyxel.text(40, 61, self.subTitle, pyxel.frame_count % 16) pyxel.text(40, 81, "Press S to Start", pyxel.frame_count % 16) pyxel.blt(self.pyxel_x, self.pyxel_y, 0, 0, 0, 70, 70)
def draw(self): pyxel.cls(12) # draw sky pyxel.blt(0, 88, 0, 0, 88, 160, 32) # draw mountain pyxel.blt(0, 88, 0, 0, 64, 160, 24, 12) # draw forest offset = pyxel.frame_count % 160 for i in range(2): pyxel.blt(i * 160 - offset, 104, 0, 0, 48, 160, 16, 12) # draw fruits for x, y, kind, is_active in self.fruit: if is_active: pyxel.blt(x, y, 0, 32 + kind * 16, 0, 16, 16, 12) # draw unique pyxel.blt( math.sin(pyxel.frame_count * 0.09 % 90) * 90, 30, 0, 80, 0, 16, 16, 12) # draw player pyxel.blt( self.player_x, self.player_y, 0, 16 if self.player_jump == True else 0, 0, 16, 16, 12, ) # draw score s = "SCORE {:>4}".format(self.score) pyxel.text(5, 4, s, 1) pyxel.text(4, 4, s, 7)
def __on_draw(self): pyxel.blt(self.x, self.y, 3, EDITOR_IMAGE_X, EDITOR_IMAGE_Y + 132, 97, 23) pyxel.blt(self.x + 97, self.y, 3, EDITOR_IMAGE_X, EDITOR_IMAGE_Y + 132, -96, 23) sound = pyxel.sound(self.parent.sound) cursor_x = self.parent.cursor_x cursor_y = self.parent.cursor_y if self.parent.play_pos < 0 else 0 if cursor_y > 0: x = self.parent.edit_x * 4 + 31 y = cursor_y * 8 + 142 pyxel.rect(x, y - 1, x + 2, y + 5, 1) for i, tone in enumerate(sound.tone): 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(sound.volume): 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(sound.effect): col = 7 if cursor_y == 3 and cursor_x == i else 1 pyxel.text(31 + i * 4, 166, "NSVF"[effect], col)
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 draw_text(self): if self.dead and self.start: px.text(1, px.height * 1 / 5, f"{(len(self.snake)-4)*100} points", COL_TEXT) px.text(1, px.height * 3 / 5, "Press R to restart", COL_TEXT) elif self.dead and not self.start: px.text(1, px.height * 1 / 2, "Press Space to start", COL_TEXT)
def draw(self): if self.game_state == 'start': # 显示开始画面 pyxel.cls(12) pyxel.text(36, 50, 'Flappy Bird', 8) pyxel.text(20, 60, 'Press Space to Play!', 1) pyxel.blt(50, 76, 0, 0, 2, 16, 11, 0) elif self.game_state == 'playing': pyxel.cls(12) pyxel.blt(0, 151, 1, 0, 17, 120, 23, 0) # 显示小鸟 pyxel.blt( self.bird_pos[0], self.bird_pos[1], 0, 0, 2, 16, 11, 0) pipe_length = 120 - self.pipe_top_pos[1] pyxel.blt( self.pipe_top_pos[0], 0, 0, 32, pipe_length, 16, self.pipe_top_pos[1], 0) pyxel.blt( self.pipe_bot_pos[0], self.pipe_bot_pos[1], 0, 32, 128, 16, 128, 0) pyxel.blt(0, 174, 1, 0, 0, 120, 6, 0) pyxel.text(80, 10, 'Score:' + str(self.score), 2)
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, )
def draw(self): pyxel.cls(pyxel.COLOR_LIGHTBLUE) for body in self.space.bodies: if isinstance(body, (Player)): body.draw(self.camera) else: self.camera.draw(body) # Desenha texto informativo pyxel.text( 5, 5, "Setas para controlar o personagem (ele tem 3 pulos)\nR para resetar", pyxel.COLOR_BLACK) info_text = "Posicao: (" + str(round( self.player.position[0], 3)) + ", " + str( round(self.player.position[1], 3)) + ")\n" + "Velocidade: (" + str( round(self.player.velocity.x, 3)) + ", " + str( round(self.player.velocity.y, 3)) + ")\n" + "Pulos Restantes: " + str( self.player.remaining_jumps) pyxel.text(5, 30, info_text, pyxel.COLOR_BLACK) msg = "" if self.paused: msg = 'PAUSED' if msg: x = (WIDTH - len(msg) * pyxel.FONT_WIDTH) / 2 pyxel.text(round(x), HEIGHT // 2, msg, pyxel.COLOR_RED)
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)
def draw(self): # clear screen pyxel.cls(1) # draw all the blocks in the grid for i in range(len(self.block_array)): # draw only if there is a block there if self.block_array[i] is not None: x, y = self.index_to_coordinates(i) pyxel.rect(x, y, x + 9, y + 9, self.block_array[i].color) # draw the gameblocks if self.gameon: self.gb.draw() self.nb.draw() # draw dashboard pyxel.text(100, 10, "SCORE: " + str(self.score), 6) pyxel.text(100, 30, "HIGH SCORE: " + str(self.highscore), 6) pyxel.text(100, 240, self.label, 6) # draw floor and walls pyxel.rect(1, 240, 88, 248, 12) pyxel.rect(1, 0, 8, 247, 12) pyxel.rect(81, 0, 88, 247, 12) # bar pyxel.rect(1, 50, 8, 52, 10) pyxel.rect(81, 50, 88, 52, 10)
def draw(self, show_labels, eye_debug): pyxel.circ(self.x, self.y, self.radius, self.colour) # Debug visualiser for eyesight if eye_debug: for eye in range(self.NUM_EYES): eye_rel = self.NUM_EYES // 2 - eye if self.NUM_EYES % 2 == 0: eye_rel -= 0.5 eye_offset = eye_rel * self.eye_angle * 2 #if eye % 2 == 0: # continue dist = self.eyesight - self.eyes[eye][self.EYE_DIST] pyxel.line( self.x, self.y, self.x + math.cos(eye_offset + self.rot + self.eye_angle) * min(self.eyesight, dist), self.y + math.sin(eye_offset + self.rot + self.eye_angle) * min(self.eyesight, dist), 5) pyxel.line( self.x, self.y, self.x + math.cos(eye_offset + self.rot - self.eye_angle) * min(self.eyesight, dist), self.y + math.sin(eye_offset + self.rot - self.eye_angle) * min(self.eyesight, dist), 5) pyxel.line(self.x + math.cos(self.rot) * 2, self.y + math.sin(self.rot) * 2, self.x + math.cos(self.rot + math.pi * 3 / 4) * 3, self.y + math.sin(self.rot + math.pi * 3 / 4) * 3, self.colour) pyxel.line(self.x + math.cos(self.rot) * 2, self.y + math.sin(self.rot) * 2, self.x + math.cos(self.rot - math.pi * 3 / 4) * 3, self.y + math.sin(self.rot - math.pi * 3 / 4) * 3, self.colour) if self.repr_anim > 0: pyxel.text(self.x, self.y - 10, "+", 15) if show_labels: pyxel.text(self.x - 10, self.y + 10, str(self.species) + '-' + str(self.gen), 15) if self.heart_anim: pyxel.text(self.x + 10, self.y - 10, "<3", 15) else: pyxel.text(self.x + 10, self.y - 10, str(math.floor(self.hunger)), 15)
def draw(self): pyxel.bltm(0, 0, 0, 0, 0, MAP_WIDTH, MAP_HEIGHT) pyxel.text(4, 4, "POINTS " + str(self.score), 7) if self.mGameOver: # à faire écrire les meilleures resultats pyxel.text(20, 80, "C'est fini!", 7) pyxel.text(10, 90, "Votre resultat est: {0}".format(self.score), 7)
def draw(self): pyxel.cls(0) # blt arguments: # x position = 10 # y position = 10 # img bank (0-2) = 0 # u img/texture coordinate = 0 # v img/texture coordinate = 0 # w img/texture width = 100 # v img/texture/height = 100 # Show how to load sprites from a second image bank. pyxel.text( 5, 50, f'Sprite Clip Position: ({self.sprite_clip_x}, {self.sprite_clip_y})', 7) # Place the sprite at (100, 100) pyxel.blt(100, 100, MARIO_IMG_BANK, self.sprite_clip_x, self.sprite_clip_y, self.sprite_cell_width, self.sprite_cell_height, COLORKEY_COLOR)