def on_draw(self): """ Render the screen. """ # This command has to happen before we start drawing arcade.start_render() # Start timing how long this takes draw_start_time = timeit.default_timer() # Draw all the sprites self.sprite_list.draw() # Draw the lines that aren't sprites for line in self.static_lines: body = line.body pv1 = body.position + line.a.rotated(body.angle) pv2 = body.position + line.b.rotated(body.angle) arcade.draw_line(pv1.x, pv1.y, pv2.x, pv2.y, arcade.color.WHITE, 2) # Display timings draw_time = timeit.default_timer() - draw_start_time arcade.draw_text("Processing time: {:.3f}".format(self.time), 20, SCREEN_HEIGHT - 20, arcade.color.BLACK, 12) arcade.draw_text("Drawing time: {:.3f}".format(draw_time), 20, SCREEN_HEIGHT - 40, arcade.color.BLACK, 12)
def animate(self, x): self.physics_engine.update() q = WINDOW_WIDTH / 4 if self.player_sprite.center_x - self.ortho_left > q * 3: self.ortho_left = self.player_sprite.center_x - q * 3 arcade.set_viewport(self.ortho_left, WINDOW_WIDTH + self.ortho_left, 0, WINDOW_HEIGHT) if self.player_sprite.center_x - self.ortho_left < q: self.ortho_left = self.player_sprite.center_x - q arcade.set_viewport(self.ortho_left, WINDOW_WIDTH + self.ortho_left, 0, WINDOW_HEIGHT) coins_hit = arcade.check_for_collision_with_list(self.player_sprite, self.coin_list) for coin in coins_hit: coin.kill() self.score += 1 arcade.draw_text("Score: {}".format(self.score), 5, 5, arcade.color.BLACK, 14)
def on_draw(self): """Render the screen""" arcade.start_render() # Text on screen text = "Press left mouse to make noise" # Render text arcade.draw_text(text, 150, 300, arcade.color.WHITE, 30)
def draw_game(self): """ Draw all the sprites, along with the score. """ # 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 on_draw(self): """ Render the screen. """ # This command has to happen before we start drawing arcade.start_render() arcade.draw_text("This is a simple template to start your game.", 10, SCREEN_HEIGHT // 2, arcade.color.BLACK, 20)
def on_draw(self): """ Render the screen. """ # This command has to happen before we start drawing arcade.start_render() self.object_list.draw() start_x = 20 start_y = 10 arcade.draw_text("Processing time: {:.3f}".format(self.time), start_x, start_y, arcade.color.BLACK, 12)
def on_draw(self): arcade.start_render() self.all_sprites_list.draw() arcade.draw_text("Score: {}".format(self.score), self.ortho_left + 0.01, 9.75, arcade.color.BLACK, 12) grid_color = (0, 0, 255, 127) for y in range(0, 801, 32): arcade.draw_line(0, y, 800, y, grid_color) for x in range(0, 801, 32): arcade.draw_line(x, 0, x, 800, grid_color)
def on_draw(self): """ Render the screen. """ # This command has to happen before we start drawing arcade.start_render() for ball in self.ball_list: arcade.draw_circle_filled(ball.x, ball.y, ball.size, ball.color) # Put the text on the screen. output = "Balls: {}".format(len(self.ball_list)) arcade.draw_text(output, 10, 20, arcade.color.WHITE, 14)
def on_draw(self): """ Render the screen. """ # This command has to happen before we start drawing arcade.start_render() # 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 on_draw(self): """ 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() # Calculate minutes minutes = int(self.total_time) // 60 # Calculate seconds by using a modulus (remainder) seconds = int(self.total_time) % 60 output = "Time: {:02d}:{:02d}".format(minutes, seconds) arcade.draw_text(output, 300, 300, arcade.color.BLACK, 30)
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() # Draw the circle arcade.draw_circle_filled(self.ball_x_position, SCREEN_HEIGHT // 2, BALL_RADIUS, arcade.color.GREEN) # Draw the text arcade.draw_text("This is a simple template to start your game.", 10, SCREEN_HEIGHT // 2, arcade.color.BLACK, 20)
def on_draw(self): """ Render the screen. """ # This command has to happen before we start drawing arcade.start_render() # Draw all the sprites. self.all_sprites_list.draw() # Put the text on the screen. # Adjust the text position based on the viewport so that we don't # scroll the text too. output = "Score: {}".format(self.score) arcade.draw_text(output, self.view_left + 10, self.view_bottom + 20, arcade.color.WHITE, 14)
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() #draw Sprites self.all_sprites_list.draw() self.rocket_sprites_list.draw() self.item_sprites_list.draw() if self.invis_activated is False: self.ball_sprite.draw() #draw Text arcade.draw_text("Computer Score: " + str(self.computer_score), 10, SCREEN_HEIGHT - 30, arcade.color.BLACK, 12) arcade.draw_text("Player Score: " + str(self.player_score), 10, 10, arcade.color.BLACK, 12)
def on_draw(self): """ Render the screen. """ # This command has to happen before we start drawing arcade.start_render() # Draw all the sprites. self.all_sprites_list.draw() # Put the text on the screen. # Adjust the text position based on the viewport so that we don't # scroll the text too. distance = self.view_left + self.player_sprite.right output = "Distance: {}".format(distance) arcade.draw_text(output, self.view_left + 10, self.view_bottom + 20, arcade.color.WHITE, 14) if self.game_over: output = "Game Over" arcade.draw_text(output, self.view_left + 200, self.view_bottom + 200, arcade.color.WHITE, 30)
def draw(self): """ Draw the balls with the instance variables we have. """ arcade.draw_circle_filled(self.x, self.y, self.radius, self.color) arcade.draw_text(str(self.id), self.x - self.radius, self.y + self.radius, self.color)
def draw_instructions(self): # Draws instructions for the game if self.level == 1: arcade.draw_text( "Eat popcorn to fill the frog's \n hunger bar! \n If you miss a popcorn your health bar goes down.", start_x=75, start_y=325, color=arcade.color.WHITE_SMOKE, font_size=12, width=0, align="center") elif self.level == 2: arcade.draw_text("Don't eat the candy, you'll lose hunger points!", start_x=125, start_y=325, color=arcade.color.WHITE_SMOKE, font_size=12, width=0, align="center") elif self.level == 3: arcade.draw_text( "The movie theatre attendant is trying to catch you! \n Dodge their hand!", start_x=125, start_y=325, color=arcade.color.WHITE_SMOKE, font_size=12, width=0, align="center") elif self.level == 4: arcade.draw_text( "They're filling up the machine! \n Jump away from the rising popcorn!\n Don't forget to keep eating falling popcorn.", start_x=125, start_y=325, color=arcade.color.WHITE_SMOKE, font_size=12, width=0, align="center") elif self.level == 5: arcade.draw_text( "They're speeding up the machine...\n Keep eating!", start_x=125, start_y=325, color=arcade.color.WHITE_SMOKE, font_size=12, width=0, align="center") elif self.level == 6: arcade.draw_text("They're trying to catch you again!", start_x=125, start_y=325, color=arcade.color.WHITE_SMOKE, font_size=12, width=0, align="center") elif self.level == 7 or self.level == 8: arcade.draw_text("Keep eating!", start_x=125, start_y=325, color=arcade.color.WHITE_SMOKE, font_size=12, width=0, align="center") elif self.level == 9: arcade.draw_text( "They won't give up... \n They're still trying to catch you!", start_x=125, start_y=325, color=arcade.color.WHITE_SMOKE, font_size=12, width=0, align="center") elif self.level == 10: arcade.draw_text( "They're filling up the machine all the way! \n Jump out of the machine to freedom!", start_x=125, start_y=250, color=arcade.color.WHITE_SMOKE, font_size=12, width=0, align="center")
TEXT_SIZE = 12 # Open the window and set the background arcade.open_window("Complex Loops - Bottom Left Triangle", 600, 400) arcade.set_background_color(arcade.color.WHITE) # Start the render process. This must be done before any drawing commands. arcade.start_render() # Loop for each row for row in range(10): # Loop for each column # Change the number of columns depending on the row we are in for column in range(10 - row): # Calculate our location x = column * COLUMN_SPACING y = row * ROW_SPACING # Draw the item arcade.draw_text("({}, {})".format(column, row), x, y, arcade.color.BLACK, TEXT_SIZE) # Finish the render. arcade.finish_render() # Keep the window up until someone closes it. arcade.run()
def draw_label(*args, **kwargs): arcade.draw_text(text, x, y, color, 14)
def draw_game(self): """ Draw all the sprites, along with the score. """ # Start timing how long this takes draw_start_time = timeit.default_timer() 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. # Draw inventory to screen... arcade.draw_lrtb_rectangle_filled( self.view_left, self.view_left + SCREEN_WIDTH - 1, self.view_bottom + TEAM_SPRITE_SIZE * 2, self.view_bottom, arcade.color.BLACK) x_position = self.view_left for item in self.player.inventory: item.bottom = self.view_bottom item.left = x_position x_position += item.width item.draw() if self.rooms[self.current_room].problem == "Attack with [spacebar]!": self.message_queue.append(self.rooms[self.current_room].problem) # enemy creation in battle room for i in range(STARTING_IMP_COUNT): enemy = arcade.Sprite("images/imp_idle.png") self.enemy_list.append(enemy) # Draw messages in queue if len(self.message_queue) > 0: center_x = SCREEN_WIDTH // 2 + self.view_left center_y = SCREEN_HEIGHT // 2 + self.view_bottom width = 400 arcade.draw_rectangle_filled(center_x, center_y, width, 200, arcade.color.BLACK) arcade.draw_rectangle_outline(center_x, center_y, width, 200, arcade.color.WHITE, 2) arcade.draw_text(self.message_queue[0], center_x, center_y + 10, arcade.color.WHITE, 14, width=width, align="center", anchor_x="center", anchor_y="center") # Draw all the sprites. self.player_list.draw() self.rooms[self.current_room].enemy_list.draw() self.rooms[self.current_room].item_list.draw() self.rooms[self.current_room].javelin_list.draw() self.draw_time = timeit.default_timer() - draw_start_time # Put the text on the screen. output = f"Score: {self.score}" arcade.draw_text(output, 10, 20, arcade.color.AMERICAN_ROSE, 14)
def draw(self): arcade.draw_text("Congrats on the Dub!", 225, 300, arcade.color.WHITE, 30)
def on_draw(self): arcade.start_render() self.logo_list.draw() score = self.score score = str(score) arcade.draw_text("Your score:" + score, 10, 20, arcade.color.WHITE, 14)
def player1_healthbar(health): arcade.draw_xywh_rectangle_filled(0, HEIGHT, 100, -20, arcade.color.RED), arcade.draw_xywh_rectangle_filled(0, HEIGHT, p1current_health, -20, arcade.color.GREEN), arcade.draw_text('player2', 0, HEIGHT - 35, arcade.color.BLACK)
def player2_healthbar(health): arcade.draw_xywh_rectangle_filled(WIDTH, HEIGHT, -100, -20, arcade.color.RED), arcade.draw_xywh_rectangle_filled(WIDTH, HEIGHT, p2current_health, -20, arcade.color.GREEN), arcade.draw_text('player1', WIDTH - 60, HEIGHT - 35, arcade.color.BLACK)
player_1 = arcade.draw_xywh_rectangle_filled(p1_x,p1_y,20,50,arcade.color.BLUE),\ arcade.draw_circle_filled(p1_x + 10,p1_y,20,arcade.color.BLACK),\ arcade.draw_xywh_rectangle_filled(p1_x+20,p1_y+30,10,5,arcade.color.BLACK) player1_halthbar = arcade.draw_xywh_rectangle_filled(0, HEIGHT, 50, -20, arcade.color.GREEN) menue = arcade.draw_text('unreal tournement 2019', WIDTH / 2, HEIGHT / 2, arcade.color.ORANGE, 30) player2_halthbar = arcade.draw_xywh_rectangle_filled(WIDTH, HEIGHT, -50, -20, arcade.color.GREEN) player_2 = arcade.draw_xywh_rectangle_filled(p2_x,p2_y,20,50,arcade.color.RED),\ arcade.draw_circle_filled(p2_x + 10,p2_y+ 50,20,arcade.color.BLACK),\ arcade.draw_xywh_rectangle_filled(p2_x,p2_y+30,10,5,arcade.color.BLACK) instructions = arcade.draw_text( 'for player1 use WASD keys to move. for player 2 use the arrow keys', WIDTH / 2, HEIGHT / 2, arcade.color.BLACK, 30) def update(delta_time):
def on_draw(): global bullet_list1 global bullet_list2 global p1_x global p1_y global p2_x global p2_y global RCTRL_pressed arcade.start_render() if current_screen == 'Game': player1_healthbar(player1_halthbar) arcade.draw_text('current mag:{}'.format(p1_mag // 1), 1235, 650, arcade.color.BLACK) player2_healthbar(player2_halthbar) arcade.draw_text('current mag:{}'.format(p2_mag // 1), 0, 650, arcade.color.BLACK) if current_screen == 'Instructions': instruction_screen(instructions) arcade.set_background_color(arcade.color.WHITE) draw_player1(player_1) draw_player2(player_2) for bullet1 in bullet_list1: arcade.draw_xywh_rectangle_filled(bullet1[0], bullet1[1] + 20, 40, 5, arcade.color.RED), for bullet2 in bullet_list2: arcade.draw_xywh_rectangle_filled(bullet2[0] - 10, bullet2[1] + 20, 40, 5, arcade.color.BLUE) if current_screen == 'Game': if player1_alive == True: draw_player1(player_1) if player2_alive == True: draw_player2(player_2) arcade.set_background_color(arcade.color.WHITE) if current_screen == 'menue': menue_screen(menue) arcade.set_background_color(arcade.color.BLACK) p1_x = 100 p1_y = 100 p2_x = 1260 p2_y = 500 if current_screen == 'Game': if player1_alive == True: for bullet1 in bullet_list1: arcade.draw_xywh_rectangle_filled(bullet1[0], bullet1[1] + 20, 40, 5, arcade.color.RED) if player2_alive == True: for bullet2 in bullet_list2: arcade.draw_xywh_rectangle_filled(bullet2[0] - 10, bullet2[1] + 20, 40, 5, arcade.color.BLUE) if current_screen == 'end': if player2_alive == False: arcade.draw_xywh_rectangle_filled(0, 0, WIDTH, HEIGHT, arcade.color.BLACK) arcade.draw_text('Blue wins press Escape to go to menu', WIDTH / 2 - 100 - 250, HEIGHT / 2, arcade.color.RED, 30) if player1_alive == False: arcade.draw_xywh_rectangle_filled(0, 0, WIDTH, HEIGHT, arcade.color.BLACK) arcade.draw_text('Red wins press Escape to go to menu', WIDTH / 2 - 100 - 250, HEIGHT / 2, arcade.color.RED, 30)
def on_draw(self): arcade.start_render() arcade.draw_text("Instructions Screen", SCREEN_WIDTH / 2, SCREEN_HEIGHT - 100, arcade.color.WHITE_SMOKE, font_size=50, anchor_x="center") arcade.draw_text("Click to advance", SCREEN_WIDTH / 2, SCREEN_HEIGHT - 180, arcade.color.RED, font_size=10, anchor_x="center") arcade.draw_text("First turn is of Human", SCREEN_WIDTH / 2, SCREEN_HEIGHT - 240, arcade.color.WHITE_SMOKE, font_size=16, anchor_x="center") arcade.draw_text("In Case of 7 Blocked Turns by both ", SCREEN_WIDTH / 2, SCREEN_HEIGHT - 300, arcade.color.WHITE_SMOKE, font_size=15, anchor_x="center") arcade.draw_text("Human and Computer,Game Result", SCREEN_WIDTH / 2, SCREEN_HEIGHT - 360, arcade.color.WHITE_SMOKE, font_size=15, anchor_x="center") arcade.draw_text("Will be decided on current Grid Position", SCREEN_WIDTH / 2, SCREEN_HEIGHT - 400, arcade.color.WHITE_SMOKE, font_size=15, anchor_x="center") arcade.draw_text("20 -> Bot Slime , 10 -> Human Slime", SCREEN_WIDTH / 2, SCREEN_HEIGHT - 450, arcade.color.WHITE_SMOKE, font_size=15, anchor_x="center") arcade.draw_text("Movement : UP DOWN LEFT RIGHT", SCREEN_WIDTH / 2, SCREEN_HEIGHT - 480, arcade.color.WHITE_SMOKE, font_size=15, anchor_x="center") snail = arcade.Sprite("images/snailone.png") snail.scale = 0.15 snail.center_x = 250 snail.center_y = 100 snail.draw() snail = arcade.Sprite("images/snailtwo.png") snail.scale = 0.15 snail.center_x = 350 snail.center_y = 100 snail.draw()
arcade.csscolor.DARK_GREEN) # Sun arcade.draw_circle_filled(500, 550, 40, arcade.color.YELLOW) # Rays to x and y axis arcade.draw_line(500, 550, 400, 550, arcade.color.YELLOW, 3) arcade.draw_line(500, 550, 600, 550, arcade.color.YELLOW, 3) arcade.draw_line(500, 550, 500, 450, arcade.color.YELLOW, 3) arcade.draw_line(500, 550, 500, 650, arcade.color.YELLOW, 3) # Diagonal Rays arcade.draw_line(500, 550, 550, 600, arcade.color.YELLOW, 3) arcade.draw_line(500, 550, 550, 500, arcade.color.YELLOW, 3) arcade.draw_line(500, 550, 450, 600, arcade.color.YELLOW, 3) arcade.draw_line(500, 550, 450, 500, arcade.color.YELLOW, 3) # Text arcade.draw_text("Pasodink medi!", 210, 230, arcade.color.BLACK, 24) # Code with parameter names """ arcade.draw_arc_outline(center_x=300, center_y=340, width=60, height=100, color=arcade.csscolor.BLACK, start_angle=0, end_angle=180, border_width=3, tilt_angle=45) """ arcade.finish_render()
def on_draw(self): arcade.start_render() self.user.draw() self.virus_list.draw() self.cure_list.draw() self.powerup_list.draw() self.wall_list.draw() #tracks lives and cures left cure_count = (f"Cures Collected: {self.score}") arcade.draw_text(cure_count, (WIDTH - 260), (HEIGHT - 40), arcade.color.WHITE, 20) life_count = (f"Lives: {self.lives}") arcade.draw_text(life_count, 30, (HEIGHT - 40), arcade.color.WHITE, 20) if len(self.cure_list) == 0: win_text = "You have received the cure! " skip_screen = "PRESS SPACE TO MOVE ON" arcade.draw_text(win_text, (WIDTH / 3 - 50), (HEIGHT - 200), arcade.color.WHITE, 25) arcade.draw_text(skip_screen, (WIDTH / 3 - 50), (HEIGHT - 300), arcade.color.WHITE, 25) if self.lives <= 0: lose_text = "You failed in curing the viruses." skip_screen = "PRESS SPACE TO MOVE ON" arcade.draw_text(lose_text, (WIDTH / 3 - 50), (HEIGHT - 200), arcade.color.WHITE, 25) arcade.draw_text(skip_screen, (WIDTH / 3 - 50), (HEIGHT - 300), arcade.color.WHITE, 25) #timer minutes = int(self.total_time) // 60 seconds = int(self.total_time) % 60 output = f"Time: {minutes:02d}:{seconds:02d}" arcade.draw_text(output, (WIDTH - 750), (HEIGHT - 40), arcade.color.WHITE, 30)
def draw(self): super().draw() draw_text(self.text, self.left, self.bottom + self.size // 2, self.text_color, self.size)
def on_draw(): arcade.start_render() # texture = arcade.load_texture("Back.jpg") # arcade.draw_texture_rectangle(300, 300, texture.width*1.5, texture.height*1.5, texture, 0) # Draw in here... arcade.draw_text("No Cyber-Bullying", 120, 450, arcade.color.BLACK, font_size=35) arcade.draw_circle_filled(600, 0, 280, arcade.color.DARK_BLUE) texture = arcade.load_texture("Computer.png") scale = 0.3 arcade.draw_texture_rectangle(500, 120, scale * texture.width, scale * texture.height, texture, 0) arcade.draw_text("If you do not want", 430, 180, arcade.color.CADET, font_size=15) arcade.draw_text("to say it then why", 430, 155, arcade.color.CADET, font_size=15) arcade.draw_text("type it ?", 430, 130, arcade.color.CADET, font_size=15) texture = arcade.load_texture("Sign.jpg") arcade.draw_texture_rectangle(64, 555, scale * texture.width, scale * texture.height, texture, 0) texture = arcade.load_texture("Phone.png") arcade.draw_texture_rectangle(50, 100, scale * texture.width, scale * texture.height, texture, 0) arcade.draw_text("Use your", 12, 140, arcade.color.BOLE, font_size=11) arcade.draw_text("phone wisely", 12, 120, arcade.color.BOLE, font_size=11) arcade.draw_text("or YOU WILL", 12, 100, arcade.color.BOLE, font_size=11) arcade.draw_text("REGRET IT", 12, 70, arcade.color.BOLE, font_size=15) arcade.draw_rectangle_outline(300, 300, 595, 595, arcade.color.BLACK, border_width=5) texture = arcade.load_texture("Mean.jpg") arcade.draw_texture_rectangle(530, 500, 0.6 * texture.width, 0.6 * texture.height, texture) arcade.draw_xywh_rectangle_filled(my_button[0], my_button[1], my_button[2], my_button[3], arcade.color.BISQUE) arcade.draw_text("Click to learn ", 505, 380, arcade.color.BISTRE, font_size=13) arcade.draw_text("more about", 505, 360, arcade.color.BISTRE, font_size=13) arcade.draw_text("how bullying", 505, 340, arcade.color.BISTRE, font_size=13) arcade.draw_text("affects others", 505, 320, arcade.color.BISTRE, font_size=13) texture = arcade.load_texture("NO.jpg") arcade.draw_texture_rectangle(60, 420, 0.6 * texture.width, 0.6 * texture.height, texture) texture = arcade.load_texture("Words.jpg") arcade.draw_texture_rectangle(60, 275, 0.6 * texture.width, 0.6 * texture.height, texture) texture = arcade.load_texture("Cops.png") arcade.draw_texture_rectangle(center_x, center_y, 0.08 * texture.width, 0.08 * texture.height, texture, 0) arcade.draw_text("If you bully", center_x - 30, center_y - 65, arcade.color.BLACK) arcade.draw_text("him I will", center_x - 30, center_y - 80, arcade.color.BLACK) arcade.draw_text("Bully you !!!", center_x - 30, center_y - 95, arcade.color.BLACK)
def drawing(self): arcade.draw_text("You're Pretty Bad at This!", 200, 300, arcade.color.WHITE, 30)
def on_draw(self): """ Render the screen. """ # This command has to happen before we start drawing arcade.start_render() for ball in self.ball_list: myTuple = compute_point_image(ball.x, ball.y, self.my_matrix) newX = myTuple[0] newY = myTuple[1] #newX,newY,newRadius = ball.compute_image() #newX,newY = self.get_point_image(ball.x,ball.y) arcade.draw_circle_filled(newX, newY, ball.radius, ball.color) # Put the text on the screen. output = "Balls: {}".format(len(self.ball_list)) arcade.draw_text(output, 10, 20, arcade.color.WHITE, 14) output = "Mouse X Pos: {}".format(self.mouse_x) arcade.draw_text(output, 10, 40, arcade.color.WHITE, 14) output = "Mouse Y Pos: {}".format(self.mouse_y) arcade.draw_text(output, 10, 60, arcade.color.WHITE, 14) output = "Mouse dx: {}".format(self.mouse_dx) arcade.draw_text(output, 10, 80, arcade.color.WHITE, 14) output = "Mouse dy: {}".format(self.mouse_dy) arcade.draw_text(output, 10, 100, arcade.color.WHITE, 14) output = "my_matrix: \n{}".format(np.matrix((self.my_matrix))) arcade.draw_text(output, 10, 200, arcade.color.WHITE, 14) output = "ZoomInPercentage: {}".format(self.ZoomInPercentage) arcade.draw_text(output, 10, 220, arcade.color.WHITE, 14) output = "mouse_scroll_x: {}".format(self.mouse_scroll_x) arcade.draw_text(output, 10, 240, arcade.color.WHITE, 14) output = "mouse_scroll_y: {}".format(self.mouse_scroll_y) arcade.draw_text(output, 10, 260, arcade.color.WHITE, 14) output = "ZoomPointX: {}".format(self.ZoomPointX) arcade.draw_text(output, 10, 280, arcade.color.WHITE, 14) output = "ZoomPointY: {}".format(self.ZoomPointY) arcade.draw_text(output, 10, 300, arcade.color.WHITE, 14)
def draw_inventory(engine, selected_item, viewport): """インベントリを描画する""" player = engine.player if selected_item == 99: player.equipment.equip_update() engine.flower_light() engine.game_state = GAME_STATE.NORMAL viewport_left = viewport[0] viewport_right = viewport[1] viewport_bottom = viewport[2] viewport_top = viewport[3] # back_panel_left = viewport_left + SCREEN_WIDTH // 5 # 背景パネルの左端 back_panel_left = viewport_left + (GRID_SIZE * 3) # 背景パネルの左端 back_panel_right = back_panel_left + GRID_SIZE * 7 # 背景パネルの左端 back_panel_bottom_left = viewport_bottom + (GRID_SIZE * 6) # 背景パネルの下端 back_panel_top_left = viewport_top - (GRID_SIZE * 2) # 背景パネルの下端 panel_width = MAIN_PANEL_X - (GRID_SIZE * 5) #SCREEN_WIDTH//2.3 # パネルの幅 panel_height = MAIN_PANEL_Y - (GRID_SIZE * 6) # パネルの高さ # 背景パネル arcade.draw_xywh_rectangle_filled( bottom_left_x=back_panel_left, bottom_left_y=back_panel_bottom_left - GRID_SIZE, width=panel_width, height=panel_height, color=[5, 5, 5, 180], ) arcade.draw_text( text="Inventory".upper(), start_x=back_panel_left + 20, start_y=viewport_top - GRID_SIZE - 9, color=arcade.color.DAFFODIL, font_size=20, font_name=UI_FONT2, # anchor_y=" ) arcade.draw_lrwh_rectangle_textured(bottom_left_x=back_panel_left, bottom_left_y=back_panel_bottom_left - GRID_SIZE, width=panel_width, height=panel_height, texture=IMAGE_ID["inventory_main"]) y = GRID_SIZE # itemtextの改行スペース item_font_size = 17 capacity = player.inventory.capacity font_color = arcade.color.WHITE equip_this = "" # キャパシティ数をループし、インベントリのアイテム名とアウトラインを描画する slot_item = [i for i in player.equipment.flower_slot] for i, item in enumerate(range(capacity)): x = 0 if i >= 9: x = GRID_SIZE * 7 if i == 9: y = GRID_SIZE if player.inventory.item_bag[item]: cur_item = player.inventory.item_bag[item] if cur_item in slot_item: equip_this = "[E]" # そのitemが装備中ならEマークを付ける font_color = arcade.color.YELLOW_ROSE else: equip_this = "" font_color = arcade.color.BLIZZARD_BLUE else: cur_item = "" equip_this = "" font_color = arcade.color.YALE_BLUE if item == selected_item: # カーソル表示 arcade.draw_lrwh_rectangle_textured( bottom_left_x=back_panel_left + x, bottom_left_y=back_panel_top_left - GRID_SIZE + y, width=64 * 7, height=64, texture=IMAGE_ID["inventory_cursor"]) cy = 13 + item_font_size if cur_item: font_color2 = arcade.color.PINK_SHERBET # itemの説明文をパネル下部に表示 # arcade.draw_lrtb_rectangle_filled( # left=back_panel_left, # right=back_panel_right+GRID_SIZE*7, # top=back_panel_bottom_left-GRID_SIZE-2, # bottom=back_panel_bottom_left-(GRID_SIZE*6), # color=[100,100,100,250], # ) left = back_panel_left + 15 arcade.draw_text(text=f"LEVEL {cur_item.level}", start_x=left, start_y=back_panel_bottom_left - GRID_SIZE - cy, color=font_color2, font_size=item_font_size, font_name=UI_FONT, anchor_y="top") arcade.draw_text(text=f"HP {cur_item.hp}/{cur_item.max_hp}", start_x=left, start_y=back_panel_bottom_left - GRID_SIZE - cy * 2, color=font_color2, font_size=item_font_size, font_name=UI_FONT, anchor_y="top") arcade.draw_text(text=f"EXP {cur_item.current_xp}", start_x=left, start_y=back_panel_bottom_left - GRID_SIZE - cy * 3, color=font_color2, font_size=item_font_size, font_name=UI_FONT, anchor_y="top") arcade.draw_texture_rectangle(center_x=left + 25, center_y=back_panel_bottom_left - GRID_SIZE - cy * 7, width=40, height=40, texture=IMAGE_ID["black_board"]) arcade.draw_texture_rectangle( center_x=left + 25, center_y=back_panel_bottom_left - GRID_SIZE - cy * 7, width=40, height=40, texture=cur_item.flower_skill.icon, ) arcade.draw_text(text=f"SKILL", start_x=left, start_y=back_panel_bottom_left - GRID_SIZE - cy * 5, color=font_color2, font_size=item_font_size, font_name=UI_FONT, anchor_y="top") # arcade.draw_lrwh_rectangle_textured( # bottom_left_x=back_panel_left+15, # bottom_left_y=back_panel_bottom_left-GRID_SIZE-cy*8, # width=40, # height=40, # texture=cur_item.flower_skill.icon # ) # arcade.draw_texture_rectangle(viewport_right/2, viewport_bottom*2, GRID_SIZE*6, GRID_SIZE*5, ip2) arcade.draw_lrwh_rectangle_textured( bottom_left_x=back_panel_left, bottom_left_y=back_panel_bottom_left - (GRID_SIZE * 5 + 20), width=GRID_SIZE * 14, height=GRID_SIZE * 4, texture=IMAGE_ID["inventory_sub"]) arcade.draw_text(text=f"States Bonus", start_x=back_panel_left + GRID_SIZE * 2, start_y=back_panel_bottom_left - GRID_SIZE - cy, color=arcade.color.GREEN_YELLOW, font_size=item_font_size - 2, font_name=UI_FONT, anchor_y="top") ky = GRID_SIZE + item_font_size for key, val in cur_item.states_bonus.items(): if val: arcade.draw_text( text=f"{key: <13} + {val}".replace("_", " ").title(), start_x=back_panel_left + GRID_SIZE * 2, start_y=back_panel_bottom_left - GRID_SIZE - ky, color=font_color, font_size=item_font_size - 4, font_name=UI_FONT, # anchor_y="top" ) ky += 10 + item_font_size arcade.draw_text(text=f"Resist Bonus", start_x=back_panel_left + GRID_SIZE * 5, start_y=back_panel_bottom_left - GRID_SIZE - cy, color=arcade.color.ORIOLES_ORANGE, font_size=item_font_size - 2, font_name=UI_FONT, anchor_y="top") ky = GRID_SIZE + item_font_size for key, val in cur_item.resist_bonus.items(): if val: arcade.draw_text( text=f"{key: <13} + {val}".replace("_", " ").title(), start_x=back_panel_left + GRID_SIZE * 5, start_y=back_panel_bottom_left - GRID_SIZE - ky, color=font_color, font_size=item_font_size - 4, font_name=UI_FONT, # anchor_y="top" ) ky += 10 + item_font_size arcade.draw_text(text=f"Explanatory Text", start_x=back_panel_left + GRID_SIZE * 8, start_y=back_panel_bottom_left - GRID_SIZE - cy, color=arcade.color.WHITE_SMOKE, font_size=item_font_size - 3, font_name=UI_FONT, anchor_y="top") arcade.draw_text( text=f"{cur_item.explanatory_text}", start_x=back_panel_left + GRID_SIZE * 8, start_y=back_panel_bottom_left - GRID_SIZE * 3 - 20, color=font_color, font_size=item_font_size - 6, font_name=UI_FONT, # anchor_y="top" ) # itemのアイコンを描画 if cur_item: arcade.draw_texture_rectangle(center_x=back_panel_left + 60 + x, center_y=back_panel_top_left - ((GRID_SIZE / 2)) + y, width=40, height=40, texture=IMAGE_ID["black_board"]) arcade.draw_texture_rectangle( center_x=back_panel_left + 60 + x, center_y=back_panel_top_left - ((GRID_SIZE / 2)) + y, width=40, height=40, texture=cur_item.icon, ) # 装備出来るアイテムならitemの左に(equip key: E)と表示 if cur_item and Tag.equip in cur_item.tag: arcade.draw_text(text="(equip key: E)", start_x=back_panel_right - (GRID_SIZE), start_y=back_panel_top_left - (GRID_SIZE / 2) + y, color=font_color, font_size=item_font_size - 7, font_name=UI_FONT2, anchor_y="center", anchor_x="center") # 使用可能アイテムならitemの左に(use key: U)と表示 elif cur_item and Tag.used in cur_item.tag: arcade.draw_text(text="(use key: U)", start_x=back_panel_right - (GRID_SIZE), start_y=back_panel_top_left - (GRID_SIZE / 2) + y, color=font_color, font_size=item_font_size - 7, font_name=UI_FONT2, anchor_y="center", anchor_x="center") # itemの説明文をパネル下部に表示 # if hasattr(cur_item, "explanatory_text"): # arcade.draw_lrtb_rectangle_filled( # left=back_panel_left, # right=back_panel_right+GRID_SIZE*7, # top=back_panel_bottom_left-GRID_SIZE-2, # bottom=back_panel_bottom_left-(GRID_SIZE*6), # color=[100,100,200,250], # ) # if item == selected_item: # arcade.draw_text( # text=f"States Bonus", # start_x=back_panel_left+GRID_SIZE*3, # start_y=back_panel_bottom_left-GRID_SIZE-12, # color=font_color, # font_size=item_font_size-5, # font_name=UI_FONT, # anchor_y="top" # ) # ky = GRID_SIZE # for key, val in cur_item.states_bonus.items(): # if val: # arcade.draw_text( # text=f"{key} : {val}", # start_x=back_panel_left+GRID_SIZE*3, # start_y=back_panel_bottom_left-GRID_SIZE-ky, # color=font_color, # font_size=item_font_size-5, # font_name=UI_FONT, # # anchor_y="top" # ) # ky += 22 # item名の表示 if cur_item: # インベントリのアイテムNone時にエラー防止措置 cur_item = cur_item.name item_text = f" {cur_item}".replace("_", " ").title() arcade.draw_text( text=f"{item+1: >2} {equip_this: >52} ", start_x=back_panel_left + 10 + x, start_y=back_panel_top_left - (GRID_SIZE / 2) + y, #bottom_left + panel_height - 120 + y, color=font_color, font_size=item_font_size - 2, font_name=UI_FONT2, anchor_y="center", anchor_x="left") arcade.draw_text( text=item_text, start_x=back_panel_left + GRID_SIZE + 25 + x, start_y=back_panel_top_left - (GRID_SIZE / 2) + y, #bottom_left + panel_height - 120 + y, color=font_color, font_size=item_font_size - 2, font_name=UI_FONT2, anchor_y="center") y -= GRID_SIZE
def intro(self): """displays life points""" output = f"Player Life points: " + str(self.player.life) + f"\nPlayer Strength points:" + str( self.player.strength) + f"\nKill Score:" + str(self.kill_score) arcade.draw_lrtb_rectangle_filled(0, 170, 600, 550, arcade.color.WARM_BLACK) arcade.draw_text(output, 0, 555, arcade.color.WHITE_SMOKE, 13)
def on_draw(self): arcade.start_render() # arcade.draw_lrwh_rectangle_textured(0 , 0 , 1100 , 800 , background) if self.state == "GameMenu": arcade.draw_lrwh_rectangle_textured(0, 0, 1100, 800, background) arcade.draw_text("Snails Game", 550, 400, arcade.color.WHITE, font_size=50, anchor_x="center") arcade.draw_text("Press any key ...", 550, 300, arcade.color.WHITE, font_size=30, anchor_x="center") elif self.state == "GameInstructions": arcade.set_background_color(arcade.color.BLACK) arcade.draw_text(" Game Instructions ", 260, 700, arcade.color.WHITE, font_size=60) arcade.draw_text( "1- Try to capture maximum number of boxes to win the game", 120, 600, arcade.color.WHITE, font_size=20) arcade.draw_text( "2- Players can move over their own splashes but will reach the end point", 120, 550, arcade.color.WHITE, font_size=20) arcade.draw_text( "3- Player who scores more than 49 will be winner", 120, 500, arcade.color.WHITE, font_size=20) arcade.draw_text( "4- Player cannot move over the opponent's sprite or splash", 120, 450, arcade.color.WHITE, font_size=20) arcade.draw_text("5- It Did So that Will cost a move ", 120, 400, arcade.color.WHITE, font_size=20) arcade.draw_text("6- Yellow is the Human player and Red is Bot", 120, 350, arcade.color.WHITE, font_size=20) arcade.draw_text("7- Press 'Esc' Key to exit the Game", 120, 300, arcade.color.WHITE, font_size=20) arcade.draw_line(270, 680, 850, 680, arcade.color.WHITE, 4) arcade.draw_text("Press Space-bar to start ...", 530, 50, arcade.color.WHITE, font_size=40) elif self.state == "GameOn": arcade.draw_lrwh_rectangle_textured(0, 0, 1100, 800, background) heading1 = f" Score of Player 1" heading2 = f" Score of BOT" score1 = f"{self.count1}" score2 = f"{self.count2}" arcade.draw_text(heading1, 820, 700, arcade.color.WHITE, font_size=20, anchor_y="center") arcade.draw_text(heading2, 820, 600, arcade.color.WHITE, font_size=20, anchor_y="center") arcade.draw_text(score1, 830, 650, arcade.color.WHITE, font_size=40, anchor_y="center") arcade.draw_text(score2, 830, 550, arcade.color.WHITE, font_size=40, anchor_y="center") turn = f"Turn : Player {self.turn}" arcade.draw_text(turn, 830, 100, arcade.color.WHITE, font_size=30, anchor_y='center') for i in range(11): arcade.draw_line(0, i * 80, 800, i * 80, arcade.color.WHITE, 3) arcade.draw_line(i * 80, 0, i * 80, 800, arcade.color.WHITE, 3) for row in range(len(self.board)): for col in range(len(self.board)): if self.board[row][col] == 1: arcade.draw_lrwh_rectangle_textured( (col * 80) + 10, 720 - (80 * row) + 10, 65, 65, human1) elif self.board[row][col] == 2: arcade.draw_lrwh_rectangle_textured( (col * 80) + 10, 720 - (80 * row) + 10, 65, 65, human2) elif self.board[row][col] == 11: arcade.draw_lrwh_rectangle_textured( (col * 80) + 10, 720 - (80 * row) + 10, 65, 65, human1splash) elif self.board[row][col] == 22: arcade.draw_lrwh_rectangle_textured( (col * 80) + 10, 720 - (80 * row) + 10, 65, 65, human2splash) elif self.state == "GameOver": arcade.draw_lrwh_rectangle_textured(0, 0, 1100, 800, background) if self.win == "Player_1": arcade.draw_text("Player 1 Wins!", 550, 400, arcade.color.WHITE, font_size=100, anchor_x="center") arcade.draw_text("Click to continue", 550, 250, arcade.color.WHITE, font_size=50, anchor_x="center") if self.win == "Player_2": arcade.draw_text("BOT Wins!", 550, 400, arcade.color.WHITE, font_size=100, anchor_x="center") arcade.draw_text("Click to continue", 550, 250, arcade.color.WHITE, font_size=50, anchor_x="center") if self.win == "draw": arcade.draw_text("It's a draw..", 550, 400, arcade.color.WHITE, font_size=50, anchor_x="center") arcade.draw_text("Click to continue", 550, 250, arcade.color.WHITE, font_size=20, anchor_x="center")
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() # start_x and start_y make the start point for the text. We draw a dot to make it easy too see # the text in relation to its start x and y. start_x = 50 start_y = 450 arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5) arcade.draw_text("Simple line of text in 12 point", start_x, start_y, arcade.color.BLACK, 12) start_x = 50 start_y = 400 arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5) arcade.draw_text("Text anchored 'top' and 'left'.", start_x, start_y, arcade.color.BLACK, 12, anchor_x="left", anchor_y="top") start_y = 350 arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5) arcade.draw_text("14 point multi\nline\ntext", start_x, start_y, arcade.color.BLACK, 14, anchor_y="top") start_y = 450 start_x = 300 arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5) arcade.draw_text("Set of text\nthat\nis centered.", start_x, start_y, arcade.color.BLACK, 14, width=200, align="center", anchor_y="top") start_y = 250 start_x = 300 arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5) arcade.draw_text("Text centered on\na point", start_x, start_y, arcade.color.BLACK, 14, width=200, align="center", anchor_x="center", anchor_y="center") start_y = 150 start_x = 300 arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5) arcade.draw_text("Text rotated on\na point", start_x, start_y, arcade.color.BLACK, 14, width=200, align="center", anchor_x="center", anchor_y="center", rotation=self.text_angle) start_y = 150 start_x = 20 arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5) arcade.draw_text("Sidewarys text", start_x, start_y, arcade.color.BLACK, 14, width=200, 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("Time elapsed: {:5.1f}".format(self.time_elapsed), start_x, start_y, arcade.color.BLACK, 14)
def draw_game(self): """ Render the screen. """ # Start timing how long this takes draw_start_time = timeit.default_timer() # 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() # Draw the sprites self.current_level.wall_list.draw() self.current_level.stair_list.draw() self.current_level.creature_list.draw() self.current_level.objects_list.draw() self.current_level.missile_list.draw() self.player_list.draw() # Draw info on the screen sprite_count = len(self.current_level.wall_list) output = f"Sprite Count: {sprite_count}" arcade.draw_text(output, self.view_left + 20, WINDOW_HEIGHT - 20 + self.view_bottom, arcade.color.WHITE, 16) output = f"Drawing time: {self.draw_time:.3f}" arcade.draw_text(output, self.view_left + 20, WINDOW_HEIGHT - 40 + self.view_bottom, arcade.color.WHITE, 16) output = f"Processing time: {self.processing_time:.3f}" arcade.draw_text(output, self.view_left + 20, WINDOW_HEIGHT - 60 + self.view_bottom, arcade.color.WHITE, 16) # Draw inventory arcade.draw_lrtb_rectangle_filled( self.view_left, self.view_left + WINDOW_WIDTH - 1, self.view_bottom + PLAYER_SPRITE_SIZE * 2, self.view_bottom, arcade.color.BLACK) x_position = self.view_left for item in self.player_sprite.inventory: item.bottom = self.view_bottom item.left = x_position x_position += item.width item.draw() # Draw messages if len(self.message_queue) > 0: center_x = WINDOW_WIDTH // 2 + self.view_left center_y = WINDOW_HEIGHT // 2 + self.view_bottom width = 400 arcade.draw_rectangle_filled(center_x, center_y, width, 200, arcade.color.BLACK) arcade.draw_rectangle_outline(center_x, center_y, width, 200, arcade.color.WHITE, 2) arcade.draw_text(self.message_queue[0], center_x, center_y + 10, arcade.color.WHITE, 14, width=width, align="center", anchor_x="center", anchor_y="center") self.draw_time = timeit.default_timer() - draw_start_time
def on_draw(self): arcade.start_render() # renderar inn leikin if self.flag: #intro skjárinn arcade.set_background_color(arcade.color.RED) arcade.draw_text( " Lárus Ármann Kjartansson\n Náðu fimm peningum til að vinna leikin \n Ýttu á Q til að hefja leik", 10, 300, arcade.color.WHITE, 24) arcade.draw_text("Lárus Ármann ", self.view_left + 10, self.view_bottom + 10, arcade.color.CHERRY, 14) #setur nafnið mitt í allar senurnar elif self.score >= 5 and self.flag == False: #endaskjárinn arcade.set_background_color(arcade.color.BUBBLES) arcade.draw_text("Leik lokið ", self.view_left + 200, self.view_bottom + 300, arcade.color.CHERRY, 44) arcade.draw_text("Lárus Ármann ", self.view_left + 10, self.view_bottom + 10, arcade.color.CHERRY, 14) #setur nafnið mitt í allar senurnar else: #aðal leikurinn arcade.set_background_color(arcade.color.AMAZON) self.wall_list.draw() self.player_list.draw() arcade.draw_text(f"stig: {self.score}", self.player_sprite.center_x - 15, self.player_sprite.center_y + 30, arcade.color.WHITE, 14) arcade.draw_text("Lárus Ármann ", self.view_left + 10, self.view_bottom + 10, arcade.color.CHERRY, 14) #setur nafnið mitt í allar senurnar self.coin_list.draw()
# Also, rotate it 45 degrees. arcade.draw_rectangle_filled(200, 520, 45, 25, arcade.color.BLUSH, 45) # Draw a point at (50, 580) that is 5 pixels large arcade.draw_point(50, 580, arcade.color.RED, 5) # Draw a line # Start point of (75, 590) # End point of (95, 570) arcade.draw_line(75, 590, 95, 570, arcade.color.BLACK, 2) # Draw a circle outline centered at (140, 580) with a radius of 18 and a line # width of 3. arcade.draw_circle_outline(140, 580, 18, arcade.color.WISTERIA, 3) # Draw a circle centered at (190, 580) with a radius of 18 arcade.draw_circle_filled(190, 580, 18, arcade.color.WISTERIA) # Draw an ellipse. Center it at (240, 580) with a width of 30 and # height of 15. arcade.draw_ellipse_filled(240, 580, 30, 15, arcade.color.AMBER) # Draw text starting at (10, 450) with a size of 20 points. arcade.draw_text("Simpson College", 10, 450, arcade.color.BRICK_RED, 20) # Finish drawing arcade.finish_render() # Keep the window up until someone closes it. arcade.run()
def on_draw(self): """ Initial screen view. :post: The grid and text are now on the screen """ arcade.start_render() letters = ["A", "B", "C", "D", "E", "F", "G", "H"] numbers = ["1", "2", "3", "4", "5", "6", "7", "8"] numbers.reverse() for i in range(8): arcade.draw_text(letters[i], (i * WIDTH) + 70, SCREEN_WIDTH - 20, arcade.color.WHITE) arcade.draw_text(numbers[i], OFFSET_AXIS_LABEL / 2, (i * HEIGHT) + 70, arcade.color.WHITE) self.shape_list.draw() arcade.draw_text("Press SPACE to rotate, ENTER to lock in the ship", SCREEN_WIDTH / 1.9, 730, arcade.color.WHITE, 28, anchor_x="center") if self.length_of_ship == 0: dummy_view = DummyView() DummyView.players.append(self.player) self.window.show_view(dummy_view) arcade.draw_text("Ship", 750, 725, arcade.color.WHITE, 15, anchor_x="center") arcade.draw_text("Orientation:", 750, 700, arcade.color.WHITE, 15, anchor_x="center") if self.direction == Direction.RIGHT: arcade.draw_text("Horizontal", 750, 675, arcade.color.WHITE, 15, anchor_x="center") else: arcade.draw_text("Vertical", 750, 675, arcade.color.WHITE, 15, anchor_x="center")
def on_draw(self): arcade.start_render() arcade.draw_text("Fiendship", WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2 + 100, arcade.color.PINK_LACE, font_size=50, anchor_x="center") arcade.draw_text("Press a key to begin", WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2 + 50, arcade.color.PINK_LACE, font_size=30, anchor_x="center") arcade.draw_text("How to play:", WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2, arcade.color.PINK_LACE, font_size=20, anchor_x="center") arcade.draw_text( "Use the up,left,right and down arrows or wasd to move and use P to sell flowers", WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2 - 30, arcade.color.PINK_LACE, font_size=20, anchor_x="center") arcade.draw_text( "Collect flowers by walking over them and attack vegetables by bumping into them", WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2 - 60, arcade.color.PINK_LACE, font_size=20, anchor_x="center") arcade.draw_text( "There are 20 levels, go to the hole in the dirt to move to the next room", WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2 - 120, arcade.color.PINK_LACE, font_size=20, anchor_x="center") arcade.draw_text("Have Fun! ", WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2 - 150, arcade.color.PINK_LACE, font_size=20, anchor_x="center")
def on_draw(self): """ Render the screen. """ # This command has to happen before we start drawing arcade.start_render() # Draw all the sprites. # self.floor_list.draw() # self.wall_list.draw() # self.wood_list.draw() # self.objects_list.draw() # self.player_sprite.draw() # self.second_list.draw() # self.my_map.width = 2 # for row_number in range(self.my_map.width): # # start_x = self.my_map.tilewidth // 2 * self.my_map.width + self.my_map.tilewidth // 2 * row_number # start_y = self.my_map.tilewidth // 2 * row_number # end_x = self.my_map.tilewidth // 2 * row_number # end_y = self.my_map.tileheight // 2 * self.my_map.height + self.my_map.tilewidth // 2 * row_number # arcade.draw_line(start_x, start_y, end_x, end_y, arcade.color.WHITE, 2) # # start_x = self.my_map.tilewidth // 2 * self.my_map.width # start_y = 0 # end_x = self.my_map.tilewidth // 2 * self.my_map.width * 2 # end_y = self.my_map.tileheight // 2 * self.my_map.height # arcade.draw_line(start_x, start_y, end_x, end_y, arcade.color.LIGHT_CYAN, 2) tilewidth = TILE_WIDTH tileheight = TILE_HEIGHT width = MAP_WIDTH height = MAP_HEIGHT # Axis start_x = 0 start_y = 0 end_x = 0 end_y = 1000 arcade.draw_line(start_x, start_y, end_x, end_y, arcade.color.WHITE, 2) # Axis start_x = 0 start_y = 0 end_x = 1000 end_y = 0 arcade.draw_line(start_x, start_y, end_x, end_y, arcade.color.WHITE, 2) # x Tic Marks for x in range(0, 1000, 64): start_y = -10 end_y = 0 arcade.draw_line(x, start_y, x, end_y, arcade.color.WHITE, 2) text_y = -25 arcade.draw_text(f"{x}", x, text_y, arcade.color.WHITE, 12, width=200, align="center", anchor_x="center") # x Tic Marks for y in range(0, 1000, 64): start_x = -10 end_x = 0 arcade.draw_line(start_x, y, end_x, y, arcade.color.WHITE, 2) text_x = -50 arcade.draw_text(f"{y}", text_x, y - 4, arcade.color.WHITE, 12, width=70, align="right", anchor_x="center") # Gridlines 1 for tile_row in range(-1, height): tile_x = 0 start_x, start_y = get_screen_coordinates(tile_x, tile_row, width, height, tilewidth, tileheight) tile_x = width - 1 end_x, end_y = get_screen_coordinates(tile_x, tile_row, width, height, tilewidth, tileheight) start_x -= tilewidth // 2 end_y -= tileheight // 2 arcade.draw_line(start_x, start_y, end_x, end_y, arcade.color.WHITE) # Gridlines 2 for tile_column in range(-1, width): tile_y = 0 start_x, start_y = get_screen_coordinates(tile_column, tile_y, width, height, tilewidth, tileheight) tile_y = height - 1 end_x, end_y = get_screen_coordinates(tile_column, tile_y, width, height, tilewidth, tileheight) start_x += tilewidth // 2 end_y -= tileheight // 2 arcade.draw_line(start_x, start_y, end_x, end_y, arcade.color.WHITE) print() for tile_x in range(width): for tile_y in range(height): screen_x, screen_y = get_screen_coordinates( tile_x, tile_y, width, height, tilewidth, tileheight) if tile_x == 0 and tile_y == 0: color = arcade.color.GREEN elif tile_x == 1 and tile_y == 0: color = arcade.color.AFRICAN_VIOLET else: color = arcade.color.RED arcade.draw_point(screen_x, screen_y, color, 3) arcade.draw_text(f"{tile_x}, {tile_y}", screen_x, screen_y, arcade.color.WHITE, 12, width=200, align="center", anchor_x="center")
def on_draw(self): """ Render the screen. """ # Clear the screen to the background color arcade.start_render() # Draw our sprites for i in self.background: i.draw() self.checkpoint_list.draw() self.wall_list.draw() self.golden_key_list.draw() self.golden_door_list.draw() self.coin_list.draw() self.heart_list.draw() self.dont_touch_list.draw() self.enemy_list.draw() self.exit_list.draw() self.ladder_list.draw() self.player_list.draw() for i in self.foreground: i.draw() # Draw our score on the screen, scrolling it with the viewport score_text = f"Score: {self.score}" arcade.draw_text(score_text, 20 + self.view_left, SCREEN_HEIGHT - 30 + self.view_bottom, arcade.csscolor.BLACK, 18) arcade.draw_text(f'Level {self.level}', 20 + self.view_left, SCREEN_HEIGHT - 50 + self.view_bottom, arcade.csscolor.BLACK, 18) #player_name #arcade.draw_text('Pasha +PLUS+', self.player_sprite.left - 32, self.player_sprite.top, arcade.csscolor.WHITE, 18) arcade.draw_text(f"Lifes: {self.lifes}", 20 + self.view_left, SCREEN_HEIGHT - 70 + self.view_bottom, arcade.csscolor.BLACK, 18) #keys if self.has_golden_key: arcade.draw_text('Ключ', 20 + self.view_left, SCREEN_HEIGHT - 90 + self.view_bottom, arcade.csscolor.BLACK, 18) #dash_cooldown if time.time() - self.dash_start_time >= DASH_COOLDOWN: arcade.draw_text('Dash: ready', 130 + self.view_left, SCREEN_HEIGHT - 30 + self.view_bottom, arcade.csscolor.BLACK, 18) else: arcade.draw_text(f"Dash: {round(DASH_COOLDOWN-time.time() + self.dash_start_time)}", 130 + self.view_left, SCREEN_HEIGHT - 30 + self.view_bottom, arcade.csscolor.BLACK, 18)
#Sign your name: Caleb Hews ''' 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 Jedi training") arcade.set_background_color(arcade.color.ALMOND) x = 20 y = 20 arcade.start_render() for x in range(0, 600, 20): arcade.draw_line(20 + x, 400, 20 + x, 0, arcade.color.BLACK, 1) for y in range(0, 600, 20): arcade.draw_line(0, 20 + y, 500, 20 + y, arcade.color.BLACK, 1) arcade.draw_lrtb_rectangle_filled(20, 80, 380, 360, arcade.color.PHLOX) arcade.draw_rectangle_filled(200, 260, 40, 20, arcade.color.BLUSH, 45) arcade.draw_circle_filled(250, 200, 40, arcade.color.WISTERIA) arcade.draw_ellipse_filled(100, 100, 60, 20, arcade.color.AMBER) arcade.draw_arc_filled(400, 320, 60, 60, arcade.color.YELLOW, 30, 330) arcade.draw_line(80, 20, 120, 60, arcade.color.BLUE, 1) arcade.draw_text("I love you. I know.", 20, 160, arcade.color.BRICK_RED, 20) arcade.draw_rectangle_filled(460, 10, 5, 5, arcade.color.RED) arcade.finish_render() arcade.run()
def on_draw(self): arcade.start_render() end_status = self.world.end_status check_render = self.world.is_ans self.bg_img = arcade.Sprite(self.world.bg_pix) self.bg_img.set_position(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2) self.bg_img.draw() if end_status == 0: #play game if self.time >= 32: self.world.status_sound('theme', False) self.world.status_sound('theme', True) self.time = 0 self.box_img.draw() self.box2_img.draw() self.coin2_img.draw() arcade.draw_text(str(LIST[self.world.question - 1][0]), BOX_POS[0][0], BOX_POS[0][1], arcade.color.BLACK, 30, width=223, align="center", anchor_x="center", anchor_y="center") arcade.draw_text('Press Left Key', BOX_POS[0][0], BOX_POS[0][1] - 55, arcade.color.GRAY, 12, width=223, align="center", anchor_x="center", anchor_y="center") arcade.draw_text(str(LIST[self.world.question - 1][1]), BOX_POS[1][0], BOX_POS[1][1], arcade.color.BLACK, 30, width=223, align="center", anchor_x="center", anchor_y="center") arcade.draw_text('Press Right Key', BOX_POS[1][0], BOX_POS[1][1] - 55, arcade.color.GRAY, 12, width=223, align="center", anchor_x="center", anchor_y="center") if not self.world.can_ans: #not enough coin arcade.draw_text(': ' + str(self.world.bet), 330, 130, arcade.color.RED, 20) if self.world.can_ans: #enough coin arcade.draw_text(': ' + str(self.world.bet), 330, 130, arcade.color.BLACK, 20) if check_render[0]: #show result if check_render[1]: self.ans_img = arcade.Sprite('images/right.png') arcade.draw_text("Correct! You got " + str(self.world.bet) + " coins", 370, 400, arcade.color.BLACK, 30, width=1000, align="center", anchor_x="center", anchor_y="center") if not check_render[1]: self.ans_img = arcade.Sprite('images/wrong.png') arcade.draw_text("Wrong! You lose " + str(self.world.bet) + " coins", 370, 400, arcade.color.RED, 30, width=1000, align="center", anchor_x="center", anchor_y="center") self.ans_img.set_position(BOX_POS[check_render[2]][0], BOX_POS[check_render[2]][1]) self.ans_img.draw() arcade.draw_text('Press Enter to continue', 250, 80, arcade.color.GRAY, 15) if not self.world.can_ans: if self.world.bet < self.world.check_coin(): arcade.draw_text( '( min ' + str(self.world.check_coin()) + ' )', 300, 100, arcade.color.RED, 13) if self.world.bet > self.world.coin: arcade.draw_text(' ( Too high )', 300, 100, arcade.color.RED, 13) self.coin_img.draw() arcade.draw_text(str(self.world.coin), 60, self.height - 35, arcade.color.WHITE, 20) if end_status != 0: #end game self.world.is_ans[0] = True if self.world.is_restart == True: self.world = World() arcade.draw_text('Press Enter to play again', 230, 20, arcade.color.GRAY, 18) if end_status == 1: arcade.draw_text('You are a billionaire!!!', SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, arcade.color.WHITE, 40, width=SCREEN_WIDTH, align="center", anchor_x="center", anchor_y="center") if end_status == 2: arcade.draw_text('Oop! You go bankrupt!', SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, arcade.color.WHITE, 40, width=SCREEN_WIDTH, align="center", anchor_x="center", anchor_y="center") if end_status == 3: arcade.draw_text('You are a commoner', SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, arcade.color.WHITE, 40, width=SCREEN_WIDTH, align="center", anchor_x="center", anchor_y="center")
def on_draw(self): arcade.start_render() arcade.draw_text(str(self.score), 20, SCREEN_HEIGHT - 40, open_color.white, 16) self.player.draw() self.bullet_list.draw() self.enemy_list.draw()
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()
# ? import arcade import os # ? arcade.open_window(600, 600, "My First Arcade Program") # ? arcade.set_background_color(arcade.color.WHITE) # ? arcade.start_render() # ? arcade.draw_text("draw_circle_filled", 363, 207, arcade.color.BLACK, 10) arcade.draw_circle_filled(420, 285, 18, arcade.color.GREEN) # ? arcade.finish_render() # ? arcade.run()
arcade.set_background_color(arcade.color.BLUE_GRAY) # 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.WHITE, 2) # Draw horizontal lines every 200 pixels 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)
def draw_game_over(self): """ Draw "Game over" across the screen. """ output = "Game Over" arcade.draw_text(output, 240, 400, arcade.color.WHITE, 54) output = "Click to restart" arcade.draw_text(output, 310, 300, arcade.color.WHITE, 24)