def on_draw(delta_time): """ Use this function to draw everything to the screen. """ # Start the render. This must happen before any drawing # commands. We do NOT need a stop render command. arcade.start_render() # Draw a rectangle. # For a full list of colors see: # http://pythonhosted.org/arcade/arcade.color.html arcade.draw_rectangle_filled(on_draw.center_x, on_draw.center_y, RECT_WIDTH, RECT_HEIGHT, arcade.color.ALIZARIN_CRIMSON) # Modify rectangles position based on the delta # vector. (Delta means change. You can also think # of this as our speed and direction.) on_draw.center_x += on_draw.delta_x * delta_time on_draw.center_y += on_draw.delta_y * delta_time # Figure out if we hit the edge and need to reverse. if on_draw.center_x < RECT_WIDTH // 2 \ or on_draw.center_x > SCREEN_WIDTH - RECT_WIDTH // 2: on_draw.delta_x *= -1 if on_draw.center_y < RECT_HEIGHT // 2 \ or on_draw.center_y > SCREEN_HEIGHT - RECT_HEIGHT // 2: on_draw.delta_y *= -1
def draw_pine_tree(x, y): """ This function draws a pine tree at the specified location. """ # Draw the trunk arcade.draw_rectangle_filled(x + 30, y - 100, 20, 40, arcade.color.DARK_BROWN) # Draw the triangle on top of the trunk point_list = ((x + 40, y), (x, y - 100), (x + 80, y - 100)) arcade.draw_polygon_filled(point_list, arcade.color.DARK_GREEN)
def draw_background(): """ This function draws the background. Specifically, the sky and ground. """ # Draw the sky in the top two-thirds arcade.draw_rectangle_filled(0, SCREEN_HEIGHT - 1, SCREEN_WIDTH - 1, SCREEN_HEIGHT * 2 / 3, arcade.color.SKY_BLUE) # Draw the ground in the bottom third arcade.draw_rectangle_filled(0, SCREEN_HEIGHT / 3, SCREEN_WIDTH - 1, SCREEN_HEIGHT / 3, arcade.color.DARK_SPRING_GREEN)
def draw_pine_tree(center_x, center_y): """ This function draws a pine tree at the specified location. Args: :center_x: x position of the tree center. :center_y: y position of the tree trunk center. """ # Draw the trunkcenter_x arcade.draw_rectangle_filled(center_x, center_y, 20, 40, arcade.color.DARK_BROWN) tree_bottom_y = center_y + 20 # Draw the triangle on top of the trunk point_list = ((center_x - 40, tree_bottom_y), (center_x, tree_bottom_y + 100), (center_x + 40, tree_bottom_y)) arcade.draw_polygon_filled(point_list, arcade.color.DARK_GREEN)
def on_draw(self): """ Render the screen. """ # This command has to happen before we start drawing arcade.start_render() # Draw the grid for row in range(10): for column in range(10): # Figure out what color to draw the box if self.grid[row][column] == 1: color = arcade.color.GREEN else: color = arcade.color.WHITE # Do the math to figure out where the box is x = (MARGIN + WIDTH) * column + MARGIN + WIDTH // 2 y = (MARGIN + HEIGHT) * row + MARGIN + HEIGHT // 2 # Draw the box arcade.draw_rectangle_filled(x, y, WIDTH, HEIGHT, color)
def on_draw(delta_time): """ Use this function to draw everything to the screen. """ # Start the render. This must happen before any drawing # commands. We do NOT need an stop render command. arcade.start_render() # Draw our rectangle arcade.draw_rectangle_filled(on_draw.x, on_draw.y, RECT_WIDTH, RECT_HEIGHT, arcade.color.BLACK) # Modify rectangles position based on the delta # vector. (Delta means change. You can also think # of this as our speed and direction.) on_draw.x += on_draw.delta_x on_draw.y += on_draw.delta_y # Figure out if we hit the edge and need to reverse. if on_draw.x < RECT_WIDTH // 2 or on_draw.x > SCREEN_WIDTH - RECT_WIDTH // 2: on_draw.delta_x *= -1 if on_draw.y < RECT_HEIGHT // 2 or on_draw.y > SCREEN_HEIGHT - RECT_HEIGHT // 2: on_draw.delta_y *= -1
# draw sky arcade.set_background_color(arcade.csscolor.SKY_BLUE) arcade.start_render() # draw a stop sign arcade.draw_polygon_filled(((400, 475), (300, 475), (250, 400), (250, 300), (300, 225), (400, 225), (450, 300), (450, 400)), arcade.csscolor.CRIMSON) # draw grass arcade.draw_rectangle_filled(300, 100, 600, 200, arcade.csscolor.GREEN) # draw stop sign post arcade.draw_rectangle_filled(350, 175, 20, 100, arcade.csscolor.LIGHT_GREY) # draw the stop text arcade.draw_text("STOP", 285, 320, arcade.csscolor.WHITE, 50) # draw the sun arcade.draw_circle_filled(20, 500, 50, arcade.csscolor.YELLOW) # draw the road
def draw_section_8(): for column in range(31): for row in range(column): x = 895 + (column * 10) y = 595 + (row * -10) arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE)
# Get ready to draw arcade.start_render() # Draw the grass arcade.draw_lrtb_rectangle_filled(0, 800, 200, 0, arcade.color.BITTER_LIME) # --- Draw the barn --- # Barn cement base arcade.draw_lrtb_rectangle_filled(30, 350, 210, 170, arcade.color.BISQUE) # Bottom half arcade.draw_lrtb_rectangle_filled(30, 350, 350, 210, arcade.color.BROWN) # Left-bottom window arcade.draw_rectangle_filled(70, 260, 30, 40, arcade.color.BONE) arcade.draw_rectangle_filled(70, 260, 20, 30, arcade.color.BLACK) # Right-bottom window arcade.draw_rectangle_filled(310, 260, 30, 40, arcade.color.BONE) arcade.draw_rectangle_filled(310, 260, 20, 30, arcade.color.BLACK) # Barn door arcade.draw_rectangle_filled(190, 230, 100, 100, arcade.color.BLACK_BEAN) # Rail above the door arcade.draw_rectangle_filled(190, 280, 180, 5, arcade.color.BONE) # Draw second level of barn arcade.draw_polygon_filled([[20, 350], [100, 470], [280, 470], [360, 340]], arcade.color.BROWN)
def on_draw(): arcade.start_render() # Draw in here... arcade.draw_rectangle_filled(center_x, center_y, RECT_WIDTH, RECT_HEIGHT, arcade.color.ALIZARIN_CRIMSON)
def draw(self): """Draw itself on the screen.""" arcade.draw_rectangle_filled(self.position_x, self.position_y, self.size_x, self.size_y, self.color)
def second_draw(): """The on_draw function for the second level""" # set global variables global GRID, row, column, color, level2, x, y, win # set up the grid so that every square can be given a variable for row in range(20): for column in range(21): # set up the walls in the grid if row == 0 or row == 19 or (column == 0 and row != 1) or (column == 19 and row != 18): GRID[row][column] = 1 if column == 20: GRID[row][column] = 3 # list all possible variables and the corresponding color # floor if GRID[row][column] == 0: color = arcade.color.BLACK # walls elif GRID[row][column] == 1: color = arcade.color.PURPLE # player elif GRID[row][column] == 2: color = arcade.color.BLUE # invisible wall at the end of the level elif GRID[row][column] == 3: color = arcade.color.BLACK # blue teleporter elif GRID[row][column] == 4: color = arcade.color.BLUEBERRY # beige teleporter elif GRID[row][column] == 5: color = arcade.color.VIOLET_RED # indigo teleporter elif GRID[row][column] == 6: color = arcade.color.INDIGO # pink teleporter elif GRID[row][column] == 7: color = arcade.color.PURPLE_PIZZAZZ # yellow gate elif GRID[row][column] == 8: color = arcade.color.YELLOW # yellow key elif GRID[row][column] == 9: color = arcade.color.DARK_YELLOW # green gate elif GRID[row][column] == 10: color = arcade.color.GREEN # green key elif GRID[row][column] == 11: color = arcade.color.BOTTLE_GREEN # red gate elif GRID[row][column] == 12: color = arcade.color.RED # red key elif GRID[row][column] == 13: color = arcade.color.RUBY_RED # gray gate elif GRID[row][column] == 14: color = arcade.color.DARK_GRAY # gray key elif GRID[row][column] == 15: color = arcade.color.GRAY # create a size for each square in the grid x = (MARGIN + WIDTH) * column + MARGIN + WIDTH // 2 y = (MARGIN + WIDTH) * row + MARGIN + WIDTH // 2 arcade.draw_rectangle_filled(x, y, HEIGHT, WIDTH, color) # set up all the rows of walls in the grid for c in range(1,4): GRID[2][c] = 1 for c in range(5,9): GRID[2][c] = 1 for c in range(10,20): GRID[2][c] = 1 for c in range(1,3): GRID[4][c] = 1 for c in range(4,13): GRID[4][c] = 1 for c in range(14,20): GRID[4][c] = 1 for c in range(3,13): GRID[6][c] = 1 for c in range(16,20): GRID[6][c] = 1 for c in range(1,17): GRID[8][c] = 1 for c in range(1,10): GRID[11][c] = 1 for c in range(11,13): GRID[11][c] = 1 for c in range(14,19): GRID[11][c] = 1 for c in range(3,6): GRID[13][c] = 1 for c in range(7,17): GRID[13][c] = 1 for c in range(1,3): GRID[15][c] = 1 for c in range(4,11): GRID[15][c] = 1 for c in range(12,19): GRID[15][c] = 1 for c in range(1,19): GRID[17][c] = 1 # set up all the individual wall blocks in the grid GRID[3][7] = 1 GRID[5][14] = 1 GRID[6][1] = 1 GRID[6][14] = 1 GRID[8][18] = 1 GRID[9][4] = 1 GRID[9][8] = 1 GRID[9][11] = 1 GRID[9][16] = 1 GRID[10][2] = 1 GRID[10][6] = 1 GRID[10][14] = 1 GRID[12][11] = 1 GRID[13][1] = 1 GRID[13][18] = 1 GRID[14][4] = 1 # set up all the teleporter blocks # blue tele GRID[1][18] = 4 GRID[18][1] = 4 # beige tele GRID[5][1] = 5 GRID[10][1] = 5 # indigo tele GRID[5][18] = 6 GRID[3][18] = 6 # pink tele GRID[16][1] = 7 GRID[16][18] = 7 # activate the functions for the keys, gates, and the level 2 player key() gate() player2() # create informative text at the side to aid the player # level 2 sign arcade.draw_text("LEVEL 2", 545, 400, arcade.color.RED, 25) # green key and gate arcade.draw_rectangle_filled(525, 310, 20, 20, arcade.color.BOTTLE_GREEN) arcade.draw_rectangle_filled(675, 310, 20, 20, arcade.color.GREEN) arcade.draw_text("unlocks", 570, 307, arcade.color.WHITE, 12) # yellow key and gate arcade.draw_rectangle_filled(525, 280, 20, 20, arcade.color.DARK_YELLOW) arcade.draw_rectangle_filled(675, 280, 20, 20, arcade.color.YELLOW) arcade.draw_text("unlocks", 570, 277, arcade.color.WHITE, 12) # red key and gate arcade.draw_rectangle_filled(525, 250, 20, 20, arcade.color.RUBY_RED) arcade.draw_rectangle_filled(675, 250, 20, 20, arcade.color.RED) arcade.draw_text("unlocks", 570, 247, arcade.color.WHITE, 12) # gray key and gate arcade.draw_rectangle_filled(525, 220, 20, 20, arcade.color.GRAY) arcade.draw_rectangle_filled(675, 220, 20, 20, arcade.color.DARK_GRAY) arcade.draw_text("unlocks", 570, 217, arcade.color.WHITE, 12) # blue teleporters arcade.draw_rectangle_filled(525, 175, 25, 25, arcade.color.BLUEBERRY) arcade.draw_rectangle_filled(675, 175, 25, 25, arcade.color.BLUEBERRY) # beige teleporters arcade.draw_rectangle_filled(525, 140, 25, 25, arcade.color.VIOLET_RED) arcade.draw_rectangle_filled(675, 140, 25, 25, arcade.color.VIOLET_RED) # indigo teleporters arcade.draw_rectangle_filled(525, 105, 25, 25, arcade.color.INDIGO) arcade.draw_rectangle_filled(675, 105, 25, 25, arcade.color.INDIGO) # pink teleporters arcade.draw_rectangle_filled(525, 70, 25, 25, arcade.color.PURPLE_PIZZAZZ) arcade.draw_rectangle_filled(675, 70, 25, 25, arcade.color.PURPLE_PIZZAZZ) arcade.draw_text("teleporters", 560, 120, arcade.color.WHITE, 13) # draw separating lines arcade.draw_line(500, 200, 700, 200, arcade.color.WHITE, 7) arcade.draw_line(500, 350, 700, 350, arcade.color.WHITE, 7) # differentiate between the keys and gates arcade.draw_text("Keys:", 512, 330, arcade.color.WHITE, 10) arcade.draw_text("Gates:", 660, 330, arcade.color.WHITE, 10) # set up a screen to be placed when the player beats the second level if win == 3: arcade.draw_rectangle_filled(400, 300, 1200, 1200, arcade.color.BLACK) arcade.draw_text("CONGRATULATIONS!", 120, 250, arcade.color.WHITE, 40)
def player2(): """Defines the abilities of the player in the second level""" # define global variables global level2, player_column, player_row, row, column, GRID, win, open1, open2, open3, open4, gate_open_1, gate_open_2, gate_open_3, gate_open_4, key_get_1, key_get_2, key_get_3, key_get_4 # set to code to run only when the second level is being played if level2 == 1: row = player_row column = player_column GRID[row][column] = 2 arcade.draw_rectangle_filled(x, y, 23.1, 23.1, color) # create code for how the player interacts with teleporters, key and gates if win == 2: # blue teleporter interaction if player_row == 1 and player_column == 18: player_row = 18 player_column = 2 arcade.play_sound(teleport_sound) GRID[1][18] = 1 GRID[18][1] = 1 # beige teleporter interaction # lower entrance if player_row == 5 and player_column == 1: player_row = 9 player_column = 1 arcade.play_sound(teleport_sound) GRID[5][1] = 1 GRID[10][1] = 1 # upper entrance if player_row == 10 and player_column == 1: player_row = 5 player_column = 2 arcade.play_sound(teleport_sound) GRID[5][1] = 1 GRID[10][1] = 1 # indigo teleporter interaction # upper entrance if player_row == 5 and player_column == 18: player_row = 3 player_column = 17 arcade.play_sound(teleport_sound) GRID[5][18] = 1 GRID[3][18] = 1 # lower entrance if player_row == 3 and player_column == 18: player_row = 5 player_column = 17 arcade.play_sound(teleport_sound) GRID[5][18] = 1 GRID[3][18] = 1 # pink teleporter interaction # left entrance if player_row == 16 and player_column == 1: player_row = 16 player_column = 17 arcade.play_sound(teleport_sound) GRID[16][1] = 1 GRID[16][18] = 1 # right entrance if player_row == 16 and player_column == 18: player_row = 16 player_column = 2 arcade.play_sound(teleport_sound) GRID[16][1] = 1 GRID[16][18] = 1 # interaction with gates to have the appropriate color when the player crosses it # yellow gate if open1 == True and gate_open_1 == 0: GRID[3][15] = 2 GRID[1][11] = 0 if open1 == True and gate_open_1 > 0: GRID[3][15] = 2 GRID[1][11] = 2 # green gate if open2 == True and gate_open_2 == 0: GRID[5][8] = 2 GRID[10][8] = 0 if open2 == True and gate_open_2 > 0: GRID[5][8] = 2 GRID[10][8] = 2 # red gate if open3 == True and gate_open_3 == 0: GRID[11][13] = 2 GRID[6][15] = 0 if open3 == True and gate_open_3 > 0: GRID[11][13] = 2 GRID[6][15] = 2 # gray gate if open4 == True and gate_open_4 == 0: GRID[16][14] = 2 GRID[13][17] = 0 if open4 == True and gate_open_4 > 0: GRID[16][14] = 2 GRID[13][17] = 2 # interaction with keys to make the player move forward afterwards as to not cause the key sound to constantly play # yellow key if (player_row == 3 and player_column == 15) and GRID[player_row][player_column-1] == 2: player_column = 16 column = player_column if (player_row == 3 and player_column == 15) and GRID[player_row][player_column+1] == 2: player_column = 14 column = player_column # green key if (player_row == 5 and player_column == 8) and GRID[player_row][player_column-1] == 2: player_column = 9 column = player_column if (player_row == 5 and player_column == 8) and GRID[player_row][player_column+1] == 2: player_column = 7 column = player_column # red key if (player_row == 11 and player_column == 13) and GRID[player_row+1][player_column] == 2: player_row = 10 row = player_row if (player_row == 11 and player_column == 13) and GRID[player_row-1][player_column] == 2: player_row = 12 row = player_row # gray key if (player_row == 16 and player_column == 14) and GRID[player_row][player_column-1] == 2: player_column = 15 column = player_column if (player_row == 16 and player_column == 14) and GRID[player_row][player_column+1] == 2: player_column = 13 column = player_column # have the player complete the level when reaching a certain point if player_column == 19 and player_row == 18: arcade.play_sound(complete) player_row = 19 # create a change of the player's position to prevent the completion sound from constantly playing if player_column == 19 and player_row == 19: win = 3
import arcade SCREEN_WIDTH = 800 SCREEN_HEIGHT = 600 arcade.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, "Drawing with Functions") arcade.set_background_color(arcade.color.CYBER_YELLOW) arcade.start_render() # Draw the Grass arcade.draw_lrtb_rectangle_filled(0, 800, 200, 0, arcade.color.BITTER_LIME) #Draw the Sun arcade.draw_circle_filled(500, 550, 40, arcade.color.ORANGE) #Draw car with wheels arcade.draw_rectangle_filled(600, 150, 140, 70, arcade.color.BLACK) arcade.draw_circle_filled(500, 110, 50, arcade.color.BLUE) arcade.draw_circle_filled(500, 110, 45, arcade.color.LIGHT_BLUE) arcade.draw_circle_filled(650, 90, 30, arcade.color.BLUE) arcade.draw_circle_filled(650, 90, 25, arcade.color.LIGHT_BLUE) # Finish and run arcade.finish_render() arcade.run()
def on_draw(self): arcade.start_render() arcade.set_viewport(0, SCREEN_WIDTH, 0, SCREEN_HEIGHT) screen_width, screen_height = self.window.get_size() self.screen_center_x = int(screen_width / 2) self.screen_center_y = int(screen_height / 2) if self.old_screen_center_x != self.screen_center_x or self.old_screen_center_y != self.screen_center_y: game_over_text = 'You Won! You Got More Coins Then On The Bar-Round!' self.game_over_text = arcade.draw_text( game_over_text, self.screen_center_x, self.screen_center_y + 150, anchor_x='center', anchor_y='center', color=arcade.csscolor.WHITE, font_size=32, font_name='fonts/RobotoMono-Regular.ttf') win_text = 'You got a stunning ' + str( self.coins) + '! Can you beat it?' self.game_over_text2 = arcade.draw_text( win_text, self.screen_center_x, self.screen_center_y + 100, anchor_x='center', anchor_y='center', color=arcade.csscolor.WHITE, font_size=32, font_name='fonts/RobotoMono-Regular.ttf') restart_text = 'Restart' self.restart_button = arcade.draw_text( restart_text, self.screen_center_x, self.screen_center_y, anchor_x='center', anchor_y='center', color=arcade.csscolor.WHITE, font_size=64, font_name='fonts/RobotoMono-Regular.ttf') self.old_screen_center_x = self.screen_center_x self.old_screen_center_y = self.screen_center_y if self.draw_restart_button_hover: if self.clicking: arcade.draw_rectangle_filled(self.screen_center_x, self.screen_center_y, self.restart_button.width + 100, self.restart_button.height + 50, self.click_color) elif self.hovering: arcade.draw_rectangle_filled(self.screen_center_x, self.screen_center_y, self.restart_button.width + 100, self.restart_button.height + 50, self.hover_color) self.play_bottom = self.restart_button.bottom self.play_left = self.restart_button.left self.game_over_text.draw() self.game_over_text2.draw() self.restart_button.draw()
def square(square_x, square_y, square_width, square_height, square_color): """ Code that sets up the squares for generation """ arcade.draw_rectangle_filled(square_x, square_y, square_width, square_height, square_color)
def draw_box(self): arcade.draw_rectangle_filled(self.x, self.y, self.side, self.side, self.c)
def draw_section_8(): for row in range(30): for column in range(30, 28 - row, -1): x = column * 10 + 905 # Instead of zero, calculate the proper x location using 'column' y = row * 10 + 305 # Instead of zero, calculate the proper y location using 'row' arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE)
def draw(self): """ Draw our rectangle """ arcade.draw_rectangle_filled(self.x, self.y, self.width, self.height, self.color, self.angle)
def draw(self): arcade.draw_rectangle_filled(self.position[0], self.position[1], self.width, self.height, self.color)
def on_draw(self): """ Render the screen. """ # Start the render process. This must be done before any drawing commands. arcade.start_render() # Draw a grid # Draw vertical lines every 120 pixels for x in range(0, 601, 120): arcade.draw_line(x, 0, x, 600, arcade.color.BLACK, 2) # Draw horizontal lines every 200 pixels for y in range(0, 601, 200): arcade.draw_line(0, y, 800, y, arcade.color.BLACK, 2) # Draw a point arcade.draw_text("draw_point", 3, 405, arcade.color.BLACK, 12) arcade.draw_point(60, 495, arcade.color.RED, 10) # Draw a set of points arcade.draw_text("draw_points", 123, 405, arcade.color.BLACK, 12) point_list = ((165, 495), (165, 480), (165, 465), (195, 495), (195, 480), (195, 465)) arcade.draw_points(point_list, arcade.color.ZAFFRE, 10) # Draw a line arcade.draw_text("draw_line", 243, 405, arcade.color.BLACK, 12) arcade.draw_line(270, 495, 300, 450, arcade.color.WOOD_BROWN, 3) # Draw a set of lines arcade.draw_text("draw_lines", 363, 405, arcade.color.BLACK, 12) point_list = ((390, 450), (450, 450), (390, 480), (450, 480), (390, 510), (450, 510)) arcade.draw_lines(point_list, arcade.color.BLUE, 3) # Draw a line strip arcade.draw_text("draw_line_strip", 483, 405, arcade.color.BLACK, 12) point_list = ((510, 450), (570, 450), (510, 480), (570, 480), (510, 510), (570, 510)) arcade.draw_line_strip(point_list, arcade.color.TROPICAL_RAIN_FOREST, 3) arcade.draw_line_strip(point_list, arcade.color.BEIGE) # Draw a polygon arcade.draw_text("draw_polygon_outline", 3, 207, arcade.color.BLACK, 9) point_list = ((30, 240), (45, 240), (60, 255), (60, 285), (45, 300), (30, 300)) arcade.draw_polygon_outline(point_list, arcade.color.SPANISH_VIOLET, 3) # Draw a filled in polygon arcade.draw_text("draw_polygon_filled", 123, 207, arcade.color.BLACK, 9) point_list = ((150, 240), (165, 240), (180, 255), (180, 285), (165, 300), (150, 300)) arcade.draw_polygon_filled(point_list, arcade.color.SPANISH_VIOLET) # Draw an outline of a circle arcade.draw_text("draw_circle_outline", 243, 207, arcade.color.BLACK, 10) arcade.draw_circle_outline(300, 285, 18, arcade.color.WISTERIA, 3) arcade.draw_circle_outline(350, 285, 18, arcade.color.WISTERIA) # Draw a filled in circle arcade.draw_text("draw_circle_filled", 363, 207, arcade.color.BLACK, 10) arcade.draw_circle_filled(420, 285, 18, arcade.color.GREEN) # Draw an ellipse outline, and another one rotated arcade.draw_text("draw_ellipse_outline", 483, 207, arcade.color.BLACK, 10) arcade.draw_ellipse_outline(540, 273, 15, 36, arcade.color.AMBER, 3) arcade.draw_ellipse_outline(540, 336, 15, 36, arcade.color.BLACK_BEAN, 3, 45) # Draw a filled ellipse, and another one rotated arcade.draw_text("draw_ellipse_filled", 3, 3, arcade.color.BLACK, 10) arcade.draw_ellipse_filled(60, 81, 15, 36, arcade.color.AMBER) arcade.draw_ellipse_filled(60, 144, 15, 36, arcade.color.BLACK_BEAN, 45) # Draw an arc, and another one rotated arcade.draw_text("draw_arc/filled_arc", 123, 3, arcade.color.BLACK, 10) arcade.draw_arc_outline(150, 81, 15, 36, arcade.color.BRIGHT_MAROON, 90, 360) arcade.draw_arc_filled(150, 144, 15, 36, arcade.color.BOTTLE_GREEN, 90, 360, 45) # Draw an rectangle outline arcade.draw_text("draw_rect", 243, 3, arcade.color.BLACK, 10) arcade.draw_rectangle_outline(295, 100, 45, 65, arcade.color.BRITISH_RACING_GREEN) arcade.draw_rectangle_outline(295, 160, 20, 45, arcade.color.BRITISH_RACING_GREEN, 3, 45) # Draw a filled in rectangle arcade.draw_text("draw_filled_rect", 363, 3, arcade.color.BLACK, 10) arcade.draw_rectangle_filled(420, 100, 45, 65, arcade.color.BLUSH) arcade.draw_rectangle_filled(420, 160, 20, 40, arcade.color.BLUSH, 45) # Load and draw an image to the screen # Image from kenney.nl asset pack #1 arcade.draw_text("draw_bitmap", 483, 3, arcade.color.BLACK, 12) texture = arcade.load_texture("images/playerShip1_orange.png") scale = .6 arcade.draw_texture_rectangle(540, 120, scale * texture.width, scale * texture.height, texture, 0) arcade.draw_texture_rectangle(540, 60, scale * texture.width, scale * texture.height, texture, 45) color = arcade.get_pixel(100, 100) assert color == (255, 255, 255) image = arcade.get_image()
''' HONOR CODE: I solemnly promise that while taking this test I will only use PyCharm or the Internet, but I will definitely not ask another person except the instructor. Signed: Ezra McCulley Recreate, exactly the Test Picture from the website. The arcade colors used in this picture in no particular order are: BLACK, ALMOND, PHLOX, BLUSH, RED, BLUE, WISTERIA, AMBER, BRICK_RED and YELLOW. The picture is 500px wide and 400px tall. Look up ARC in the documentation to do the PAC-MAN. ''' import arcade arcade.open_window(500, 400, "Ch. 7 Take Home Test") arcade.set_background_color(arcade.color.ALMOND) arcade.start_render() for x_line in range(0, 500, 20): # grid arcade.draw_rectangle_filled(0 + x_line, 200, 1, 400, arcade.color.BLACK) arcade.draw_rectangle_filled(250, 0 + x_line, 500, 1, arcade.color.BLACK) arcade.draw_lrtb_rectangle_filled(19.5, 80, 380, 359.5, arcade.color.PHLOX) # Phlox Block arcade.draw_rectangle_filled(200, 260, 39, 20, arcade.color.BLUSH, 45) # Blush Block arcade.draw_circle_filled(250, 200, 41, arcade.color.WISTERIA) # Wisteria Circle arcade.draw_ellipse_filled(100, 99, 60, 19.5, arcade.color.AMBER) # Amber Ellipse arcade.draw_rectangle_filled(460, 10, 5, 5, arcade.color.RED) # Red Square
arcade.color.BOTTLE_GREEN, 90, 360, 45) # My drawing of PACMAN arcade.draw_arc_filled(300, 345, 36, 36, arcade.color.YELLOW, 90, 360, -45) # Draw an rectangle outline arcade.draw_text("draw_rect", 243, 3, arcade.color.WHITE, 10) arcade.draw_rectangle_outline(295, 100, 45, 65, arcade.color.BRITISH_RACING_GREEN) arcade.draw_rectangle_outline(295, 160, 20, 45, arcade.color.BRITISH_RACING_GREEN, 3, 45) # Draw a filled in rectangle arcade.draw_text("draw_filled_rect", 363, 3, arcade.color.WHITE, 10) arcade.draw_rectangle_filled(420, 100, 45, 65, arcade.color.BLUSH) arcade.draw_rectangle_filled(420, 160, 20, 40, arcade.color.BLUSH, 45) # Load and draw an image to the screen # Image from kenney.nl asset pack #1 arcade.draw_text("draw_bitmap", 483, 3, arcade.color.WHITE, 12) texture = arcade.load_texture("images/playerShip1_orange.png") scale = .6 arcade.draw_texture_rectangle(540, 120, scale * texture.width, scale * texture.height, texture, 0) arcade.draw_texture_rectangle(540, 60, scale * texture.width, scale * texture.height, texture, 45) # Finish the render. # Nothing will be drawn without this. # Must happen after all draw commands
def draw_log(self): if self.log is not None: x, _, y, _ = self.game.viewport draw_rectangle_filled(x + 100, y + 25, 200, 50, BLACK) draw_text(self.log, x + 10, y + 20, WHITE)
''' Recreate, exactly the Test Picture from the website. The arcade colors used in this picture in no particular order are: BLACK, ALMOND, PHLOX, BLUSH, RED, BLUE, WISTERIA, AMBER, BRICK_RED and YELLOW. The picture is 500px wide and 400px tall. Look up ARC in the documentation to do the PAC-MAN. 25 across 20 down ''' import arcade arcade.open_window(500, 400, "Yoda's species is called Yoda's Species") arcade.set_background_color(arcade.color.ALMOND) arcade.start_render() h = 20 xvalue = 20 for z in range(25): arcade.draw_line(xvalue, 400, xvalue, 0, arcade.color.BLACK, 1) xvalue += 20 for z in range(25): arcade.draw_line(500, h, 0, h, arcade.color.BLACK) h += 20 arcade.draw_xywh_rectangle_filled(20, 360, 60, 20, arcade.color.PHLOX) arcade.draw_rectangle_filled(200, 280, 40, 20, arcade.color.BLUSH, 45) arcade.draw_circle_filled(250, 220, 40, arcade.color.WISTERIA) arcade.draw_line(80, 20, 120, 60, arcade.color.BLUE, 1) arcade.draw_ellipse_filled(100, 100, 60, 20, arcade.color.AMBER, 0, 128) arcade.draw_text("I love you. I know.", 20, 180, arcade.color.BRICK_RED, 20, 220, "left", "Calibri", False, False, "left", "baseline", 0) arcade.draw_rectangle_filled(460, 10, 5, 5, arcade.color.RED, 0) arcade.draw_arc_filled(400, 320, 60, 60, arcade.color.YELLOW, 30, 330, 0) arcade.finish_render() arcade.run()
def do_draw_rectangle(self): # 0.1 : 1600 for x in range(0, SCREEN_WIDTH, 20): for y in range(0, SCREEN_HEIGHT, 15): arcade.draw_rectangle_filled(x + 10, y + 8, 10, 10, arcade.color.AZURE)
def on_draw(): """Draws the main level and the transition to the second level""" # create global variables global GRID, color, column, row, x, y, win, level2, timer # set the code for it only to run during the first level and before the player has won if level2 == 0: if win == 0: # create code that allows every square in the grid to be changed for row in range(ROW_COUNT): for column in range(COLUMN_COUNT): # set variables for the walls in the grid if row == 0 or row == 14 or (column == 0 and row != 1) or (column == 14 and row != 13): GRID[row][column] = 1 if column == 15: GRID[row][column] = 3 # set each variable to a specific color # floor if GRID[row][column] == 0: color = arcade.color.BLACK # walls elif GRID[row][column] == 1: color = arcade.color.PURPLE # player and its trail elif GRID[row][column] == 2: color = arcade.color.BLUE # invisible wall past the finishing point elif GRID[row][column] == 3: color = arcade.color.BLACK # teleporter elif GRID[row][column] == 4: color = arcade.color.BLUEBERRY # yellow gate elif GRID[row][column] == 5: color = arcade.color.YELLOW # yellow key elif GRID[row][column] == 6: color = arcade.color.DARK_YELLOW # green gate elif GRID[row][column] == 7: color = arcade.color.GREEN # green key elif GRID[row][column] == 8: color = arcade.color.BOTTLE_GREEN # set a size for each square in the grid x = (MARGIN + WIDTH) * column + MARGIN + WIDTH // 2 y = (MARGIN + HEIGHT) * row + MARGIN + HEIGHT // 2 arcade.draw_rectangle_filled(x, y, WIDTH, HEIGHT, color) # set up the columns of walls within the grid for r in range(2, 6): GRID[r][2] = 1 for r in range(2, 7): GRID[r][4] = 1 for r in range(2, 8): GRID[r][6] = 1 GRID[r][8] = 1 for r in range(2, 10): GRID[r][10] = 1 for r in range(2, 12): GRID[r][12] = 1 for r in range(7, 13): GRID[r][2] = 1 for r in range(9, 12): GRID[r][4] = 1 GRID[r][6] = 1 # set up the rows of walls within the grid for c in range(2, 5): GRID[2][c] = 1 GRID[7][c] = 1 for c in range(6, 9): GRID[2][c] = 1 for c in range(6, 10): GRID[9][c] = 1 for c in range(8, 12): GRID[11][c] = 1 for c in range(12, 14): GRID[12][c] = 1 # identify the teleporter entrance and exit GRID[3][7] = 4 GRID[3][3] = 4 # create an if statement to activate keys, gates, and the player to run before the player has beaten the level if win == 0: key() gate() player() # create information text to assist the player # green key and gate info arcade.draw_rectangle_filled(525, 150, 30, 30, arcade.color.BOTTLE_GREEN) arcade.draw_rectangle_filled(675, 150, 30, 30, arcade.color.GREEN) arcade.draw_text("unlocks", 567, 145, arcade.color.WHITE, 13) # yellow key and gate info arcade.draw_rectangle_filled(525, 100, 30, 30, arcade.color.DARK_YELLOW) arcade.draw_rectangle_filled(675, 100, 30, 30, arcade.color.YELLOW) arcade.draw_text("unlocks", 567, 95, arcade.color.WHITE, 13) # teleporter info arcade.draw_rectangle_filled(525, 50, 30, 30, arcade.color.BLUEBERRY) arcade.draw_rectangle_filled(675, 50, 30, 30, arcade.color.BLUEBERRY) arcade.draw_text("teleporters", 555, 45, arcade.color.WHITE, 13) # level 1 sign arcade.draw_text("LEVEL 1", 550, 420, arcade.color.RED, 20) # separating line arcade.draw_line(500, 75, 700, 75, arcade.color.WHITE, 7) arcade.draw_line(500, 210, 700, 210, arcade.color.WHITE, 7) # differentiate the key spaces from the gates arcade.draw_text("Keys:", 505, 180, arcade.color.WHITE, 12) arcade.draw_text("Gates:", 650, 180, arcade.color.WHITE, 12) # player controls arcade.draw_text("W: Move Up", 545, 340, arcade.color.WHITE, 12) arcade.draw_text("A: Move Left", 545, 320, arcade.color.WHITE, 12) arcade.draw_text("S: Move Down", 545, 300, arcade.color.WHITE, 12) arcade.draw_text("D: Move Right", 545, 280, arcade.color.WHITE, 12) arcade.draw_text("K: Reset Level", 545, 260, arcade.color.WHITE, 12) # player info arcade.draw_rectangle_filled(550, 385, 30, 30, arcade.color.BLUE) arcade.draw_text("Player", 580, 382, arcade.color.WHITE, 12) # additional gameplay information arcade.draw_text("You can't move past your own line", 495, 230, arcade.color.YELLOW, 12) # create code for the transition after the player has beaten the level if level2 == 1: # create a victory screen that covers the old grid arcade.draw_rectangle_filled(400, 300, 1200, 600, arcade.color.BLACK) arcade.draw_text("LEVEL 1 COMPLETE!!!", 135, 250, arcade.color.WHITE, 30) # use the timer to give the player a few seconds before switching levels if timer > 4: win = 2 arcade.draw_rectangle_filled(400, 300, 1200, 600, arcade.color.BLACK) # launch the code for the second level second_draw()
Make your flag 260 pixels tall Use the scaling image on the website to determine other dimensions The hexadecimal colors for the official flag are red:#BF0A30(191,10,48) and blue:#002868(0,40,104) Title the window, "The Stars and Stripes" I used a draw_text command and used 20 pt. asterisks for the stars. We will have a competition to see who can make this flag in the least lines of code. The record is 16! You will have to use some loops to achieve this. ''' import arcade arcade.open_window(494, 260, "The Stars and Stripes") arcade.set_background_color(arcade.color.WHITE) arcade.start_render() for y in range(10, 251, 40): arcade.draw_rectangle_filled(247, y, 494, 20, (191, 10, 48)) arcade.draw_rectangle_filled(99, 190, 197.6, 140, (0, 40, 104)) # draw stars y = 235 for star_rows in range(9): if star_rows % 2 == 0: x = 6 for star in range(6): if star == 0: arcade.draw_text("*", x, y, arcade.color.WHITE, 20) else: arcade.draw_text("*", x, y, arcade.color.WHITE, 20) x += 35 else: x = 23 for star in range(5):
def player(): """Defines the abilities of the player for the first level""" # assign global variables global GRID, x, y, color, row, column, player_row, player_column, open1, open2, gate_open_1, gate_open_2, win, level2, key_get_1, key_get_2, timer, HEIGHT, WIDTH, MARGIN # assign this code to run only if it is in the first level if level2 == 0: # make the player have a unique grid variable to identify where it is row = player_row column = player_column GRID[row][column] = 2 arcade.draw_rectangle_filled(x, y, WIDTH, HEIGHT, color) # tell the code that the level has been beaten when the player reaches a certain point if player_column == 14 and player_row == 13: win += 1 # create code that allows the player to interact with the gates, keys, and teleporters if win == 0: # code for the teleporter interaction if player_column == 7 and player_row == 3: player_column = 3 player_row = 4 arcade.play_sound(teleport_sound) GRID[3][3] = 1 GRID[3][7] = 1 if player_column == 3 and player_row == 3: player_column = 7 player_row = 4 arcade.play_sound(teleport_sound) GRID[3][3] = 1 GRID[3][7] = 1 # code for the gate interaction so that the gate square becomes the appropriate colour when the player crosses it # yellow gate if open1 == True and gate_open_1 == 0: GRID[9][3] = 2 GRID[11][7] = 0 if open1 == True and gate_open_1 > 0: GRID[11][7] = 2 GRID[9][3] = 2 # green gate if open2 == True and gate_open_2 == 0: GRID[10][9] = 2 GRID[13][12] = 0 if open2 == True and gate_open_2 > 0: GRID[10][9] = 2 GRID[13][12] = 2 # code that moves the player when it grabs a key so that the key sound will not constantly play # yellow key if (player_row == 9 and player_column == 3) and GRID[player_row-1][player_column] == 2: player_row = 10 row = player_row if (player_row == 9 and player_column == 3) and GRID[player_row+1][player_column] == 2: player_row = 8 row = player_row # green key if (player_row == 10 and player_column == 9) and GRID[player_row][player_column+1] == 2: player_column = 8 column = player_column if (player_row == 10 and player_column == 9) and GRID[player_row][player_column-1] == 2: player_column = 10 column = player_column # create code for when the player does finish the level if win == 1: # reset the player position player_row = 1 player_column = 0 # remove the player path for i in range(len(grid_row)): for j in range(len(grid_column)): GRID[grid_row[i]][grid_column[j]] = 0 if GRID[row][column] == 2: GRID[row][column] = 0 # reset the keys and gates and their relative functions GRID[9][3] = 6 GRID[10][9] = 8 open1 = False open2 = False key_get_1 = 0 key_get_2 = 0 gate_open_1 = 0 gate_open_2 = 0 GRID[11][7] = 5 GRID[13][12] = 7 # change the height, width and margin of the grid squares for the next level HEIGHT = 23.1 WIDTH = 23.1 MARGIN = 1 # reset the grid values grid_reset() # create a large square to cover up the previous level arcade.draw_rectangle_filled(400, 300, 1200, 600, arcade.color.BLACK) # play a victory sound arcade.play_sound(complete) # activate the setup of the next level level2setup() timer = 0 level2 = 1
def draw_play(): arcade.set_background_color(arcade.color.GRAY_BLUE) arcade.draw_rectangle_filled(WIDTH / 2, HEIGHT / 2, 7 * a, 4 * b, arcade.color.WHITE_SMOKE) arcade.draw_rectangle_filled(WIDTH / 2 - 3.5 * a, HEIGHT / 2 - 2.5 * b, 2 * a, b, arcade.color.WHITE_SMOKE) arcade.draw_rectangle_filled(WIDTH / 2 + 3.5 * a, HEIGHT / 2 + 2.5 * b, 2 * a, b, arcade.color.WHITE_SMOKE) arcade.draw_rectangle_filled(WIDTH / 2 - 5.5 * a, HEIGHT / 2 - 1.5 * b, 2 * a, 3 * b, arcade.color.GUPPIE_GREEN) arcade.draw_rectangle_filled(WIDTH / 2 + 5.5 * a, HEIGHT / 2 + 1.5 * b, 2 * a, 3 * b, arcade.color.GUPPIE_GREEN) arcade.draw_rectangle_filled(player_x, player_y, 15, 15, arcade.color.RED) arcade.draw_circle_filled(ball1_x, ball1_y, 10, arcade.color.BLUE) arcade.draw_circle_filled(ball2_x, ball2_y, 10, arcade.color.BLUE) arcade.draw_circle_filled(ball3_x, ball3_y, 10, arcade.color.BLUE) arcade.draw_circle_filled(ball4_x, ball4_y, 10, arcade.color.BLUE)
def on_draw(self): arcade.start_render() # Draw all the sprites. self.effect_list.draw() self.chest_list.draw() self.arrow_list.draw() self.fireball_list.draw() self.wall_list.draw() self.player_sprite.draw() self.enemy_list.draw() self.potion_list.draw() self.coin_list.draw() self.ammo_list.draw() # If you get a high score change the text if self.highscore_sound: # Render the high-score text output = "High Score: " + str(self.highscore) if not self.highscore_text or self.highscore_text != output: self.highscore_text = arcade.create_text( output, arcade.color.YELLOW, 14) arcade.render_text(self.highscore_text, self.view_left + 8, self.view_bottom + 365) else: # Render the score text output = "Score: " + str(self.score) + " (" + str( self.highscore) + ")" if not self.score_text or self.score_text != output: self.score_text = arcade.create_text(output, arcade.color.GREEN, 10) arcade.render_text(self.score_text, self.view_left + 8, self.view_bottom + 365) if self.player_sprite.alive: # Render the arrow count text output = "Arrows: " + str(self.ammo) if not self.ammo_text or self.ammo_text != output: self.ammo_text = arcade.create_text(output, arcade.color.WHITE, 12) arcade.render_text(self.ammo_text, self.view_left + 8, self.view_bottom + 8) # Draw Health bar x = self.player_sprite.center_x y = self.player_sprite.center_y arcade.draw_rectangle_filled(x, y - 16, 24, 4, (255, 0, 0)) arcade.draw_rectangle_filled( x - math.ceil((24 - (self.health / 4.16)) / 2), y - 16, math.ceil(self.health / 4.16), 4, (0, 255, 0)) # Death screen if not self.player_sprite.alive: arcade.draw_text("You died!", self.player_sprite.center_x - 125, self.player_sprite.center_y, (200, 20, 20), 48) arcade.draw_text("Press R To Restart", self.player_sprite.center_x - 125, self.player_sprite.center_y - 125, (200, 20, 20), 24) # Instructions if not self.game_started: arcade.draw_texture_rectangle(self.player_sprite.center_x, self.player_sprite.center_y, 150, 200, self.controls)
def draw(self): if self.visible: arcade.draw_rectangle_filled(self.center_x, self.center_y, self.width, self.height, self.color)
def on_draw(): global tick_counter arcade.start_render() # menu if current_screen == 0: arcade.set_background_color(arcade.color.GREEN) arcade.draw_text("Pants VS Zombies", WIDTH / 2, HEIGHT - 100, arcade.color.BLACK, font_size=30, anchor_x="center") draw_instruction_button(instruction_button) draw_game_button(game_button) arcade.draw_text("Instructions", WIDTH / 2, HEIGHT - 550, arcade.color.BLACK, font_size=30, anchor_x="center") arcade.draw_text("Play", WIDTH / 2, HEIGHT - 700, arcade.color.BLACK, font_size=30, anchor_x="center") # instructions elif current_screen == 1: arcade.set_background_color(arcade.color.GRAY) arcade.draw_text("Instructions", WIDTH / 2, HEIGHT - 100, arcade.color.BLACK, font_size=30, anchor_x="center") draw_instructions("instructions") arcade.draw_text("Esc to go to Menu", WIDTH - 1000, HEIGHT - 700, arcade.color.BLACK, font_size=30, anchor_x="center") # game elif current_screen == 2: tick_counter += 1 for i in level_generator(tick_counter): zombie_sprites.append(Zombie(i)) setup_grid(grid_col_1, grid_col_2) for i in gridGenerator[:-1]: arcade.draw_rectangle_filled(i + 50, HEIGHT - 50, 100, 100, arcade.color.BLACK_BEAN) arcade.draw_rectangle_filled(i + 50, HEIGHT - 50, 90, 90, arcade.color.ALLOY_ORANGE) arcade.draw_texture_rectangle( 150, HEIGHT - 50, 100, 100, arcade.load_texture('.\\assets\\diamond.png')) arcade.draw_texture_rectangle( 250, HEIGHT - 50, 100, 100, arcade.load_texture('.\\assets\\gold.png')) arcade.draw_texture_rectangle( 350, HEIGHT - 50, 100, 100, arcade.load_texture('.\\assets\\leather.png')) global mouse_select, send_fabric_error if mouse_select == 1: arcade.draw_rectangle_outline(150, HEIGHT - 50, 90, 90, color=arcade.color.RED, border_width=5) elif mouse_select == 2: arcade.draw_rectangle_outline(250, HEIGHT - 50, 90, 90, color=arcade.color.RED, border_width=5) elif mouse_select == 3: arcade.draw_rectangle_outline(350, HEIGHT - 50, 90, 90, color=arcade.color.RED, border_width=5) grid_counter = -1 for row in grid: grid_counter += 1 row_counter = -1 for col in row: row_counter += 1 if col == 1: arcade.draw_texture_rectangle( (100 * grid_counter) + 50, (100 * row_counter) + 50, 100, 100, arcade.load_texture('.\\assets\\diamond.png')) if tick_counter % 5 == 0: pant_projectile = arcade.Sprite( ".\\assets\\pant_projectile.png", center_x=(100 * grid_counter) + 50, center_y=(100 * row_counter) + 50) pant_sprites.append(pant_projectile) elif col == 2: arcade.draw_texture_rectangle( (100 * grid_counter) + 50, (100 * row_counter) + 50, 100, 100, arcade.load_texture('.\\assets\\gold.png')) if random.randint(0, 70) == 1: fabric_sprites.append( Fabric((100 * grid_counter) + 50, (100 * row_counter) + 50)) elif col >= 35: arcade.draw_texture_rectangle( (100 * grid_counter) + 50, (100 * row_counter) + 50, 100, 100, arcade.load_texture('.\\assets\\leather.png')) if tick_counter % 2 == 1: arcade.draw_circle_filled((100 * grid_counter) + 50, (100 * row_counter) + 80, 5, arcade.color.RED) elif col >= 3: arcade.draw_texture_rectangle( (100 * grid_counter) + 50, (100 * row_counter) + 50, 100, 100, arcade.load_texture('.\\assets\\leather.png')) grid[grid_counter][row_counter] += 1 pant_sprites.move(30, 0) pant_sprites.draw() if send_fabric_error: arcade.draw_text(str(fabric), 50, HEIGHT - 60, color=arcade.color.RED, font_size=30, anchor_x="center") send_fabric_error = False else: arcade.draw_text(str(fabric), 50, HEIGHT - 60, color=arcade.color.BLACK, font_size=30, anchor_x="center") # zombies zombie_sprites.draw() # falling fabric fabric_sprites.draw() elif current_screen == 3: arcade.set_background_color(arcade.color.WHITE) arcade.draw_text("Game over!", WIDTH / 2, HEIGHT - 100, arcade.color.BLACK, font_size=30, anchor_x="center")
Make your flag 260 pixels tall Use the scaling image on the website to determine other dimensions The hexadecimal colors for the official flag are red:#BF0A30 and blue:#002868 Title the window, "The Stars and Stripes" I used a draw_text command and used 20 pt. asterisks for the stars. We will have a competition to see who can make this flag in the least lines of code. The record is 16! You will have to use some loops to achieve this. ''' import arcade #Setup and White Background arcade.open_window(494, 260, "The Stars and Stripes") arcade.set_background_color(arcade.color.WHITE) arcade.start_render() for y in range(10, 251, 40): #Red Stripes arcade.draw_rectangle_filled(247, y, 494, 20, (191, 10, 48)) arcade.draw_rectangle_filled(99, 190, 198, 140, (0, 40, 104)) #Top Left Blue Box y = 235 #White Stars First Part for StarRows in range(9): if StarRows % 2 == 0: x = 16.38 for Star in range(6): if Star == 0: arcade.draw_text("*", x, y, arcade.color.WHITE, 20) else: arcade.draw_text("*", x, y, arcade.color.WHITE, 20) x += 32.76 y -= 15
''' import arcade # draw window with width 500 & height 400 arcade.open_window(500, 400, "Jedi test") arcade.set_background_color(arcade.color.ALMOND) arcade.start_render() # draw vertical grid lines for i in range(1, 501, 20): arcade.draw_line(i, 0, i, 400, arcade.color.BLACK, 2) # draw horizontal grid lines for i in range(1, 401, 20): arcade.draw_line(0, i, 500, i, arcade.color.BLACK, 2) # draw rectangle at x=50, y=370, with width 60 & height 20 arcade.draw_rectangle_filled(50, 370, 60, 20, arcade.color.PHLOX) # draw rectangle at x=200, y=260, with width 40 & height 20 arcade.draw_rectangle_filled(200, 260, 40, 20, arcade.color.BLUSH, -45) # draw circle at (250, 200) with a radius of 40 arcade.draw_circle_filled(250, 200, 40, arcade.color.WISTERIA) # Draw text at (20, 155) in 23pt size arcade.draw_text("I love you. I know.", 20, 155, arcade.color.BRICK_RED, 23) # draw blue line arcade.draw_line(80, 20, 120, 60, arcade.color.BLUE, 1) # draw the orange oval arcade.draw_ellipse_filled(100, 100, 120, 40, arcade.color.AMBER) # draw the yellow pacman thing arcade.draw_arc_filled(400, 320, 120, 120, arcade.color.YELLOW, 30, 330) # draw the small red square arcade.draw_rectangle_filled(461, 10, 6, 6, arcade.color.RED) arcade.finish_render()
def draw_section_6(): for column in range(31): for row in range(column): x = 605 - (column * 10) y = 305 + (row * 10) arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE)
def snake(snake_x, snake_y, snake_scale_x, snake_scale_y, snake_color): """ Code that sets up the snake part to be drawn """ arcade.draw_rectangle_filled(snake_x, snake_y, snake_scale_x, snake_scale_y, snake_color)