def draw_instructions_page(self, page): """ Draw an instruction page. Load the page as an image. """ texture = arcade.load_texture("images/instructions_{}.png" .format(page)) arcade.draw_texture_rectangle(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2, texture.width, texture.height, texture, 0)
def draw_instructions_page(self, page_number): """ Draw an instruction page. Load the page as an image. """ page_texture = self.instructions[page_number] arcade.draw_texture_rectangle(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2, page_texture.width, page_texture.height, page_texture, 0)
def draw(self): """ Draw the menu items :return: None """ # Start Screen arcade.draw_texture_rectangle(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, SCREEN_WIDTH, SCREEN_HEIGHT, self.home_screen_background) # Title arcade.draw_text("Asteroid Shooter", 400, 500, arcade.color.WHITE, 30, width=500, align="center", anchor_x="center", anchor_y="center") # Play button arcade.draw_rectangle_outline(400, 200, 250, 50, arcade.color.WHITE) arcade.draw_text("Press SPACE to start", 400, 200, arcade.color.WHITE, 20, width=300, align="center", anchor_x="center", anchor_y="center") # Instructions button arcade.draw_rectangle_outline(400, 140, 200, 50, arcade.color.WHITE) arcade.draw_text("Press I for Instructions", 400, 140, arcade.color.WHITE, 15, width=300, align="center", anchor_x="center", anchor_y="center")
def draw_story_page(self, page_number): arcade.set_background_color(arcade.color.SKY_BLUE) arcade.draw_rectangle_filled(495, 50, 990, 100, arcade.color.GREEN) arcade.draw_text('"HEY THIS IS THE VERY INTERESTING BACK STORY ' '\nBEHIND BLOCK ADVENTURE, THIS IS NOT IMPORTANT ' '\nAT ALL TO YOUR GAMEPLAY SO YOU CAN SKIP THIS ' '\nIF YOU WANT BUT HERE IS THE SAD STORY OF BLUE ' '\nBLOCK. BLUE BLOCK WAS A CRACKHEAD.ONE DAY HIS ' '\nMOM TOLD HIM TO GET GROCERIES BUT HE WAS ALREADY ' '\nINTOXICATED OUT OF HIS MIND. AFTER ARGUING WITH ' '\nWHO HE THOUGHT WAS HIS MOM FOR A WHILE (IT WAS ' '\nHIS PET HUMAN) HE GOES OUT TO BUY GROCERIES. ' '\nUNLUCKILY FOR HIM THERE WAS A WHOLE NEW ADVENTURE ' '\nWAITING OUTSIDE FOR HIM. NOT LIKE LORD OF THE RINGS' '\nBUT NONETHELESS AN ADVENTURE WAY MORE ENTERTAINING ' '\nTHAN HIS NORMAL INSIDE LIFE."', 150, 250, arcade.color.BLACK, 25) block_image = arcade.load_texture("Images/RedBlock.png") scale = 1.7 arcade.draw_texture_rectangle(100, 155, scale * block_image.width, scale * block_image.height, block_image, 0)
def draw_ransomware_intro(): # TOP LINE: start_x, start_y, end_x, end_y arcade.draw_line(0, 650, 350, 650, arcade.color.DARK_BLUE, 4) # BOTTOM LINE: start_x, start_y, end_x, end_y arcade.draw_line(0, 550, 300, 550, arcade.color.DARK_BLUE, 4) # CONNECTOR LINE: start_x, start_y, end_x, end_y arcade.draw_line(300, 550, 350, 650, arcade.color.DARK_BLUE, 4) # FILL the lines; rectangle arcade.draw_xywh_rectangle_filled(0, 550, 300, 100, arcade.color.SKY_BLUE) # FILL the lines; triangle arcade.draw_triangle_filled(350, 650, 300, 650, 300, 550, arcade.color.SKY_BLUE) # Text: "What is a ransomware"? arcade.draw_text("What is a ransomware?", 15, 590, arcade.color.DARK_BLUE, 24, 0, "center", 'calibri', True) arcade.draw_line(12, 580, 290, 580, arcade.color.DARK_BLUE, 3) # BULLET POINT AND TEXT 1 arcade.draw_circle_filled(25, 515, 5, arcade.color.DARK_BLUE) arcade.draw_text( "A malware that forcefully encrypts data, \nand demands ransom to \"save\" malware-led", 35, 505, arcade.color.BLACK, 14, 0) arcade.draw_text("data destruction.", 35, 487, arcade.color.DARK_RED, 14) # fills in blank, w/ different colour # BULLET POINT AND TEXT 2 arcade.draw_circle_filled(25, 455, 5, arcade.color.DARK_BLUE) arcade.draw_text( "If ransom isn't paid, the data is destroyed. \nNo guarantee of decryption either.", 35, 440, arcade.color.BLACK, 14) # BULLET POINT AND TEXT 3 arcade.draw_circle_filled(25, 420, 5, arcade.color.DARK_BLUE) arcade.draw_text("e.g. WannaCry, CryptoLocker, etc.", 35, 415, arcade.color.RED, 14) # EXAMPLE IMAGE - WannaCry virus ransomware_image = arcade.load_texture("textures/ransomware_image.png") arcade.draw_texture_rectangle(530, 525, 0.55 * ransomware_image.width, 0.55 * ransomware_image.height, ransomware_image)
def draw_end_screen(x, y): global alien_points, human_points, elapsed_time scale = 1.67 texture = arcade.load_texture("space2.jpg") arcade.draw_texture_rectangle(x, y, scale * texture.width, scale * texture.height, texture, 0) arcade.draw_text("GAME OVER!", 270, 500, arcade.color.BLACK, 65, font_name='GARA') arcade.draw_text("press space to restart", 350, 75, arcade.color.BLACK, 25) if alien_points > human_points or alien_times_hit == 3: arcade.draw_text("The Humans Have Won Control!", 175, 400, arcade.color.BLACK, 40) elif human_points > alien_points or human_times_hit == 3: arcade.draw_text("The Aliens Have Won Control!", 200, 400, arcade.color.BLACK, 40) else: arcade.draw_text("It's a tie! Peace has been achieved.", 150, 400, arcade.color.BLACK, 40) arcade.draw_text("For now...", 800, 350, arcade.color.BLACK, 25)
def draw_background(background): # break_point = SCREEN_HEIGHT*(1/3) # arcade.draw_lrtb_rectangle_filled(0, SCREEN_WIDTH, SCREEN_HEIGHT, break_point, arcade.color.SKY_BLUE) # arcade.draw_lrtb_rectangle_filled(0, SCREEN_WIDTH, break_point, 0, arcade.color.FOREST_GREEN) arcade.draw_texture_rectangle(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2, SCREEN_WIDTH, SCREEN_HEIGHT, background) def set_button_textures(): normal = ":resources:gui_themes/Fantasy/Buttons/Normal.png" hover = ":resources:gui_themes/Fantasy/Buttons/Hover.png" clicked = ":resources:gui_themes/Fantasy/Buttons/Clicked.png" locked = ":resources:gui_themes/Fantasy/Buttons/Locked.png" a = Theme() button_theme = a.add_button_textures(normal, hover, clicked, locked) return button_theme button_theme = set_button_textures() button = StopButton(x=100, y=500, theme=button_theme) button.draw()
def draw_invincibility(self): # Load the image of the ship from the images folder self.invincibility_life -= 1 if self.invincibility_life == 0: self.invincible = False img = "images/normandy - teal.png" texture = arcade.load_texture(img) width = 150 height = 100 alpha = 1 # For transparency, 1 means not transparent x = self.center.x y = self.center.y angle = self.angle - 90 # Shift the unit cirlce 90 degrees arcade.draw_texture_rectangle(x, y, width, height, texture, angle, alpha)
def draw_question(self): if not self.waiting_on_input: with open('questions.csv') as questions: rows = questions.readlines() data = random.choice( list( csv.reader(rows, quotechar='"', delimiter=',', quoting=csv.QUOTE_ALL, skipinitialspace=True))) self.question = data[0] self.correct_answer = int(data[1]) self.waiting_on_input = True background = arcade.load_texture("assets/images/questions/" + self.question + ".png") arcade.draw_texture_rectangle(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2, SCREEN_WIDTH, SCREEN_HEIGHT, background)
def on_draw(self): arcade.start_render() arcade.draw_texture_rectangle(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2, self.background_image.width, self.background_image.height, self.background_image, 0) self.pipe_list.draw() if self.player.started and not self.player.moving and self.flash_drawn < 5: arcade.draw_rectangle_filled(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2, SCREEN_WIDTH, SCREEN_HEIGHT, arcade.color.WHITE) self.flash_drawn += 1 elif self.player.dead: arcade.draw_text("\t Score: {}\nPress R to restart".format( self.score), 0.19 * SCREEN_WIDTH, 0.9 * SCREEN_HEIGHT, arcade.color.WHITE, 30, bold=True, font_name="Rockwell Nova") elif self.player.started: arcade.draw_text("{}".format(self.score), SCREEN_WIDTH // 2, int(0.9 * SCREEN_HEIGHT), arcade.color.WHITE, 30, bold=True, font_name="Rockwell Nova") # Call draw() on all your sprite lists below self.player_list.draw() if not self.player.started: self.title_list.draw() arcade.draw_text(str(self.fps), 0.9 * SCREEN_WIDTH, 0.95 * SCREEN_HEIGHT, arcade.color.WHITE, 20, bold=True)
def on_draw(self): """ Render the screen. """ # This command should happen before we start drawing. It will clear # the screen to the background color, and erase what we drew last frame. arcade.start_render() # Call draw() on all your sprite lists below # Draw the background texture arcade.draw_texture_rectangle(600, 300, 1200, 1000, self.background) self.my_cat.draw() self.my_paddle1.draw() self.my_paddle2.draw() arcade.draw_text(f"Player 1: {self.score1}", 300, 700, arcade.color.ALICE_BLUE, 25, 0, "left", "QuietMeows-48jx.ttf" ) arcade.draw_text(f"Player 2: {self.score2}", 700, 700, arcade.color.ALICE_BLUE, 25, 0, "right", "QuietMeows-48jx.ttf")
def on_draw(self): arcade.start_render() if self.current_state == 0: arcade.draw_rectangle_filled(SW / 2, SH / 2, SW, SH, arcade.color.BLACK) arcade.draw_text( "Use arrow keys to move, collect as many coins as possible and avoid the bombs", SW / 2, SH / 2 - 30, arcade.color.GHOST_WHITE, 14, align="center", anchor_x="center") elif not self.gameover: arcade.draw_texture_rectangle( SW / 2, SH / 2, SW, SH, arcade.load_texture("background.jpg")) self.player_list.draw() self.bomb_list.draw() self.coin_list.draw() the_score = f"Score: {self.score}" arcade.draw_text(the_score, SW - 90, SH - 35, arcade.color.BLACK, 14) else: output = f"Score: {self.score}" arcade.draw_rectangle_filled(SW / 2, SH / 2, SW, SH, arcade.color.BLACK) arcade.draw_text("Game Over! Press SPACE to play again", SW / 2, SH / 2 - 30, arcade.color.GHOST_WHITE, 14, align="center", anchor_x="center") arcade.draw_text(output, SW / 2, SH / 2 - 50, arcade.color.GHOST_WHITE, 14, align="center", anchor_x="center")
def on_draw(self): """ 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. self.player_list.draw()
def on_draw(self): """ 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.background) # Draw all the sprites. self.all_sprites_list.draw() # Put the text on the screen. output = "Score: {}".format(self.score) arcade.draw_text(output, 10, 20, arcade.color.WHITE, 14)
def game_play_screen(): # lines vertical arcade.draw_line(200, 100, 200, 400, arcade.color.BLACK, 4) arcade.draw_line(300, 100, 300, 400, arcade.color.BLACK, 4) # horizontal lines arcade.draw_line(100, 200, 400, 200, arcade.color.BLACK, 4) arcade.draw_line(100, 300, 400, 300, arcade.color.BLACK, 4) # drawing in the O's and X's when the buttons are pressed # circle_1 arcade.draw_circle_outline(circle_1_x, circle_1_y, 35, arcade.color.BLACK, 5) # cross_1 texture = arcade.load_texture("x marks the spot .png") scale = .35 arcade.draw_texture_rectangle(x_1_x, x_1_y, scale * texture.width, scale * texture.height, texture, 0) # circle 2 arcade.draw_circle_outline(circle_2_x, circle_2_y, 35, arcade.color.BLACK, 5) # cross 2 texture = arcade.load_texture("x marks the spot .png") scale = .35 arcade.draw_texture_rectangle(x_2_x, x_2_y, scale * texture.width, scale * texture.height, texture, 0) # circle 3 arcade.draw_circle_outline(circle_3_x, circle_3_y, 35, arcade.color.BLACK, 5) # cross 3 texture = arcade.load_texture("x marks the spot .png") scale = .35 arcade.draw_texture_rectangle(x_3_x, x_3_y, scale * texture.width, scale * texture.height, texture, 0) # circle 4 arcade.draw_circle_outline(circle_4_x, circle_4_y, 35, arcade.color.BLACK, 5) # cross 4 texture = arcade.load_texture("x marks the spot .png") scale = .35 arcade.draw_texture_rectangle(x_4_x, x_4_y, scale * texture.width, scale * texture.height, texture, 0) # circle 5 arcade.draw_circle_outline(circle_5_x, circle_5_y, 35, arcade.color.BLACK, 5) # go back button arcade.draw_rectangle_filled(80, 450, 100, 50, arcade.color.YELLOW_ROSE) arcade.draw_text("Back", 40, 435, arcade.color.BLACK, 30) # reset game button arcade.draw_rectangle_filled(400, 450, 190, 50, arcade.color.YELLOW_ROSE) arcade.draw_text("New Game", 310, 435, arcade.color.BLUE, 30)
def on_draw_game(self): arcade.draw_texture_rectangle(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2, SCREEN_WIDTH, SCREEN_HEIGHT, self.background) #### DRAW CHOICE #### self.rock.draw() arcade.render_text(self.text_A, 100, 50) self.paper.draw() arcade.render_text(self.text_S, 200, 50) self.scissor.draw() arcade.render_text(self.text_D, 300, 50) #### DRAW RED #### if self.x == 1: self.rock_red.draw() elif self.x == 2: self.paper_red.draw() elif self.x == 3: self.scissor_red.draw() #### DRAW BLUE #### elif self.x == 4: self.rock_blue.draw() elif self.x == 5: self.paper_blue.draw() elif self.x == 6: self.scissor_blue.draw() #### DRAW SCORE #### output_score = f"Score : {self.score}" if not self.score_text or self.score_text.text != output_score: self.score_text = arcade.create_text(output_score, arcade.color.BLACK, 15) arcade.render_text(self.score_text, 300, 475) #### DRAW TIME #### output_time = f"Time : {round(self.time)}" if not self.time_text or self.time_text.text != output_time: self.time_text = arcade.create_text(output_time, arcade.color.BLACK, 15) arcade.render_text(self.time_text, 10, 475)
def on_draw(self): # 화면 그리기 """ Render the screen. """ arcade.start_render() if self.check_game == True: # Draw our sprites self.wall_list.draw() self.background_list.draw() self.coin_list.draw() self.dont_touch_list.draw() self.monster_list.draw() self.platform_list.draw() self.foreground_list.draw() self.ladder_list.draw() self.player_list.draw() #레벨이 0이면 코인 표시 x if self.level != 0: coin_text = "Coin: {}".format(self.coin) #남은 코인 표시 life_text = "Life: {}".format(self.life) arcade.draw_text(coin_text, 10 + self.view_left, 30 + self.view_bottom, arcade.csscolor.BLACK, 18) arcade.draw_text(life_text, 10 + self.view_left, 10 + self.view_bottom, arcade.csscolor.BLACK, 18) else: arcade.start_render() if self.background_title: # 처음 화면 ( 메뉴화면 ) arcade.draw_texture_rectangle( int(1.5 * (screen_width // 3)), int(9.5 * (screen_height // 11)), 274, 62, self. background_title) # x(가운데 ) , y(가운데), 전체 width, 전체 height arcade.draw_texture_rectangle(screen_width // 2, screen_height // 2, screen_width, screen_height, self.background) if self.button_list: for button in self.button_list: button.draw_button() if self.text_list: for text in self.text_list: text.draw_text()
def on_draw(self) -> None: """ Holds all rendering code to screen :return: none, draws to the window """ arcade.start_render() if self.transition is not None: arcade.draw_texture_rectangle(self.WINDOW_WIDTH / 2, self.WINDOW_HEIGHT / 2, 800, 800, self.transition) if self.transition == arcade.load_texture("images/win_screen.png"): arcade.draw_text("<PRESS DELETE TO EXIT>", 250, 40, arcade.color.WHITE, 24) else: arcade.draw_text("<PRESS ENTER>", 300, 40, arcade.color.WHITE, 24) if self.is_game_active: self.rooms[self.world].ground_list.draw() self.rooms[self.world].wall_list.draw() self.rooms[self.world].traps_list.draw() for item in self.enemies: if item.textures is not None: item.draw() for item in self.towers: if item.textures is not None: item.draw() if self.player.textures is not None: self.player.draw() # draw health bar self.draw_health_bar(self.player.health) # if self.world == 4: for item in self.enemies: if isinstance(item, Boss): self.draw_health_bar_boss(item.health, item) # draw tutorial instructions if self.world == 0: arcade.draw_text("Press SPACE to ATTACK", 30, 30, arcade.color.WHITE, 24) arcade.draw_text("Dodge FIREBALLS", 300, 300, arcade.color.WHITE, 24) arcade.draw_text("Kill ENEMIES", 300, 750, arcade.color.WHITE, 24) arcade.draw_text("Avoid the LAVA", 560, 510, arcade.color.WHITE, 24) arcade.draw_text("Press P to PAUSE", 50, 750, arcade.color.WHITE, 24) arcade.draw_text("ARROW KEYS to MOVE", 150, 500, arcade.color.WHITE, 24)
def on_draw(self): arcade.start_render() arcade.draw_texture_rectangle(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2, SCREEN_WIDTH, SCREEN_HEIGHT, self.background) if not self.playing: arcade.draw_text("Thanks for playing!", (SCREEN_WIDTH // 2) - 150, (SCREEN_HEIGHT // 2) + 20, open_color.white, 30) else: self.player_list.draw() self.enemy_list.draw() self.bullet_list.draw() self.enemy_bullet_list.draw() arcade.draw_text("Score: {}".format(int(self.score)), 10, SCREEN_HEIGHT - 30, open_color.white, 16) arcade.draw_text("HP: {}".format(int(self.hp)), SCREEN_WIDTH - 80, SCREEN_HEIGHT - 30, open_color.white, 16) arcade.draw_text(self.title, SCREEN_WIDTH // 2 - 50, SCREEN_HEIGHT - 30, open_color.white, 16)
def on_draw(self): """ 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.background) # Draw all the sprites. self.coin_list.draw() self.player_list.draw() # Render the text arcade.draw_text(f"Score: {self.score}", 10, 20, arcade.color.WHITE, 14)
def draw(self): # draw background arcade.draw_texture_rectangle(self.game.SCREEN_WIDTH // 2, self.game.SCREEN_HEIGHT // 2, self.game.SCREEN_WIDTH, self.game.SCREEN_HEIGHT, self.background) # fade in the logo if self.logo.alpha < 255: fade_in(self.logo, 4) self.logo.draw() # slide in the santa if self.santa.center_y < 140: slide_in(self.santa, 3, 140) self.santa.draw() # fade in buttons after logo is shown if self.logo.alpha == 255: for button in self.button_list: if button.alpha < 255: fade_in(button, 4) button.draw()
def on_draw(self): arcade.start_render() arcade.draw_texture_rectangle(SW // 2, SH // 2, SW, SH, self.background) minutes = int(self.total_time) // 60 seconds = int(self.total_time) % 60 self.player_list.draw() self.reaper_list.draw() objective = "Current Objective: Survive for 1 minute" t_output = f"Time: {minutes:02d}:{seconds:02d}" arcade.draw_text(objective, SW/2, SH - 40, arcade.color.VIOLET_BLUE, 20) arcade.draw_text(t_output, SW / 2, SH - 70, arcade.color.VIOLET_BLUE, 20) if self.gameover == True: arcade.draw_rectangle_filled(SW // 2, SH // 2, SW, SH, arcade.color.BLACK) arcade.draw_text("Game Over: Press P to Play Again!", SW / 2 - 50, SH / 2 - 20, ((0, 255, 0)), 14)
def game_over_screen(self): arcade.draw_texture_rectangle(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2, 900, 600, self.deathtexture) output = "Game Over" arcade.draw_text(output, SCREEN_WIDTH // 2 - 220, SCREEN_HEIGHT // 2 + 200, arcade.color.BLACK, 72) output = "Click SPACE key to restart" arcade.draw_text(output, SCREEN_WIDTH // 2 - 230, SCREEN_HEIGHT // 2 - 210, arcade.color.BLACK, 32) output = "Your SCORE: {}".format(self.score) arcade.draw_text(output, SCREEN_WIDTH // 2 - 100, SCREEN_HEIGHT // 2, arcade.color.BLACK, 24) output = "YOUR BEST SCORE: {}".format(self.bestscore) arcade.draw_text(output, SCREEN_WIDTH // 2 - 140, SCREEN_HEIGHT // 2 - 80, arcade.color.BLACK, 24)
def on_draw(self): """ Render the screen. """ arcade.start_render() # Draw the background texture arcade.draw_texture_rectangle(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_WIDTH * 2, SCREEN_HEIGHT * 2, 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. self.player_list.draw() if self.current_room == 2: arcade.draw_text("oNetWOSeVEntHRee", 1000, 450, arcade.color.WHITE, 50, width=1000, align="center", anchor_x="center", anchor_y="center", rotation=90.0) start_y = 20 start_x = 50 arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5) arcade.draw_text(f"Time elapsed: {self.time_elapsed:7.1f}", start_x, start_y, arcade.color.BLACK, 14)
def on_draw(self): """ Called whenever we need to draw the window. """ arcade.start_render() arcade.draw_texture_rectangle(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2, SCREEN_WIDTH, SCREEN_HEIGHT, self.backround) if not self.playing: arcade.draw_text("You've Done Well Challenger!!!", (SCREEN_WIDTH // 2) - 150, (SCREEN_HEIGHT // 2) + 30, open_color.red_6, 50) else: self.player_list.draw() self.enemy_list.draw() self.bullet_list.draw() self.enemy_bullet_list.draw() arcade.draw_text("Score: {}".format(int(self.score)), 10, SCREEN_HEIGHT - 30, open_color.red_6, 16) arcade.draw_text("HP: {}".format(int(self.hp)), SCREEN_WIDTH - 80, SCREEN_HEIGHT - 30, open_color.red_6, 16)
def on_draw(self): arcade.set_viewport(self.world.panda.x - SCREEN_WIDTH // 2, self.world.panda.x + SCREEN_WIDTH // 2, 0, SCREEN_HEIGHT) arcade.start_render() arcade.draw_texture_rectangle(self.panda_sprite.center_x, SCREEN_HEIGHT // 2, SCREEN_WIDTH + 50, SCREEN_HEIGHT, self.background) self.draw_platforms(self.world.platforms) self.draw_coins(self.world.coins) arcade.draw_text("Space to Start", -100, self.height // 2, arcade.color.RED, 30) self.panda_sprite.draw() arcade.draw_text(str(self.world.score), self.world.panda.x + (SCREEN_WIDTH // 2) - 890, self.height - 30, arcade.color.BLACK, 20) self.draw_skulls(self.world.skulls)
def on_draw(self): ar.start_render() texture = ar.load_texture('image\Game_menu.png') ar.draw_texture_rectangle(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, SCREEN_WIDTH, SCREEN_HEIGHT, texture) # текст меню ar.draw_text('Нажми на ENTER чтобы начать игру', SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 + 130, ar.color.BLACK, 16, anchor_x="center") ar.draw_text('Нажми на Q чтобы выйти из игры', SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 + 90, ar.color.BLACK, 18, anchor_x="center")
def draw_arrow(self, arrow, x, y): if arrow == self.gameTracker.playerBtnInfo.BTN_UP: arcade.draw_texture_rectangle(x, y, self.arrow_texture_size , self.arrow_texture_size, self.arrow_up_texture) elif arrow == self.gameTracker.playerBtnInfo.BTN_LEFT: arcade.draw_texture_rectangle(x, y, self.arrow_texture_size , self.arrow_texture_size, self.arrow_left_texture) elif arrow == self.gameTracker.playerBtnInfo.BTN_RIGHT: arcade.draw_texture_rectangle(x, y, self.arrow_texture_size , self.arrow_texture_size, self.arrow_right_texture) elif arrow == self.gameTracker.playerBtnInfo.BTN_DOWN: arcade.draw_texture_rectangle(x, y, self.arrow_texture_size , self.arrow_texture_size, self.arrow_down_texture)
def draw_title_things(): # Draw title arcade.draw_text("Ransomware and Prevention Techniques", 240, text_height, arcade.color.DARK_BLUE, 30, 0, "center", 'ARIAL', True) # Draw underline arcade.draw_line(230, underline_height, 890, underline_height, arcade.color.DARK_BLUE, 3) # Load texture_1 -- computer screen texture_1 = arcade.load_texture("textures/computer_1.png") scale = 0.055 arcade.draw_texture_rectangle(150, text_height, scale * texture_1.width, scale * texture_1.height, texture_1) # Load texture_2 -- ransomware clipart texture_2 = arcade.load_texture("textures/malware_1.png") scale = 0.16 arcade.draw_texture_rectangle(950, text_height, scale * texture_2.width, scale * texture_2.height, texture_2)
def on_draw(self): """ Render the screen. """ # This command has to happen before we start drawing arcade.start_render() # Draw all the sprites. self.player_list.draw() self.wall_list.draw() # Put the text on the screen. # Adjust the text position based on the view port so that we don't # scroll the text too. if self.game_over: arcade.draw_texture_rectangle(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, SCREEN_WIDTH, SCREEN_HEIGHT, "") pass
def on_draw(self): """ Render the screen. """ arcade.start_render() for i in range(len(scores)): for j in range(len(scores[i])): arcade.draw_texture_rectangle( 100 + j * 20, 400 - i * 40, 20, 24, arcade.load_texture("number/n_" + str(scores[i][j]) + ".png")) for i in range(len(times)): for j in range(len(times[i])): arcade.draw_texture_rectangle( 300 + j * 20, 400 - i * 40, 20, 24, arcade.load_texture("number/n_" + str(times[i][j]) + ".png"))
def on_draw(self): arcade.start_render() scale = .6 arcade.draw_texture_rectangle(540, 120, self.texture.image.width * scale, self.texture.image.height * scale, self.texture, angle=45) arcade.draw_xywh_rectangle_textured(10, 400, 64, 64, self.texture) for i in range(15): arcade.draw_scaled_texture_rectangle(i * 50 + 20, 220, scale, self.texture, angle=45, alpha=i * 15)
import arcade import os # set the text for the meme line1 = "1goodVariableName" line2 = "good_variable_name1" # set the dimensions of the window, based on the image height = 640 width = 550 arcade.open_window(height, width, "Meme Generator") arcade.set_background_color(arcade.color.WHITE) arcade.start_render() # load the image texture = arcade.load_texture("images/drake_meme.jpg") arcade.draw_texture_rectangle(texture.width//2, texture.height//2, texture.width, texture.height, texture, 0) # render the text arcade.draw_text(line1, width//2 + 100, height - height//3, arcade.color.BLACK, 12) arcade.draw_text(line2, width//2 + 100, height//2 - height//4, arcade.color.BLACK, 12) arcade.finish_render() arcade.run()
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 arcade.finish_render() # Keep the window up until someone closes it. arcade.run()