def draw_defeat(self): # draw defeat interface arcade.draw_rectangle_filled(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, SCREEN_WIDTH, SCREEN_HEIGHT, arcade.color.RED) arcade.draw_text("YOU LOSE", SCREEN_WIDTH / 2 - 70, SCREEN_HEIGHT / 2, arcade.color.WHITE_SMOKE, font_size=35) # display your scores arcade.draw_text(f"Score: {str(self.snake.score)}", SCREEN_WIDTH / 2 - 50, SCREEN_HEIGHT / 2 - 50, arcade.color.BLACK, font_size=35) xb2, yb2, wb2, hb2 = button_b2 arcade.draw_xywh_rectangle_filled(xb2, yb2, wb2, hb2, arcade.color.WHITE_SMOKE) arcade.draw_text("* Back", xb2, yb2, arcade.color.ROSE_GOLD, font_size=20)
def draw_player(self): # torso arcade.draw_xywh_rectangle_filled(self.x, self.y, self.width, self.height, arcade.color.BLUE) # head arcade.draw_circle_filled(self.x + self.radius, self.y + self.height + self.radius, self.radius, arcade.color.YELLOW) # legs arcade.draw_xywh_rectangle_filled(self.x, self.y - self.height, self.radius - 1, self.height, arcade.color.RED) arcade.draw_xywh_rectangle_filled(self.x + self.radius + 1, self.y - self.height, self.radius - 1, self.height, arcade.color.RED) # arms arcade.draw_xywh_rectangle_filled(self.x - self.arm_width, self.y + self.height * 0.2, self.arm_width, self.height * 0.8, arcade.color.RED) arcade.draw_xywh_rectangle_filled(self.x + self.width, self.y + self.height * 0.2, self.arm_width, self.height * 0.8, arcade.color.RED)
def draw_menu(self): # button_i for instruction, button_s for start xi, yi, wi, hi = button_i xs, ys, ws, hs = button_s arcade.start_render() arcade.set_background_color(arcade.color.VANILLA) # display buttons and texts arcade.draw_text("Snakes", width / 4 + 40, height / 4 * 3, arcade.color.BLACK, font_size=50) arcade.draw_xywh_rectangle_filled(xi, yi, wi, hi, arcade.color.WHITE_SMOKE) arcade.draw_xywh_rectangle_filled(xs, ys, ws, hs, arcade.color.WHITE_SMOKE) arcade.draw_text("* Instructions", width / 4 + 30, height / 2 - 80, arcade.color.BLACK, font_size=35) arcade.draw_text( "* Start", width / 4 + 30, height / 2 + 50, arcade.color.BLACK, font_size=35, )
def on_draw(): global screen arcade.start_render() if screen == "death": arcade.draw_text(f"You got {str(player_points)}!", 60, 60, arcade.color.BLACK, 12) arcade.draw_text("Press enter to restart the game", 60, 30, arcade.color.BLACK, 12) elif screen == "playing": # Draw the player arcade.draw_ellipse_filled(pos_x, pos_y, 8, 5, arcade.color.SCHOOL_BUS_YELLOW) # Draw all the pipes for pipe in list_of_pipes: arcade.draw_xywh_rectangle_filled(pipe[0], pipe[1] + pipe_height, pipe_width, HEIGHT, arcade.color.GO_GREEN) arcade.draw_xywh_rectangle_filled(pipe[0], 0, pipe_width, pipe[1], arcade.color.GO_GREEN) arcade.draw_text(str(player_points), WIDTH / 2, HEIGHT - 15, arcade.color.BLACK, 12)
def draw_play(): arcade.set_background_color(arcade.color.BLACK) if button_pause[BTN_IS_CLICKED]: color3 = button_pause[BTN_CLICKED_COLOR] else: color3 = button_pause[BTN_COLOR] arcade.draw_xywh_rectangle_filled(button_pause[BTN_X] - 1, button_pause[BTN_Y] - 1, button_pause[BTN_WIDTH] + 3, button_pause[BTN_HEIGHT] + 3, button_pause[BTN_OUTLINE_COLOR]) arcade.draw_xywh_rectangle_filled(button_pause[BTN_X], button_pause[BTN_Y], button_pause[BTN_WIDTH], button_pause[BTN_HEIGHT], color3) arcade.draw_text("=", button_pause[BTN_X] + 12, button_pause[BTN_Y] + 7, arcade.color.WHITE, font_size=40) arcade.draw_text(f"Lives: {health}", 30, 30, arcade.color.ASH_GREY, font_size=40) arcade.draw_text(f"Score: {score}", 1000, 680, arcade.color.ASH_GREY, font_size=40)
def on_draw(self): arcade.start_render() arcade.draw_text("Game Over", SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, arcade.color.BLACK, font_size=75, anchor_x="center") arcade.draw_xywh_rectangle_filled(SCREEN_WIDTH / 2 - 100, SCREEN_HEIGHT / 2 - 50, 200, 50, arcade.color.BLACK) arcade.draw_text("RESTART", SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - 50, arcade.color.WHITE, font_size=40, anchor_x="center") output = f"SCORE: {self.score}" arcade.draw_text(output, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - 200, arcade.color.WHITE, font_size=40, anchor_x="center") self.crosshair.draw()
def draw_character_screen(self): arcade.draw_xywh_rectangle_filled( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, colors["status_panel_background"], ) spacing = 1.8 y_value = SCREEN_HEIGHT - 50 x_value = 10 text_size = 24 text = "Character Screen" arcade.draw_text(text, x_value, y_value, colors['status_panel_text'], text_size) y_value -= text_size * spacing text_size = 20 texts = [ f"Attack: {self.game_engine.player.fighter.power}", f"Defense: {self.game_engine.player.fighter.defense}", f"HP: {self.game_engine.player.fighter.hp} / {self.game_engine.player.fighter.max_hp}", f"Max Inventory: {self.game_engine.player.inventory.capacity}", f"Level: {self.game_engine.player.fighter.level}", ] for text in texts: arcade.draw_text(text, x_value, y_value, colors['status_panel_text'], text_size) y_value -= text_size * spacing if self.game_engine.player.fighter.ability_points > 0: self.character_sheet_buttons.draw()
def on_draw(self): health_x = 20 health_y = screen_height - 50 """ Render the screen. """ # This command has to happen before we start drawing arcade.start_render() # Draw the background texture arcade.draw_texture_rectangle(screen_width // 2, screen_height // 2, screen_width, screen_height, self.rooms[self.current_room].background) # Draw all the walls in this room self.rooms[self.current_room].wall_list.draw() # If you have coins or monsters, then copy and modify the line # above for each list. if self.current_room != 0 and self.current_room == 1: self.enemy_list.draw() self.bullet_list.draw() self.player_list.draw() self.explosions_list.draw() for i in range(health): arcade.draw_xywh_rectangle_filled(health_x, health_y, 20, 20, arcade.color.BLUE) health_x += 50
def draw(self): """Draw the rectangle based on the current state """ arcade.draw_xywh_rectangle_filled(self.x, self.y, self.width, self.height, self.fill_color) arcade.draw_xywh_rectangle_outline(self.x, self.y, self.width, self.height, self.pen_color, 3)
def on_draw(self): arcade.start_render() arcade.draw_lrwh_rectangle_textured(0, 0, 640, 640, self.bg) self.player.draw() self.enemy.draw() self.energy.draw() arcade.draw_text('YOU', 10, 610, arcade.color.BLUE, 14, bold=True) arcade.draw_text('OPPONENT', 530, 610, arcade.color.ROSE, 14, bold=True) arcade.draw_xywh_rectangle_filled(10, 590, self.player.life, 10, arcade.color.BLUE) arcade.draw_xywh_rectangle_filled(630 - self.enemy.life, 590, self.enemy.life, 10, arcade.color.ROSE) arcade.draw_text(str(self.player.energy), 30, 560, arcade.color.BLACK, 18, bold=True) if self.game == 'Lose': texture = arcade.load_texture('res\lose.png') arcade.draw_lrwh_rectangle_textured(192, 80, 256, 128, texture) if self.game == 'Won': texture = arcade.load_texture('res\won.png') arcade.draw_lrwh_rectangle_textured(192, 80, 256, 128, texture)
def chest(x, y, w, h): arcade.draw_xywh_rectangle_filled(x, y, w, h, arcade.color.DARK_BROWN) arcade.draw_xywh_rectangle_filled(x + 12.5, y + 10, 5, 5, arcade.color.GRAY) arcade.draw_xywh_rectangle_filled(x, y, 2.5, h, arcade.color.GOLD) arcade.draw_xywh_rectangle_filled(x + 27.5, y, 2.5, h, arcade.color.GOLD) arcade.draw_xywh_rectangle_filled(x, y + 10, w, 1, arcade.color.BLACK)
def on_draw(self): """ Render the screen. """ # Clear the screen to the background color arcade.start_render() # Draw our sprites # self.wall_list.draw() # invisible # self.answer_sprites.draw() # invisible self.bg_list.draw() self.sky_scraper_sprites.draw() self.player_sprite.draw() self.draw_stats() w = 200 h = 60 arcade.draw_xywh_rectangle_filled(SCREEN_WIDTH // 2 - w // 2 + self.view_left, SCREEN_HEIGHT - h, width=w, height=h, color=arcade.color.BLACK) arcade.draw_text(self.equations[0].equationUnsolved(), self.view_left + SCREEN_WIDTH // 2, 600 + self.view_bottom, arcade.csscolor.WHITE, 18, anchor_x="center")
def on_key_press(self, key, modifiers): global undocount """Called whenever a key is pressed. """ # Reset Screen if key == game.key.P: point.plot() point.connect() if key == game.key.R: point.clear() # Undo last Action if key == game.key.U: if undocount >= 10: point.clear() if debugExec: print("Before:") print(code) print(lines) print("After:") code.pop() lines.pop(realindex) point.points.pop(realindex) if debugExec: print(code) print(realindex) print(lines) point.connect() for i in range(2): game.draw_xywh_rectangle_filled(WIDTH, HEIGHT, 0, 0, Colors.black) undocount += 1 point.check()
def on_draw(): arcade.start_render() # Draw in here... #Add image texture = arcade.load_texture("wig2.png") scale = 0.5 arcade.draw_texture_rectangle(240, 420, scale * texture.width, scale * texture.height, texture, 0) #Shapes arcade.draw_circle_filled(240, 440, 50, arcade.color.PEACH_YELLOW) arcade.draw_circle_filled(240, 0, 350, arcade.color.COCOA_BROWN) arcade.draw_rectangle_filled(240, 370, 150, 100, arcade.color.ASH_GREY) arcade.draw_rectangle_filled(240, 320, 40, 75, arcade.color.BATTLESHIP_GREY) arcade.draw_text("DON'T BE MEAN", 110, 220, arcade.color.BLACK, 30) arcade.draw_text("BEHIND THE SCREEN", 75, 180, arcade.color.BLACK, 30) arcade.draw_text("YOU have the", 80, 110, arcade.color.BLACK, 30) #Eyes arcade.draw_line(200, 460, 220, 450, arcade.color.BLACK_LEATHER_JACKET, 4) arcade.draw_line(280, 460, 260, 450, arcade.color.BLACK_LEATHER_JACKET, 4) #Button arcade.draw_xywh_rectangle_filled(my_button[0], my_button[1], my_button[2], my_button[3], arcade.color.WARM_BLACK) arcade.draw_text("Ctrl", 325, 110, arcade.color.WHITE_SMOKE, 20) #Add image texture = arcade.load_texture("computer_mouse.png") scale = .1 arcade.draw_texture_rectangle(x, 300, scale * texture.width, scale * texture.height, texture, 130)
def on_draw(self): w_sum = self._label.get_size()[0] if len(self._diff_label.text) > 0: w_sum += 10 + self._diff_label.get_size()[0] arcade.draw_xywh_rectangle_filled(self._label.x - 2, self._label.y - 2, w_sum + 4, self._label.get_size()[1] + 4, (0, 0, 0, 200)) self._label.on_draw() self._diff_label.on_draw()
def draw(self): with self.light_layer: arcade.draw_xywh_rectangle_filled(0, 0, self.screen_width, self.screen_height, arcade.color.WHITE) self.light_layer.draw(ambient_color=arcade.color.BLACK) self.coils.draw() self.coils.update(0.0) # to make sure coils get reaped from ActorList
def placement(x, y, end, space): for tree in range(x, end): if x <= end: arcade.draw_xywh_rectangle_filled(x, y, 10, 30, arcade.color.GREEN) arcade.draw_triangle_filled(x - 10, y + 30, x + 20, y + 30, x + 5, y + 100, arcade.color.BROWN) x += space
def on_draw(): arcade.start_render() # Draw in here... # arcade.draw_shape_etc (x-coord, y-coord, radius, colour) arcade.draw_circle_filled(player_x, player_y, 200, arcade.color.YELLOW) arcade.draw_ellipse_filled(255, 300, 20, 45, arcade.color.BLACK) arcade.draw_ellipse_filled(395, 300, 20, 45, arcade.color.BLACK) arcade.draw_xywh_rectangle_filled(265, 135, 120, 60, arcade.color.BLACK)
def draw_start_screen_animation(): global start_key_rgb, on_start_screen, on_play_screen arcade.draw_xywh_rectangle_filled(0, 0, WIDTH, HEIGHT, start_key_rgb) if on_start_screen: arcade.set_background_color(arcade.color.WHITE) elif on_play_screen: arcade.set_background_color(arcade.color.BLACK)
def home_page_draw(): """Draws the home page """ arcade.draw_text("HYPERSPACE", 25, HEIGHT/2 * 1.5, arcade.color.WHITE, 100) arcade.draw_xywh_rectangle_filled(WIDTH/6, HEIGHT/2, 500, 100, button_color) arcade.draw_text("Play", WIDTH/2 - 75, HEIGHT/2 + 15, arcade.color.WHITE, 75) arcade.draw_xywh_rectangle_filled(WIDTH/6, HEIGHT/4, 500, 100, button_color_two) arcade.draw_text("How to play", WIDTH/6 + 25, HEIGHT/4 + 10, arcade.color.WHITE, 75)
def on_draw(): arcade.start_render() # Draw in here... arcade.draw_xywh_rectangle_filled(my_button[0], my_button[1], my_button[2], my_button[3], arcade.color.BLACK)
def on_draw(): arcade.start_render() # screens and fish if current_screen == "menu": arcade.draw_text("Fishy", WIDTH / 4, HEIGHT / 2, arcade.color.WHITE, font_size=100) arcade.draw_text("press I for instructions ", WIDTH / 2, HEIGHT / 2 - 30, arcade.color.RED) arcade.draw_text("press P for play screen", WIDTH / 2, HEIGHT / 2 - 60, arcade.color.RED) arcade.draw_circle_filled(fish[0], fish[1], 100, arcade.color.ORANGE) arcade.draw_circle_filled(fish[0] + 40, fish[1], 15, arcade.color.BLACK) arcade.draw_triangle_filled(fish[0], fish[1], fish[0] - 50, fish[1] + 10, fish[0] - 50, fish[1] - 50, arcade.color.ORANGE) elif current_screen == "instruction": arcade.draw_text( "instructions: W= up S= down A= left D = right - collect bubbles and move away from other objects", WIDTH / 16, HEIGHT / 2, arcade.color.RED) arcade.draw_text("press esc to go back to main menu", WIDTH / 16, HEIGHT / 2 - 30, arcade.color.RED) elif current_screen == "over": arcade.draw_text("GAME OVER", WIDTH / 16, HEIGHT / 2, arcade.color.RED, font_size=100) # seaweed drawing if current_screen == "play": for x, y in zip(seaweed_x, seaweed_y): arcade.draw_rectangle_filled(x, y, 10, 80, arcade.color.SPRING_GREEN) # bubble drawing if current_screen == "play": for x, y in zip(bubble_x, bubble_y): arcade.draw_circle_filled(x, y, 5, arcade.color.LIGHT_BLUE) # fish if current_screen == "play": arcade.draw_circle_filled(fish[0], fish[1], 25, arcade.color.ORANGE) arcade.draw_circle_filled(fish[0] + 10, fish[1], 2, arcade.color.BLACK) # health bar drawing if current_screen == "play": max_bar_width = 200 bar_height = 50 arcade.draw_xywh_rectangle_filled(WIDTH / 2 - max_bar_width / 2, HEIGHT - bar_height, max_bar_width, bar_height, arcade.color.BLUE) health_width = player_health / player_max_health * max_bar_width arcade.draw_xywh_rectangle_filled(WIDTH / 2 - max_bar_width / 2, HEIGHT - bar_height, health_width, bar_height, arcade.color.GREEN)
def on_draw(): arcade.start_render() if button_pressed: color = arcade.color.ASH_GREY else: color = arcade.color.BLACK # Draw in here... arcade.draw_xywh_rectangle_filled(my_button[0], my_button[1], my_button[2], my_button[3], color)
def draw_telemetry(self): telemetry = 'скорость: {} \n'.format(self.robot.speed) + \ 'топливо: {} %\n'.format(round(self.robot.fuel)) + \ 'в поле: {} \n'.format(len(self.resurse_list)) + \ 'на борту: {} \n'.format(self.robot.box_current) arcade.draw_xywh_rectangle_filled(5, 10, 150, 100, arcade.color.DARK_BLUE_GRAY) arcade.draw_xywh_rectangle_outline(5, 10, 150, 100, arcade.color.BLACK, 4) arcade.draw_text(telemetry, 10, 15, arcade.color.YELLOW, 16, anchor_x="left")
def on_draw(): arcade.start_render() x = 300 y = 50 for x in range(0, 640, 60): arcade.draw_triangle_filled(x - 20, y + 50, x + 5, y + 150, x + 30, y + 50, arcade.color.DARK_GREEN) arcade.draw_xywh_rectangle_filled(x, y, 10, 50, arcade.color.DARK_BROWN)
def on_draw(): arcade.start_render() # Draw in here... arcade.draw_rectangle_filled(320, 240, 200, 50, arcade.color.RED) arcade.draw_xywh_rectangle_filled( 220, 215, player_health / size_multiplier_healthbar, 50, arcade.color.GREEN) arcade.draw_text(str(f'{player_health} / {player_max_health}'), 285, 235, arcade.color.BLACK)
def on_draw(): arcade.start_render() # Draw in here... arcade.draw_xywh_rectangle_filled(my_button[0], my_button[1], my_button[2], my_button[3], arcade.color.BLACK) if show_text: arcade.draw_text("the button was clicked", 100, 300, arcade.color.RED, 12)
def draw(self): self.sprite.draw() if self.is_attacked: arcade.draw_xywh_rectangle_filled(self.sprite.center_x - (self.sprite.width / 2.5), self.sprite.center_y + (self.sprite.height / 2), 100, 5, arcade.color.RED) arcade.draw_xywh_rectangle_filled(self.sprite.center_x - (self.sprite.width / 2.5), self.sprite.center_y + (self.sprite.height / 2), self.health, 5, arcade.color.GREEN)
def on_draw(): y = 0 arcade.start_render() # Draw in here... for x in range(0, 640, 60): arcade.draw_xywh_rectangle_filled(x, y, 25, 50, arcade.color.BROWN) arcade.draw_triangle_filled(x-12.5, y+50, x+12.5, y+125, x+37.5, y+50, arcade.color.FOREST_GREEN)
def on_draw(player): arcade.start_render() arcade.draw_text("Pokedex", 20, 570, arcade.color.BLACK, 50) arcade.draw_text("Total Caught:", 20, 520, arcade.color.BLACK, 30) arcade.draw_text(str(len(player.poke_list)), 250, 520, arcade.color.BLACK, 30) arcade.draw_text("Q - Sort", 30, 30, arcade.color.BLACK, 60) arcade.draw_text("E - Search", 370, 30, arcade.color.BLACK, 60) arcade.draw_xywh_rectangle_filled(0, 173, 768, 320, arcade.color.WHITE) arcade.draw_xywh_rectangle_outline(10, 405, 450, 70, arcade.color.GRAY, 3) arcade.draw_xywh_rectangle_outline(5, 290, 460, 90, arcade.color.BLACK, 5) arcade.draw_xywh_rectangle_outline(10, 193, 450, 70, arcade.color.GRAY, 3) if player.get_pointer() - 1 != -1: arcade.draw_text( "{}: {}".format(player.poke_list[player.get_pointer() - 1].num, player.poke_list[player.get_pointer() - 1].name), 20, 425, arcade.color.BLACK, 20) arcade.draw_text( "{}: {}".format(player.poke_list[player.get_pointer()].num, player.poke_list[player.get_pointer()].name), 20, 320, arcade.color.BLACK, 30) if player.get_pointer() + 1 != len(player.poke_list): arcade.draw_text( "{}: {}".format(player.poke_list[player.get_pointer() + 1].num, player.poke_list[player.get_pointer() + 1].name), 20, 213, arcade.color.BLACK, 20) arcade.draw_triangle_filled(475, 335, 495, 315, 495, 355, arcade.color.BLACK) arcade.draw_xywh_rectangle_outline(500, 210, 250, 250, arcade.color.BLACK, 10) arcade.draw_texture_rectangle( 625, 335, 240, 240, player.poke_list[player.get_pointer()].texture) if player.search_menu: arcade.draw_xywh_rectangle_filled(100, 100, 568, 440, arcade.color.BLACK) arcade.draw_xywh_rectangle_filled(110, 110, 548, 420, arcade.color.WHITE) arcade.draw_text("Enter Pokemon Number:", 140, 450, arcade.color.BLACK, 35) arcade.draw_text(" " + player.search_number, 140, 200, arcade.color.BLACK, 220) if player.sort_menu: arcade.draw_xywh_rectangle_filled(100, 100, 568, 440, arcade.color.BLACK) arcade.draw_xywh_rectangle_filled(110, 110, 548, 420, arcade.color.WHITE) arcade.draw_text("Do you want to sort", 115, 380, arcade.color.BLACK, 50) arcade.draw_text("the Pokedex?", 175, 310, arcade.color.BLACK, 50)