def on_draw(self): arcade.start_render() arcade.draw_points(self.cities, arcade.color.WHITE, 10) if not self.done: arcade.draw_line_strip(self.permutations[self.current_permutation], arcade.color.WHITE, 2) arcade.draw_line_strip(self.cities, arcade.color.GREEN, 3) percent_done = self.current_permutation / (len(self.permutations) - 1) * 100 arcade.draw_text(f'{percent_done:.3f}%', SCREEN_WIDTH // 2, 30, arcade.color.WHITE, 24, anchor_x='center') arcade.draw_text(f"Shortest Path: {self.shortest:.3f}", SCREEN_WIDTH // 2, SCREEN_HEIGHT - 30, arcade.color.WHITE, anchor_x='center') if self.done: arcade.draw_text( f"Time to Find Shortest Path: {self.total_time:.3f} seconds", SCREEN_WIDTH // 2, SCREEN_HEIGHT - 60, arcade.color.WHITE, anchor_x='center')
def on_draw(self): arcade.start_render() #arcade render zorgt ervoor dat alles begint met tekenen. Dat hoeft maar 1x, en het hoeft niet gestopt te worden. if self.game_state == STATE_MENU: arcade.draw_text( f" PRESS SPACE TO PLAY", SCREEN_WIDTH // 10, 350, arcade.color.WHITE_SMOKE, 70, bold=True, ) #Hier geef je aan wat er getyped moet worden als je begint met het spel. if self.game_state == STATE_PLAYING: point_list = ((SCREEN_WIDTH // 2, 800), (SCREEN_WIDTH // 2, 780), (SCREEN_WIDTH // 2, 740), (SCREEN_WIDTH // 2, 720), (SCREEN_WIDTH // 2, 680), (SCREEN_WIDTH // 2, 660), (SCREEN_WIDTH // 2, 620), (SCREEN_WIDTH // 2, 600), (SCREEN_WIDTH // 2, 560), (SCREEN_WIDTH // 2, 540), (SCREEN_WIDTH // 2, 500), (SCREEN_WIDTH // 2, 480), (SCREEN_WIDTH // 2, 440), (SCREEN_WIDTH // 2, 420), (SCREEN_WIDTH // 2, 380), (SCREEN_WIDTH // 2, 360), (SCREEN_WIDTH // 2, 320), (SCREEN_WIDTH // 2, 300), (SCREEN_WIDTH // 2, 260), (SCREEN_WIDTH // 2, 240), (SCREEN_WIDTH // 2, 200), (SCREEN_WIDTH // 2, 180), (SCREEN_WIDTH // 2, 140), (SCREEN_WIDTH // 2, 120), (SCREEN_WIDTH // 2, 80), (SCREEN_WIDTH // 2, 60), (SCREEN_WIDTH // 2, 20), (SCREEN_WIDTH // 2, 0)) arcade.draw_points(point_list, arcade.color.LIGHT_GRAY, 20) self.score_board.on_draw() self.score_board2.on_draw() self.ball.on_draw() self.rectangle.on_draw() self.rectangle2.on_draw() if self.game_state == STATE_GAME_OVER: arcade.draw_text( f" GAME OVER", 250, 350, arcade.color.WHITE_SMOKE, 80, bold=True, ) arcade.draw_text(f" (PRESS ENTER TO PLAY AGAIN)", 345, 80, arcade.color.ROSE_RED, 20, bold=True)
def draw_snow(): point_list = ((565, 470), (565, 480), (460, 470), (525, 526), (450, 530), (430, 500), (648, 490), (600, 460), (610, 542), (676, 460)) arcade.draw_points(point_list, arcade.color.WHITE, 10)
def on_draw(self): arcade.start_render() if self.pagina == 0: self.capa.draw(center_x = self.screen_width/2, center_y = self.screen_height/2, width = self.capa.width, height = self.capa.height) if self.pagina == 1 and self.timer > 0: arcade.draw_text(f"{int(self.timer)}!", self.screen_width / 2, self.screen_height / 2, arcade.color.RED, 50, anchor_x = 'center', anchor_y = 'center') elif self.pagina == 1 and self.timer <= 0: arcade.draw_text("VAI!", self.screen_width / 2, self.screen_height / 2, arcade.color.RED, 50, anchor_x = 'center', anchor_y = 'center') self.pagina = 2 elif self.pagina == 2: arcade.draw_points(self.estrelas_brancas, arcade.color.WHITE, 2) arcade.draw_points(self.estrelas_vermelhas, arcade.color.DARK_PINK, 2) arcade.draw_points(self.estrelas_azuis, arcade.color.COLUMBIA_BLUE, 2) arcade.draw_points(self.estrelas_laranjas, arcade.color.DARK_ORANGE, 2) self.player.draw() self.espinho.draw() self.plat_list.draw() vidas_restantes = f"Vidas: {self.vida}" if self.vida >= 0: arcade.draw_text(vidas_restantes, self.screen_width - 200 , self.screen_height - 50, arcade.color.DANDELION, 30) else: arcade.draw_text("GAME OVER!", self.screen_width / 2 , self.screen_height / 2, arcade.color.RED, 40, anchor_x= 'center', anchor_y = 'center') pontos_jogador = f"Pontos: {self.pontos}" if self.vida >= 0: arcade.draw_text(pontos_jogador, 50 , self.screen_height - 50, arcade.color.DANDELION, 30) else: arcade.draw_text("GAME OVER!", self.screen_width / 2 , self.screen_height / 2, arcade.color.RED, 40, anchor_x= 'center', anchor_y = 'center')
def drawBackground(): #Drawing points on the screen point_list = ((150, 60), (400, 60), (700, 60), (950, 60), (60, 260), (250, 260), (450, 260), (650, 260), (850, 260), (1060, 260), (60, 460), (380, 460), (500, 460), (650, 460), (750, 460), (1060, 460), (60, 660), (480, 660), (550, 660), (600, 660), (680, 660), (1060, 660), (600, 800)) arcade.draw_points(point_list, arcade.color.PURPLE, 75) #Drawing the lines shwoing the board play point connections point_list = ((600, 800), (150, 60), (600, 800), (400, 60), (600, 800), (700, 60), (600, 800), (950, 60), (60, 660), (1060, 660), (60, 460), (1060, 460), (60, 260), (1060, 260), (150, 60), (950, 60), (60, 660), (60, 260), (1060, 660), (1060, 260)) arcade.draw_lines(point_list, arcade.color.PURPLE, 4)
def draw_outside(): # Snow and moon outside with drawn points arcade.draw_circle_filled(625, 505, 30, arcade.color.CREAM) arcade.draw_circle_outline(625, 505, 30, arcade.color.CADMIUM_YELLOW, 5) point_list = ((565, 470), (565, 480), (460, 470), (525, 526), (450, 530), (430, 500), (648, 490), (600, 460), (610, 542), (676, 460)) arcade.draw_points(point_list, arcade.color.WHITE, 10)
def drawboard(self): """ Method to draw the contents of the environment """ # iterate the array and draws a rectangle for each living cell cells = [] for li in range(self.lines): for co in range(self.columns): if self.grid[li, co] == 1: # arcade.draw_xywh_rectangle_filled(co * self.size, # (self.lines-1 - li) * self.size, # self.size, self.size, LIFECOLOUR) cells.append(((co * self.size) + int(self.size / 2), ((self.lines - 1 - li) * self.size) + int(self.size / 2))) if len(cells) > 0: arcade.draw_points(tuple(cells), LIFECOLOUR, self.size)
def draw_solar_panels(position_x, position_y): arcade.draw_rectangle_filled(position_x, position_y, 40, 120, (65, 88, 140)) point_list = (( position_x - 10, position_y - 30, ), (position_x - 10, position_y + 30), (position_x + 10, position_y - 30), (position_x + 10, position_y + 30)) arcade.draw_points(point_list, arcade.color.BLACK, 10) point_list = ((position_x + 27, position_y - 12), (position_x - 27, position_y - 12)) arcade.draw_points(point_list, (121, 123, 128), 10) point_list = ((position_x + 23, position_y + 60), (position_x + 23, position_y - 60), (position_x - 23, position_y + 60), (position_x - 23, position_y - 60)) arcade.draw_lines(point_list, (121, 123, 128), 5)
def on_draw(self): arcade.start_render() arcade.draw_points(self.cities, arcade.color.WHITE, 10) if len(self.path) > 1: arcade.draw_line_strip(self.path, arcade.color.WHITE, 2) if self.done: arcade.draw_text(f"Shortest Path: {self.shortest:.3f}", SCREEN_WIDTH // 2, SCREEN_HEIGHT - 30, arcade.color.WHITE, anchor_x='center') arcade.draw_text( f"Time to Find Shortest Path: {self.total_time:.3f} seconds", SCREEN_WIDTH // 2, SCREEN_HEIGHT - 60, arcade.color.WHITE, anchor_x='center')
def background(): arcade.set_background_color(arcade.color.DARK_VIOLET) arcade.draw_lrtb_rectangle_filled(0, 800, 600 / 3, 0, arcade.color.DARK_SCARLET) arcade.draw_lrtb_rectangle_filled(0, 800, 570 / 3, 0, arcade.color.CAPUT_MORTUUM) arcade.draw_lrtb_rectangle_filled(0, 800, 550 / 3, 0, arcade.color.BISTRE) # Moon and stars arcade.draw_circle_filled(125, 505, 50, arcade.color.CREAM) point_list = ((565, 470), (460, 340), (600, 460), (250, 274), (670, 500), (500, 400), (676, 460), (270, 300), (300, 370), (200, 540), (170, 330), (360, 270), (170, 430), (150, 600), (50, 550), (70, 400), (370, 560), (440, 500), (510, 510)) arcade.draw_points(point_list, arcade.color.WHITE, 10) # House texture1 = arcade.load_texture("images/house.png") scale = .3 arcade.draw_texture_rectangle(650, 329, scale * texture1.width, scale * texture1.height, texture1, 0) # Underground tomb texture2 = arcade.load_texture("images/coffin.png") scale = .1 arcade.draw_texture_rectangle(170, 70, scale * texture2.width, scale * texture2.height, texture2, 50)
def on_draw(): arcade.start_render() arcade.draw_text("Computer Ergonomics", 280, 700, arcade.color.BLACK, 25) # ergonomics tips arcade.draw_text("Tips for sitting at your computer", 60, 650, arcade.color.BLACK, 15) arcade.draw_line(55, 645, 340, 645, arcade.color.WHITE, 2) # Bullet Points point_list = ((60, 633), (60, 603), (60, 573), (60, 543), (60, 483), (60, 453)) arcade.draw_points(point_list, arcade.color.TEAL_DEER, 7) arcade.draw_point(85, 513, arcade.color.MEDIUM_ELECTRIC_BLUE, 5) arcade.draw_text("Sit upright with your back straight and shoulders back", 70, 630, arcade.color.BLACK, 12) arcade.draw_text( "Your body should face the screen, don't twist your head or body to face the screen", 70, 600, arcade.color.BLACK, 12) arcade.draw_text( "Use a chair that has support for your lower back, and a cushioned seat", 70, 570, arcade.color.BLACK, 12) arcade.draw_text("Try to work away from sunlight and windows, ", 70, 540, arcade.color.BLACK, 12) arcade.draw_text( "If not possible position your screen so there’s minimal glare by having the screen face away from the suns’ rays", 95, 510, arcade.color.BLACK, 12) arcade.draw_text( "Periodically stand up and walk around to prevent back strain/pain and neck strains", 70, 480, arcade.color.BLACK, 12) arcade.draw_text( "Use a chair that has support for your lower back, and a cushioned seat", 70, 450, arcade.color.BLACK, 12) #images texture = arcade.load_texture("situp.jpg") scale = 0.25 arcade.draw_texture_rectangle(760, 620, scale * texture.width, scale * texture.height, texture, 0) texture = arcade.load_texture("20-20-eyesights.png") scale = 0.2 arcade.draw_texture_rectangle(200, 200, scale * texture.width, scale * texture.height, texture, 0) # stickman sitting in chair # body arcade.draw_circle_filled(700, 650, 10, arcade.color.FLIRT) arcade.draw_line(700, 640, 700, 600, arcade.color.FLIRT, 1.5) arcade.draw_line(685, 620, 715, 620, arcade.color.FLIRT, 1.5) arcade.draw_line(700, 600, 725, 600, arcade.color.FLIRT, 1.5) arcade.draw_line(700, 600, 725, 600, arcade.color.FLIRT, 1.5) arcade.draw_line(725, 600, 740, 610, arcade.color.FLIRT, 1.5) arcade.draw_line(725, 600, 740, 590, arcade.color.FLIRT, 1.5) # face arcade.draw_line(695, 655, 695, 650, arcade.color.BLACK, 1.5) arcade.draw_line(705, 655, 705, 650, arcade.color.BLACK, 1.5) arcade.draw_arc_outline(700, 646, 4, 4, arcade.color.BLACK, 180, 360) # chair arcade.draw_line(680, 640, 680, 585, arcade.color.JORDY_BLUE, 5) arcade.draw_line(677, 585, 740, 585, arcade.color.JORDY_BLUE, 5) arcade.draw_line(708.5, 585, 708.5, 560, arcade.color.JORDY_BLUE, 5) arcade.draw_line(691.5, 560, 725.5, 560, arcade.color.JORDY_BLUE, 5) arcade.draw_circle_filled(691.5, 550.5, 7, arcade.color.CADMIUM_ORANGE) arcade.draw_circle_filled(725.5, 550.5, 7, arcade.color.CADMIUM_ORANGE) # 20 20 20 rule arcade.draw_text("20-20-20 rule", 70, 375, arcade.color.BLACK, 15) arcade.draw_line(65, 370, 195, 370, arcade.color.WHITE, 2) arcade.draw_text( "Every look at something away for ", 70, 350, arcade.color.BLACK, 12) arcade.draw_text( " 20 minutes 20 feet 20 seconds", 70, 350, arcade.color.BLACK, 12, bold=True) # Button Hotspot arcade.draw_text("CLICK ME", 550, 200, arcade.color.BLACK, 20, bold=True) arcade.draw_rectangle_outline(my_button[0], my_button[1], my_button[2], my_button[3], arcade.color.BLACK) if show_text: arcade.draw_text( "Look out your windows or across the room until you see\nthis message go away in your peripheral vision", 450, 125, arcade.color.PINE_GREEN, 12, bold=True, italic=True) # stickman moving_chair # Stickman arcade.draw_circle_filled(800, 450, 10, arcade.color.FLIRT) arcade.draw_line(800, 440, 800, 400, arcade.color.FLIRT, 1.5) arcade.draw_line(785, 420, 815, 420, arcade.color.FLIRT, 1.5) arcade.draw_line(800, 400, 825, 400, arcade.color.FLIRT, 1.5) arcade.draw_line(800, 400, 825, 400, arcade.color.FLIRT, 1.5) arcade.draw_line(825, 400, 840, 410, arcade.color.FLIRT, 1.5) arcade.draw_line(825, 400, 840, 390, arcade.color.FLIRT, 1.5) # face arcade.draw_line(795, 455, 795, 450, arcade.color.BLACK, 1.5) arcade.draw_line(805, 455, 805, 450, arcade.color.BLACK, 1.5) arcade.draw_arc_outline(800, 446, 4, 4, arcade.color.BLACK, 180, 360) arcade.draw_text( "Animation is supposed to depict\nman getting up from his seat", 725, 325, arcade.color.BLACK, 8) chair(chair_x, 50)
# Set background color to space black and create the trunk. arcade.start_render() arcade.draw_lrtb_rectangle_filled(190, 400, 400, 250, (203, 214, 214)) arcade.draw_lrtb_rectangle_outline(190, 400, 400, 250, (121, 123, 128), 5) # little squares 1 arcade.draw_lrtb_rectangle_filled(180, 190, 300, 290, (121, 123, 128)) arcade.draw_lrtb_rectangle_filled(400, 410, 300, 290, (121, 123, 128)) # First lateral Panels(left,right) arcade.draw_lrtb_rectangle_filled(140, 180, 370, 250, (65, 88, 140)) arcade.draw_lrtb_rectangle_filled(410, 450, 370, 250, (65, 88, 140)) point_list = ((160, 280), (160, 340), (430, 280), (430, 340)) arcade.draw_points(point_list, (0, 0, 0), 10) # little squares 2 arcade.draw_lrtb_rectangle_filled(130, 140, 300, 290, (121, 123, 128)) arcade.draw_lrtb_rectangle_filled(450, 460, 300, 290, (121, 123, 128)) # Second lateral panels arcade.draw_lrtb_rectangle_filled(90, 130, 370, 250, (65, 88, 140)) arcade.draw_lrtb_rectangle_filled(460, 500, 370, 250, (65, 88, 140)) point_list = ((100, 280), (100, 340), (120, 280), (120, 340), (470, 280), (470, 340), (490, 280), (490, 340)) arcade.draw_points(point_list, (0, 0, 0), 10) # little squares 3 point_list = ((85, 295), (505, 295)) arcade.draw_points(point_list, (121, 123, 128), 10) # Third lateral panels arcade.draw_lrtb_rectangle_filled(45, 85, 370, 250, (65, 88, 140))
for y in range(0, 601, 200): arcade.draw_line(0, y, 800, y, arcade.color.WHITE, 2) # Draw a point arcade.draw_text("draw_point", 7, 405, arcade.color.WHITE, 12) arcade.draw_point(60, 495, arcade.color.RED, 10) # Draw a set of points arcade.draw_text("draw_points", 133, 405, arcade.color.WHITE, 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.WHITE, 12) arcade.draw_line(270, 495, 300, 450, arcade.color.BURNT_ORANGE, 3) # Draw a set of lines arcade.draw_text("draw_lines", 363, 405, arcade.color.WHITE, 12) point_list = ((390, 450), (450, 450), (390, 480), (450, 480), (390, 510), (450, 510) ) arcade.draw_lines(point_list, arcade.color.BLUE, 3)
def draw_agent_objects(self, agent): a = agent e = self.env m = a.map ppm = e.px_per_m angle = a.angle theta = angle + pi / 2 if self.env.is_one_waypoint_map: arcade.draw_circle_filled( center_x=m.x_pixels[1], center_y=m.y_pixels[1], radius=21, color=color.ORANGE) if self.static_obstacle: static_obst_pixels = m.static_obst_pixels arcade.draw_line( static_obst_pixels[0][0], static_obst_pixels[0][1], static_obst_pixels[1][0], static_obst_pixels[1][1], color=color.BLACK_OLIVE, line_width=5, ) elif self.is_intersection_map: if agent.agent_index == 0: wp_clr = (10, 210, 50) else: wp_clr = (250, 140, 20) for i in range(len(m.waypoints)): arcade.draw_circle_filled( center_x=m.x_pixels[i], center_y=m.y_pixels[i], radius=21, color=wp_clr) else: # Draw the background texture bg_scale = 1.1 arcade.draw_texture_rectangle( MAP_WIDTH_PX // 2 + SCREEN_MARGIN, MAP_HEIGHT_PX // 2 + SCREEN_MARGIN, MAP_WIDTH_PX * bg_scale, MAP_HEIGHT_PX * bg_scale, self.background) if a.ego_rect is not None and DRAW_COLLISION_BOXES: arcade.draw_rectangle_outline( center_x=a.x * ppm, center_y=a.y * ppm, width=a.vehicle_width * ppm, height=a.vehicle_height * ppm, color=color.LIME_GREEN, border_width=2, tilt_angle=math.degrees(a.angle), ) arcade.draw_points(point_list=(a.ego_rect * ppm).tolist(), color=color.YELLOW, size=3) if a.front_to_waypoint is not None and DRAW_WAYPOINT_VECTORS: ftw = a.front_to_waypoint fy = a.front_y fx = a.front_x # arcade.draw_line( # start_x=e.front_x * ppm, # start_y=e.front_y * ppm, # end_x=(e.front_x + ftw[0]) * ppm, # end_y=(e.front_y + ftw[1]) * ppm, # color=c.LIME_GREEN, # line_width=2, # ) arcade.draw_line( start_x=fx * ppm, start_y=fy * ppm, end_x=(fx + cos( theta - a.angle_to_waypoint) * a.distance_to_end) * ppm, end_y=(fy + sin( theta - a.angle_to_waypoint) * a.distance_to_end) * ppm, color=color.PURPLE, line_width=2, ) # Center to front length ctf = a.vehicle_height / 2 arcade.draw_line( start_x=a.x * ppm, start_y=a.y * ppm, end_x=(a.x + cos(theta) * 20) * ppm, end_y=(a.y + sin(theta) * 20) * ppm, color=color.LIGHT_RED_OCHRE, line_width=2, ) arcade.draw_line( start_x=fx * ppm, start_y=fy * ppm, end_x=(fx + a.heading[0]) * ppm, end_y=(fy + a.heading[1]) * ppm, color=color.BLUE, line_width=2, ) arcade.draw_circle_filled( center_x=fx * ppm, center_y=fy * ppm, radius=5, color=color.YELLOW) arcade.draw_circle_filled( center_x=a.x * ppm, center_y=a.y * ppm, radius=5, color=color.WHITE_SMOKE, ) arcade.draw_circle_filled( center_x=a.static_obstacle_points[0][0] * ppm, center_y=a.static_obstacle_points[0][1] * ppm, radius=5, color=color.WHITE_SMOKE, ) arcade.draw_circle_filled( center_x=a.static_obstacle_points[1][0] * ppm, center_y=a.static_obstacle_points[1][1] * ppm, radius=5, color=color.WHITE_SMOKE, ) if a.static_obst_angle_info is not None: start_obst_dist, end_obst_dist, start_obst_angle, end_obst_angle = \ a.static_obst_angle_info # start_obst_theta = start_obst_angle # arcade.draw_line( # start_x=fx * ppm, # start_y=fy * ppm, # end_x=(fx + cos(start_obst_theta) * start_obst_dist) * ppm, # end_y=(fy + sin(start_obst_theta) * start_obst_dist) * ppm, # color=c.BLACK, # line_width=2,) # log.info('DRAWING LINES') arcade.draw_line( start_x=fx * ppm, start_y=fy * ppm, end_x=(fx + cos( theta - start_obst_angle) * start_obst_dist) * ppm, end_y=(fy + sin( theta - start_obst_angle) * start_obst_dist) * ppm, color=color.BLUE, line_width=2, ) p_x = a.front_x + cos(theta + pi / 6) * 20 p_y = a.front_y + sin(theta + pi / 6) * 20 pole_test = np.array((p_x, p_y)) pole_angle = a.get_angle_to_point(pole_test) arcade.draw_circle_filled( center_x=pole_test[0] * ppm, center_y=pole_test[1] * ppm, radius=5, color=color.WHITE_SMOKE, ) arcade.draw_line( start_x=fx * ppm, start_y=fy * ppm, end_x=(fx + cos( (angle + math.pi / 2) - pole_angle) * 20) * ppm, end_y=(fy + sin( (angle + math.pi / 2) - pole_angle) * 20) * ppm, color=color.BRIGHT_GREEN, line_width=2, ) # arcade.draw_line( # start_x=fx * ppm, # start_y=fy * ppm, # end_x=(fx + cos((angle + math.pi / 2) - end_obst_angle) * end_obst_dist) * ppm, # end_y=(fy + sin((angle + math.pi / 2) - end_obst_angle) * end_obst_dist) * ppm, # color=c.RED, # line_width=2,) arcade.draw_line( start_x=fx * ppm, start_y=fy * ppm, end_x=(a.static_obstacle_points[1][0]) * ppm, end_y=(a.static_obstacle_points[1][1]) * ppm, color=color.RED, line_width=2, )
def draw_points(self): arcade.draw_points(self.points, arcade.color.WILLPOWER_ORANGE, 1.0)
def draw(self): path = self.get_path() arcade.draw_points(path, arcade.color.GOLD, 3)
def on_draw(self): arcade.start_render() if self.game_state == STATE_PLAYING: point_list = ((SCREEN_WIDTH // 2, 693), (SCREEN_WIDTH // 2, 665), (SCREEN_WIDTH // 2, 651), (SCREEN_WIDTH // 2, 623), (SCREEN_WIDTH // 2, 609), (SCREEN_WIDTH // 2, 581), (SCREEN_WIDTH // 2, 567), (SCREEN_WIDTH // 2, 539), (SCREEN_WIDTH // 2, 525), (SCREEN_WIDTH // 2, 497), (SCREEN_WIDTH // 2, 483), (SCREEN_WIDTH // 2, 455), (SCREEN_WIDTH // 2, 441), (SCREEN_WIDTH // 2, 413), (SCREEN_WIDTH // 2, 399), (SCREEN_WIDTH // 2, 371), (SCREEN_WIDTH // 2, 357), (SCREEN_WIDTH // 2, 329), (SCREEN_WIDTH // 2, 315), (SCREEN_WIDTH // 2, 287), (SCREEN_WIDTH // 2, 273), (SCREEN_WIDTH // 2, 245), (SCREEN_WIDTH // 2, 234), (SCREEN_WIDTH // 2, 206), (SCREEN_WIDTH // 2, 192), (SCREEN_WIDTH // 2, 164), (SCREEN_WIDTH // 2, 150), (SCREEN_WIDTH // 2, 122), (SCREEN_WIDTH // 2, 108), (SCREEN_WIDTH // 2, 80), (SCREEN_WIDTH // 2, 66), (SCREEN_WIDTH // 2, 38), (SCREEN_WIDTH // 2, 24), (SCREEN_WIDTH // 2, 0)) arcade.draw_points(point_list, arcade.color.LIGHT_GRAY, 14) self.ball.on_draw() self.rectangle.on_draw() self.rectangle2.on_draw() self.score_board.on_draw() self.score_board2.on_draw() # Hier geef je aan wat hij moet typen als je GAME OVER bent if self.game_state == STATE_GAME_OVER: arcade.draw_text( f" GAME OVER", 155, 300, arcade.color.WHITE, 100, bold=True, ) arcade.draw_text(f" (PRESS ENTER TO PLAY AGAIN)", 345, 80, arcade.color.RED, 20, bold=True) # Hier geef je aan wat hij moet typen als je gaat beginnen met het spel if self.game_state == STATE_MENU: arcade.draw_text(f" PRESS SPACE TO START", 10, 300, arcade.color.WHITE, 80, bold=True)
def on_draw(): arcade.start_render() arcade.draw_text("Cloud computing", 280, 700, arcade.color.BLACK, 25) # About cloud computing arcade.draw_text("What is cloud computing?", 60, 650, arcade.color.BLACK, 15) arcade.draw_text( "Cloud computing (The cloud) is storing and accessing data and programs via the Internet rather", 60, 625, arcade.color.BLACK, 12) arcade.draw_text( "than on your hard drive. It is stored on remote servers, instead of than on your own computer.", 60, 607, arcade.color.BLACK, 12) arcade.draw_text("3 main types", 60, 575, arcade.color.BLACK, 15) arcade.draw_line(58, 571, 172, 571, arcade.color.BLACK, 1.5) # Software as a Service arcade.draw_text("Software as a Service (SaaS)", 75, 532, arcade.color.BLACK, 13.5) # Bullet Points point_list = ((100, 520), (100, 490), (100, 475), (100, 460)) arcade.draw_points(point_list, arcade.color.TEAL_DEER, 5) arcade.draw_point(120, 505, arcade.color.SELECTIVE_YELLOW, 5) arcade.draw_text( "Allows users to connect to and use apps via the internet ", 110, 515, arcade.color.BLACK, 11) arcade.draw_text("Examples include email, calenders", 130, 500, arcade.color.BLACK, 11) arcade.draw_text( "All software and infrastructure is taken care of by service provider", 110, 485, arcade.color.BLACK, 11) arcade.draw_text( "Customers usually rent service based on month-month and connect to it online", 110, 470, arcade.color.BLACK, 11) arcade.draw_text("Allows organization to quickly start with minimal cost", 110, 455, arcade.color.BLACK, 11) # Infrastructure as a Service arcade.draw_text("Infrastructure as a Service (IaaS)", 75, 402, arcade.color.BLACK, 13.5) point_list = ((100, 390), (100, 375), (100, 360), (100, 345), (100, 330)) arcade.draw_points(point_list, arcade.color.TEAL_DEER, 5) arcade.draw_text("Instant computing infrastructure", 110, 385, arcade.color.BLACK, 11) arcade.draw_text("You only pay for what you use", 110, 370, arcade.color.BLACK, 11) arcade.draw_text( "Service provider manages infrastructure, customer manages the software", 110, 355, arcade.color.BLACK, 11) arcade.draw_text("No need to buy your own physical servers", 110, 340, arcade.color.BLACK, 11) arcade.draw_text("Common uses of IaaS", 110, 325, arcade.color.BLACK, 11) point_list = ((120, 315), (120, 300)) arcade.draw_points(point_list, arcade.color.SELECTIVE_YELLOW, 5) arcade.draw_text("High-performance computing", 130, 310, arcade.color.BLACK, 11) arcade.draw_text("Big data analysis", 130, 295, arcade.color.BLACK, 11) #Platform as a Service arcade.draw_text("Platform as a Service (PaaS)", 75, 242, arcade.color.BLACK, 13.5) point_list = ((100, 230), (100, 215), (100, 200), (100, 170), (100, 155)) arcade.draw_points(point_list, arcade.color.TEAL_DEER, 5) point_list = ((120, 185), (120, 140), (120, 125)) arcade.draw_points(point_list, arcade.color.SELECTIVE_YELLOW, 5) arcade.draw_text("Development and deployment in the cloud", 110, 225, arcade.color.BLACK, 11) arcade.draw_text( "Lets you deliver simple cloud-based apps to sophisticated, cloud-enabled apps", 110, 210, arcade.color.BLACK, 11) arcade.draw_text( "Includes features of IaaS (infrastructure—servers, storage, and networking)", 110, 195, arcade.color.BLACK, 11) arcade.draw_text( "Additionally includes middleware, development tools, business intelligence services, database management systems", 130, 180, arcade.color.BLACK, 11) arcade.draw_text( "You manage the applications and services you develop, and the cloud service provider manages everything else", 110, 165, arcade.color.BLACK, 11) arcade.draw_text("Common uses of PaaS ", 110, 150, arcade.color.BLACK, 11) arcade.draw_text( "Development framework, develop or customize cloud based apps", 130, 134, arcade.color.BLACK, 11) arcade.draw_text( "Analytics or business intelligence, forecast product success, investment returns", 130, 120, arcade.color.BLACK, 11)
arcade.set_background_color(arcade.color.DARK_VIOLET) # AMARANTH_PURPLE arcade.start_render() # Floor CAPUT_MORTUUM arcade.draw_lrtb_rectangle_filled(0, 800, 600 / 3, 0, arcade.color.DARK_SCARLET) arcade.draw_lrtb_rectangle_filled(0, 800, 570 / 3, 0, arcade.color.CAPUT_MORTUUM) # Moon and stars arcade.draw_circle_filled(125, 505, 50, arcade.color.CREAM) point_list = ((565, 470), (460, 340), (600, 460), (250, 274), (670, 500), (500, 400), (676, 460), (270, 300), (300, 370), (200, 540), (170, 330), (360, 270), (170, 430), (150, 600), (50, 550), (70, 400), (370, 560), (440, 500), (510, 510)) arcade.draw_points(point_list, arcade.color.WHITE, 10) # House texture1 = arcade.load_texture("house.png") scale = .3 arcade.draw_texture_rectangle(650, 329, scale * texture1.width, scale * texture1.height, texture1, 0) # Underground tomb texture2 = arcade.load_texture("coffin.png") scale = .1 arcade.draw_texture_rectangle(170, 70, scale * texture2.width, scale * texture2.height, texture2, 50) # finish then remain til closed arcade.finish_render() arcade.run()
def draw(self): arcade.draw_text(f'{self.pid}', self.x+5, self.y+5, arcade.color.WHITE, 10) arcade.draw_points([(self.x,self.y)], self.color, 10)
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()
def on_draw(self): arcade.start_render() arcade.set_viewport(-OFFSET, PITCH_L+OFFSET, -OFFSET, PITCH_W+OFFSET) point_list = ((0, 0), (0, PITCH_W), (PITCH_L, PITCH_W), (PITCH_L,0)) arcade.draw_polygon_outline(point_list, arcade.color.WHITE, 3) arcade.draw_line(PITCH_L/2, 0, PITCH_L/2, PITCH_W, arcade.color.WHITE, 3) R = 9.15 arcade.draw_points([(PITCH_L/2, PITCH_W/2)], arcade.color.WHITE, 5) arcade.draw_circle_outline(PITCH_L/2, PITCH_W/2, R*10, arcade.color.WHITE, 3) SMAL_BOX_W = (7.32/2 + 5.5) * 2 SMAL_BOX_L = 5.5 point_list = ((0, PITCH_W/2+(SMAL_BOX_W/2)*10), (SMAL_BOX_L*10, PITCH_W/2+(SMAL_BOX_W/2)*10), (SMAL_BOX_L*10, PITCH_W/2-(SMAL_BOX_W/2)*10), (0, PITCH_W/2-(SMAL_BOX_W/2)*10)) arcade.draw_polygon_outline(point_list, arcade.color.WHITE, 3) point_list = ((PITCH_L, PITCH_W/2+(SMAL_BOX_W/2)*10), (PITCH_L-SMAL_BOX_L*10, PITCH_W/2+(SMAL_BOX_W/2)*10), (PITCH_L-SMAL_BOX_L*10, PITCH_W/2-(SMAL_BOX_W/2)*10), (PITCH_L, PITCH_W/2-(SMAL_BOX_W/2)*10) ) arcade.draw_polygon_outline(point_list, arcade.color.WHITE, 3) LARGE_BOX_W = 40.3 LARGE_BOX_L = 16.5 point_list = ((0, PITCH_W/2+(LARGE_BOX_W/2)*10), (LARGE_BOX_L*10, PITCH_W/2+(LARGE_BOX_W/2)*10), (LARGE_BOX_L*10, PITCH_W/2-(LARGE_BOX_W/2)*10), (0, PITCH_W/2-(LARGE_BOX_W/2)*10)) arcade.draw_polygon_outline(point_list, arcade.color.WHITE, 3) point_list = ((PITCH_L, PITCH_W/2+(LARGE_BOX_W/2)*10), (PITCH_L-LARGE_BOX_L*10, PITCH_W/2+(LARGE_BOX_W/2)*10), (PITCH_L-LARGE_BOX_L*10, PITCH_W/2-(LARGE_BOX_W/2)*10), (PITCH_L, PITCH_W/2-(LARGE_BOX_W/2)*10) ) arcade.draw_polygon_outline(point_list, arcade.color.WHITE, 3) arcade.draw_points([(11*10, PITCH_W/2), (PITCH_L-11*10, PITCH_W/2)], arcade.color.WHITE, 5) for player in self.players_list: player.draw() if self.mode == 'V': for passline in self.passes_list: passline.draw() elif self.mode == 'P': self.p.draw() top1 = (pd.Series(self.hits) <= 1).mean() top2 = (pd.Series(self.hits) <= 2).mean() top3 = (pd.Series(self.hits) <= 3).mean() mrr = (1/pd.Series(self.hits)).mean() arcade.draw_text(f'MRR: {mrr:.2}, top 1/2/3: {top1:.2}/{top2:.2}/{top3:.2}', 30, PITCH_W-30, arcade.color.WHITE, 12) arcade.draw_text(f'example {self.cur_example}', PITCH_L-170, PITCH_W-30, arcade.color.WHITE, 12)
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)
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( ":resources:images/space_shooter/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) # # Overlapping, with transparency test # Draw arcade.draw_rectangle_filled(650, 100, 50, 50, (255, 0, 0)) arcade.draw_rectangle_filled(670, 100, 50, 50, (0, 255, 0, 127)) import sys # TODO: Fix. See https://github.com/pvcraven/arcade/issues/539 if sys.platform != "darwin": # Test colors color = arcade.get_pixel(635, 100) assert color == (255, 0, 0) color = arcade.get_pixel(670, 100) assert color == (128, 127, 0) color = arcade.get_pixel(690, 100) assert color == (128, 255, 128) # Test this other thing color = arcade.get_pixel(100, 100) assert color == (255, 255, 255) # Run the get image. Ideally we'd test the output arcade.get_image()