Ejemplo n.º 1
0
    def on_draw(self):
        """
        Render the screen.
        """

        # This command has to happen before we start drawing
        arcadeplus.start_render()

        for z in [300, 200, 150, 100]:
            opacity = int(math.exp(-z / 1000) * 255)
            angle = z
            scale = 150 / z
            translate = scale / 500
            self.stars.draw_transformed(
                0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, opacity,
                Matrix3x3().rotate(angle).scale(scale * ASPECT,
                                                scale).translate(
                                                    -self.camera_x * translate,
                                                    0))
        self.ship.draw()

        for i, pair in enumerate([
            ['identity', Matrix3x3()],
            ['rotate(30)', Matrix3x3().rotate(30)],
            ['scale(0.8, 0.5)', Matrix3x3().scale(0.8, 0.5)],
            ['translate(0.3, 0.1)',
             Matrix3x3().translate(0.3, 0.1)],
            [
                'rotate(10).\nscale(0.33, 0.33)',
                Matrix3x3().rotate(10).scale(0.7, 0.7)
            ],
            ['scale(-1, 1)', Matrix3x3().scale(-1, 1)],
            ['shear(0.3, 0.1)', Matrix3x3().shear(0.3, 0.1)],
            [f'rotate({int(self.t) % 360})',
             Matrix3x3().rotate(self.t)],
        ]):
            x = 80 + 180 * (i % 4)
            y = 420 - (i // 4) * 320
            arcadeplus.draw_text(pair[0], x, y - 20 - pair[0].count('\n') * 10,
                                 arcadeplus.color.WHITE, 10)
            self.xy_square.draw_transformed(x, y, 100, 100, 0, 255, pair[1])
Ejemplo n.º 2
0
    def on_draw(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.
        arcadeplus.start_render()

        # Draw the sprites
        self.wall_list.draw()
        self.player_list.draw()

        # Draw info on the screen
        sprite_count = len(self.wall_list)

        output = f"Sprite Count: {sprite_count}"
        arcadeplus.draw_text(output, self.view_left + 20,
                             self.height - 20 + self.view_bottom,
                             arcadeplus.color.WHITE, 16)

        output = f"Drawing time: {self.draw_time:.3f}"
        arcadeplus.draw_text(output, self.view_left + 20,
                             self.height - 40 + self.view_bottom,
                             arcadeplus.color.WHITE, 16)

        output = f"Processing time: {self.processing_time:.3f}"
        arcadeplus.draw_text(output, self.view_left + 20,
                             self.height - 60 + self.view_bottom,
                             arcadeplus.color.WHITE, 16)

        self.draw_time = timeit.default_timer() - draw_start_time
Ejemplo n.º 3
0
    def on_draw(self):
        """
        Render the screen.
        """

        # This command has to happen before we start drawing
        arcadeplus.start_render()

        # Start timing how long this takes
        draw_start_time = timeit.default_timer()

        # Draw all the sprites.
        self.wall_list.draw()
        self.player_list.draw()

        # Draw info on the screen
        sprite_count = len(self.wall_list)

        output = f"Sprite Count: {sprite_count}"
        arcadeplus.draw_text(output, self.view_left + 20,
                             SCREEN_HEIGHT - 20 + self.view_bottom,
                             arcadeplus.color.WHITE, 16)

        output = f"Drawing time: {self.draw_time:.3f}"
        arcadeplus.draw_text(output, self.view_left + 20,
                             SCREEN_HEIGHT - 40 + self.view_bottom,
                             arcadeplus.color.WHITE, 16)

        output = f"Processing time: {self.processing_time:.3f}"
        arcadeplus.draw_text(output, self.view_left + 20,
                             SCREEN_HEIGHT - 60 + self.view_bottom,
                             arcadeplus.color.WHITE, 16)

        self.draw_time = timeit.default_timer() - draw_start_time
Ejemplo n.º 4
0
    def on_draw(self):
        """
        Render the screen.
        """

        # This command has to happen before we start drawing
        arcadeplus.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)
            arcadeplus.draw_line(pv1.x, pv1.y, pv2.x, pv2.y,
                                 arcadeplus.color.WHITE, 2)

        for joint in self.joints:
            color = arcadeplus.color.WHITE
            if isinstance(joint, pymunk.DampedSpring):
                color = arcadeplus.color.DARK_GREEN
            arcadeplus.draw_line(joint.a.position.x, joint.a.position.y,
                                 joint.b.position.x, joint.b.position.y, color,
                                 3)

        # arcadeplus.draw_text(output, 10, 20, arcadeplus.color.WHITE, 14)
        # Display timings
        output = f"Processing time: {self.processing_time:.3f}"
        arcadeplus.draw_text(output, 20, SCREEN_HEIGHT - 20,
                             arcadeplus.color.WHITE)

        output = f"Drawing time: {self.draw_time:.3f}"
        arcadeplus.draw_text(output, 20, SCREEN_HEIGHT - 40,
                             arcadeplus.color.WHITE)

        self.draw_time = timeit.default_timer() - draw_start_time

        output = f"Mode: {self.mode}"
        arcadeplus.draw_text(output, 20, SCREEN_HEIGHT - 60,
                             arcadeplus.color.WHITE)

        output = f"Physics: {self.physics}"
        arcadeplus.draw_text(output, 20, SCREEN_HEIGHT - 80,
                             arcadeplus.color.WHITE)
Ejemplo n.º 5
0
    def on_draw(self):
        """ Render the screen. """

        # This command has to happen before we start drawing
        arcadeplus.start_render()

        # Start timing how long this takes
        draw_start_time = timeit.default_timer()

        # Draw all the sprites
        self.static_sprite_list.draw()
        self.dynamic_sprite_list.draw()

        # Display timings
        output = f"Processing time: {self.processing_time:.3f}"
        arcadeplus.draw_text(output, 20 + self.view_left,
                             SCREEN_HEIGHT - 20 + self.view_bottom,
                             arcadeplus.color.WHITE, 12)

        output = f"Drawing time: {self.draw_time:.3f}"
        arcadeplus.draw_text(output, 20 + self.view_left,
                             SCREEN_HEIGHT - 40 + self.view_bottom,
                             arcadeplus.color.WHITE, 12)

        # Display instructions
        output = "Use the mouse to move boxes, space to punch, hold G to grab an item to the right."
        arcadeplus.draw_text(output, 20 + self.view_left,
                             SCREEN_HEIGHT - 60 + self.view_bottom,
                             arcadeplus.color.WHITE, 12)

        self.draw_time = timeit.default_timer() - draw_start_time
Ejemplo n.º 6
0
    def on_draw(self):
        """ Render the screen. """

        # This command has to happen before we start drawing
        arcadeplus.start_render()

        # Draw all the sprites.
        self.enemy_list.draw()
        self.player_bullet_list.draw()
        self.enemy_bullet_list.draw()
        self.shield_list.draw()
        self.player_list.draw()

        # Render the text
        arcadeplus.draw_text(f"Score: {self.score}", 10, 20,
                             arcadeplus.color.WHITE, 14)

        # Draw game over if the game state is such
        if self.game_state == GAME_OVER:
            arcadeplus.draw_text(f"GAME OVER", 250, 300,
                                 arcadeplus.color.WHITE, 55)
            self.set_mouse_visible(True)
Ejemplo n.º 7
0
    def on_draw(self):
        # clear screen and start render process
        arcadeplus.start_render()

        # draw game items
        self.bullet_list.draw()
        self.enemy_list.draw()
        self.player.draw()

        # Put the score on the screen.
        output = f"Score: {self.score}"
        arcadeplus.draw_text(output, 10, 20, arcadeplus.color.WHITE, 14)

        # Game over message
        if self.game_over:
            arcadeplus.draw_text("Game Over",
                                 SCREEN_WIDTH / 2,
                                 SCREEN_HEIGHT / 2,
                                 arcadeplus.color.WHITE,
                                 100,
                                 width=SCREEN_WIDTH,
                                 align="center",
                                 anchor_x="center",
                                 anchor_y="center")
def draw_reset_button(x, y, button_width, button_height, colour_default, text,
                      colour_hover, colour_press):
    global restart, reset1
    if x + (button_width / 2) > mouse_x > x - (button_width / 2) and \
            y - (button_height / 2) < mouse_y < y + (button_height / 2) and \
            mouse_press:
        arcade.draw_rectangle_filled(x, y, button_width, button_height,
                                     colour_press)
        if not start and reset:
            restart = True
            reset1 = False
        elif start and reset:
            restart = False
            reset1 = False
    elif x + (button_width / 2) > mouse_x > x - (button_width / 2) and \
            y - (button_height / 2) < mouse_y < y + (button_height / 2) and \
            not mouse_press:
        arcade.draw_rectangle_filled(x, y, button_width, button_height,
                                     colour_hover)
        reset1 = True
    else:
        arcade.draw_rectangle_filled(x, y, button_width, button_height,
                                     colour_default)
    arcade.draw_text(text, x - 25, y - 7, arcade.color.BLACK, 12, bold=True)
Ejemplo n.º 9
0
    def on_draw(self):
        """
        Render the screen.
        """

        # This command has to happen before we start drawing
        arcadeplus.start_render()

        # Start timing how long this takes
        draw_start_time = timeit.default_timer()

        # --- Draw all the rectangles
        for x in range(0, SCREEN_WIDTH, SQUARE_SPACING):
            for y in range(0, SCREEN_HEIGHT, SQUARE_SPACING):
                arcadeplus.draw_rectangle_filled(x, y, SQUARE_WIDTH,
                                                 SQUARE_HEIGHT,
                                                 arcadeplus.color.DARK_BLUE)

        # Print the timing
        output = f"Drawing time: {self.draw_time:.3f} seconds per frame."
        arcadeplus.draw_text(output, 20, SCREEN_HEIGHT - 40,
                             arcadeplus.color.WHITE, 18)

        self.draw_time = timeit.default_timer() - draw_start_time
Ejemplo n.º 10
0
    def on_draw(self):
        arcadeplus.start_render()
        """
        Draw "Game over" across the screen.
        """
        arcadeplus.draw_text("Game Over", 240, 400, arcadeplus.color.WHITE, 54)
        arcadeplus.draw_text("Click to restart", 310, 300, arcadeplus.color.WHITE, 24)

        time_taken_formatted = f"{round(self.time_taken, 2)} seconds"
        arcadeplus.draw_text(f"Time taken: {time_taken_formatted}",
                         WIDTH/2,
                         200,
                         arcadeplus.color.GRAY,
                         font_size=15,
                         anchor_x="center")

        output_total = f"Total Score: {self.window.total_score}"
        arcadeplus.draw_text(output_total, 10, 10, arcadeplus.color.WHITE, 14)
Ejemplo n.º 11
0
    def on_draw(self):
        """ Draw everything """
        arcadeplus.start_render()
        self.coin_list.draw()
        self.trigger_sprite.draw()
        self.player_list.draw()

        # Put the instructions on the screen.
        instructions1 = "Touch a coin to set its intensity property to 'bright'."
        arcadeplus.draw_text(instructions1, 10, 90, arcadeplus.color.WHITE, 14)
        instructions2 = "Touch the trigger at the bottom-right to destroy all 'bright' sprites."
        arcadeplus.draw_text(instructions2, 10, 70, arcadeplus.color.WHITE, 14)

        # Query the property on the coins and show results.
        coins_are_bright = [
            coin.intensity == 'bright' for coin in self.coin_list
        ]
        output_any = f"Any sprites have intensity=bright? : {any(coins_are_bright)}"
        arcadeplus.draw_text(output_any, 10, 40, arcadeplus.color.WHITE, 14)
        output_all = f"All sprites have intensity=bright? : {all(coins_are_bright)}"
        arcadeplus.draw_text(output_all, 10, 20, arcadeplus.color.WHITE, 14)
Ejemplo n.º 12
0
    def on_draw(self):
        """ Draw everything """

        # Start timing how long this takes
        draw_start_time = timeit.default_timer()

        if self.frame_count % 60 == 0:
            if self.fps_start_timer is not None:
                total_time = timeit.default_timer() - self.fps_start_timer
                self.fps = 60 / total_time
            self.fps_start_timer = timeit.default_timer()
        self.frame_count += 1

        arcadeplus.start_render()
        self.coin_list.draw()
        self.player_list.draw()

        # Put the text on the screen.
        output = f"Score: {self.score}"
        arcadeplus.draw_text(output, 10, 20, arcadeplus.color.WHITE, 14)

        # Display timings
        output = f"Processing time: {self.processing_time:.3f}"
        arcadeplus.draw_text(output, 20, SCREEN_HEIGHT - 20,
                             arcadeplus.color.BLACK, 16)

        output = f"Drawing time: {self.draw_time:.3f}"
        arcadeplus.draw_text(output, 20, SCREEN_HEIGHT - 40,
                             arcadeplus.color.BLACK, 16)

        if self.fps is not None:
            output = f"FPS: {self.fps:.0f}"
            arcadeplus.draw_text(output, 20, SCREEN_HEIGHT - 60,
                                 arcadeplus.color.BLACK, 16)

        self.draw_time = timeit.default_timer() - draw_start_time
Ejemplo n.º 13
0
    def on_draw(self):
        """
        Render the screen.
        """

        self.frame_count += 1

        # This command has to happen before we start drawing
        arcadeplus.start_render()

        # Draw all the sprites.
        self.player_list.draw()
        self.wall_list.draw()
        self.coin_list.draw()

        if self.last_time and self.frame_count % 60 == 0:
            fps = 1.0 / (time.time() - self.last_time) * 60
            self.fps_message = f"FPS: {fps:5.0f}"

        if self.fps_message:
            arcadeplus.draw_text(self.fps_message, self.view_left + 10,
                                 self.view_bottom + 40, arcadeplus.color.BLACK,
                                 14)

        if self.frame_count % 60 == 0:
            self.last_time = time.time()

        # Put the text on the screen.
        # Adjust the text position based on the view port so that we don't
        # scroll the text too.
        distance = self.player_sprite.right
        output = f"Distance: {distance}"
        arcadeplus.draw_text(output, self.view_left + 10,
                             self.view_bottom + 20, arcadeplus.color.BLACK, 14)

        if self.game_over:
            arcadeplus.draw_text("Game Over", self.view_left + 200,
                                 self.view_bottom + 200,
                                 arcadeplus.color.BLACK, 30)
Ejemplo n.º 14
0
    def on_draw(self):
        arcadeplus.start_render()

        # Draw player, for effect, on pause screen.
        # The previous View (GameView) was passed in
        # and saved in self.game_view.
        player_sprite = self.game_view.player_sprite
        player_sprite.draw()

        # draw an orange filter over him
        arcadeplus.draw_lrtb_rectangle_filled(left=player_sprite.left,
                                              right=player_sprite.right,
                                              top=player_sprite.top,
                                              bottom=player_sprite.bottom,
                                              color=arcadeplus.color.ORANGE +
                                              (200, ))

        arcadeplus.draw_text("PAUSED",
                             WIDTH / 2,
                             HEIGHT / 2 + 50,
                             arcadeplus.color.BLACK,
                             font_size=50,
                             anchor_x="center")

        # Show tip to return or reset
        arcadeplus.draw_text("Press Esc. to return",
                             WIDTH / 2,
                             HEIGHT / 2,
                             arcadeplus.color.BLACK,
                             font_size=20,
                             anchor_x="center")
        arcadeplus.draw_text("Press Enter to reset",
                             WIDTH / 2,
                             HEIGHT / 2 - 30,
                             arcadeplus.color.BLACK,
                             font_size=20,
                             anchor_x="center")
def sliders2():
    global slide2_color, slider_x2, press2, CURE_RATE
    if slider_x2 - 5 <= mouse_x <= slider_x2 + 5 and slider_y2 - 13 <= mouse_y <= slider_y2 + 13:
        slide2_color = arcade.color.GRAY
        if mouse_press:
            slide2_color = arcade.color.DARK_GRAY
            press2 = True
            if 700 < slider_x2 < 900:
                slider_x2 = mouse_x
    elif not mouse_press and press2:
        slide2_color = arcade.color.BLUE
        press2 = False
    elif press2:
        if 700 < slider_x2 < 900:
            slider_x2 = mouse_x
            slide2_color = arcade.color.DARK_GRAY
    else:
        slide2_color = arcade.color.BLUE
    if slider_x2 >= 900:
        slider_x2 = 899
    elif slider_x2 <= 700:
        slider_x2 = 701
    arcade.draw_rectangle_outline(WIDTH / 2, HEIGHT / 2 - 200, 200, 5, arcade.color.BLACK)
    arcade.draw_rectangle_filled(slider_x2, slider_y2, 10, 25, slide2_color)

    if slider_x2 >= 833:
        arcade.draw_text(f'Cure Rate: High', WIDTH / 2 - 20, HEIGHT / 2 - 230,
                         arcade.color.BLACK)
    elif slider_x2 <= 777:
        arcade.draw_text(f'Cure Rate: Low', WIDTH / 2 - 20, HEIGHT / 2 - 230,
                         arcade.color.BLACK)
    else:
        arcade.draw_text(f'Cure Rate: Medium', WIDTH / 2 - 20, HEIGHT / 2 - 230,
                         arcade.color.BLACK)

    CURE_RATE = (200 - (slider_x2 - 700)) * 10
def sliders1():
    global slide1_color, slider_x1, press1, DEATH_RATE
    if slider_x1 - 5 <= mouse_x <= slider_x1 + 5 and slider_y1 - 13 <= mouse_y <= slider_y1 + 13:
        slide1_color = arcade.color.GRAY
        if mouse_press:
            slide1_color = arcade.color.DARK_GRAY
            press1 = True
            if 700 < slider_x1 < 900:
                slider_x1 = mouse_x
    elif not mouse_press and press1:
        slide1_color = arcade.color.BLUE
        press1 = False
    elif press1:
        if 700 < slider_x1 < 900:
            slider_x1 = mouse_x
            slide1_color = arcade.color.DARK_GRAY
    else:
        slide1_color = arcade.color.BLUE
    if slider_x1 >= 900:
        slider_x1 = 899
    elif slider_x1 <= 700:
        slider_x1 = 701
    arcade.draw_rectangle_outline(WIDTH / 2, HEIGHT / 2 - 100, 200, 5, arcade.color.BLACK)
    arcade.draw_rectangle_filled(slider_x1, slider_y1, 10, 25, slide1_color)
    if slider_x1 >= 833:
        arcade.draw_text(f'Death Rate: High', WIDTH / 2 - 20, HEIGHT / 2 - 130,
                         arcade.color.BLACK)
    elif slider_x1 <= 777:
        arcade.draw_text(f'Death Rate: Low', WIDTH / 2 - 20, HEIGHT / 2 - 130,
                         arcade.color.BLACK)
    else:
        arcade.draw_text(f'Death Rate: Medium', WIDTH / 2 - 20, HEIGHT / 2 - 130,
                         arcade.color.BLACK)


    DEATH_RATE = (200 - (slider_x1 - 700)) * 10
Ejemplo n.º 17
0
    def on_draw(self):
        """
        Render the screen.
        """

        # Start the render process. This must be done before any drawing commands.
        arcadeplus.start_render()

        # Draw a grid
        # Draw vertical lines every 120 pixels
        for x in range(0, 601, 120):
            arcadeplus.draw_line(x, 0, x, 600, arcadeplus.color.BLACK, 2)

        # Draw horizontal lines every 200 pixels
        for y in range(0, 601, 200):
            arcadeplus.draw_line(0, y, 800, y, arcadeplus.color.BLACK, 2)

        # Draw a point
        arcadeplus.draw_text("draw_point", 3, 405, arcadeplus.color.BLACK, 12)
        arcadeplus.draw_point(60, 495, arcadeplus.color.RED, 10)

        # Draw a set of points
        arcadeplus.draw_text("draw_points", 123, 405, arcadeplus.color.BLACK,
                             12)
        point_list = ((165, 495), (165, 480), (165, 465), (195, 495),
                      (195, 480), (195, 465))
        arcadeplus.draw_points(point_list, arcadeplus.color.ZAFFRE, 10)

        # Draw a line
        arcadeplus.draw_text("draw_line", 243, 405, arcadeplus.color.BLACK, 12)
        arcadeplus.draw_line(270, 495, 300, 450, arcadeplus.color.WOOD_BROWN,
                             3)

        # Draw a set of lines
        arcadeplus.draw_text("draw_lines", 363, 405, arcadeplus.color.BLACK,
                             12)
        point_list = ((390, 450), (450, 450), (390, 480), (450, 480),
                      (390, 510), (450, 510))
        arcadeplus.draw_lines(point_list, arcadeplus.color.BLUE, 3)

        # Draw a line strip
        arcadeplus.draw_text("draw_line_strip", 483, 405,
                             arcadeplus.color.BLACK, 12)
        point_list = ((510, 450), (570, 450), (510, 480), (570, 480),
                      (510, 510), (570, 510))
        arcadeplus.draw_line_strip(point_list,
                                   arcadeplus.color.TROPICAL_RAIN_FOREST, 3)
        arcadeplus.draw_line_strip(point_list, arcadeplus.color.BEIGE)

        # Draw a polygon
        arcadeplus.draw_text("draw_polygon_outline", 3, 207,
                             arcadeplus.color.BLACK, 9)
        point_list = ((30, 240), (45, 240), (60, 255), (60, 285), (45, 300),
                      (30, 300))
        arcadeplus.draw_polygon_outline(point_list,
                                        arcadeplus.color.SPANISH_VIOLET, 3)

        # Draw a filled in polygon
        arcadeplus.draw_text("draw_polygon_filled", 123, 207,
                             arcadeplus.color.BLACK, 9)
        point_list = ((150, 240), (165, 240), (180, 255), (180, 285),
                      (165, 300), (150, 300))
        arcadeplus.draw_polygon_filled(point_list,
                                       arcadeplus.color.SPANISH_VIOLET)

        # Draw an outline of a circle
        arcadeplus.draw_text("draw_circle_outline", 243, 207,
                             arcadeplus.color.BLACK, 10)
        arcadeplus.draw_circle_outline(300, 285, 18, arcadeplus.color.WISTERIA,
                                       3)
        arcadeplus.draw_circle_outline(350, 285, 18, arcadeplus.color.WISTERIA)

        # Draw a filled in circle
        arcadeplus.draw_text("draw_circle_filled", 363, 207,
                             arcadeplus.color.BLACK, 10)
        arcadeplus.draw_circle_filled(420, 285, 18, arcadeplus.color.GREEN)

        # Draw an ellipse outline, and another one rotated
        arcadeplus.draw_text("draw_ellipse_outline", 483, 207,
                             arcadeplus.color.BLACK, 10)
        arcadeplus.draw_ellipse_outline(540, 273, 15, 36,
                                        arcadeplus.color.AMBER, 3)
        arcadeplus.draw_ellipse_outline(540, 336, 15, 36,
                                        arcadeplus.color.BLACK_BEAN, 3, 45)

        # Draw a filled ellipse, and another one rotated
        arcadeplus.draw_text("draw_ellipse_filled", 3, 3,
                             arcadeplus.color.BLACK, 10)
        arcadeplus.draw_ellipse_filled(60, 81, 15, 36, arcadeplus.color.AMBER)
        arcadeplus.draw_ellipse_filled(60, 144, 15, 36,
                                       arcadeplus.color.BLACK_BEAN, 45)

        # Draw an arc, and another one rotated
        arcadeplus.draw_text("draw_arc/filled_arc", 123, 3,
                             arcadeplus.color.BLACK, 10)
        arcadeplus.draw_arc_outline(150, 81, 15, 36,
                                    arcadeplus.color.BRIGHT_MAROON, 90, 360)
        arcadeplus.draw_arc_filled(150, 144, 15, 36,
                                   arcadeplus.color.BOTTLE_GREEN, 90, 360, 45)

        # Draw an rectangle outline
        arcadeplus.draw_text("draw_rect", 243, 3, arcadeplus.color.BLACK, 10)
        arcadeplus.draw_rectangle_outline(
            295, 100, 45, 65, arcadeplus.color.BRITISH_RACING_GREEN)
        arcadeplus.draw_rectangle_outline(
            295, 160, 20, 45, arcadeplus.color.BRITISH_RACING_GREEN, 3, 45)

        # Draw a filled in rectangle
        arcadeplus.draw_text("draw_filled_rect", 363, 3,
                             arcadeplus.color.BLACK, 10)
        arcadeplus.draw_rectangle_filled(420, 100, 45, 65,
                                         arcadeplus.color.BLUSH)
        arcadeplus.draw_rectangle_filled(420, 160, 20, 40,
                                         arcadeplus.color.BLUSH, 45)

        # Load and draw an image to the screen
        # Image from kenney.nl asset pack #1
        arcadeplus.draw_text("draw_bitmap", 483, 3, arcadeplus.color.BLACK, 12)
        texture = arcadeplus.load_texture(
            ":resources:images/space_shooter/playerShip1_orange.png")
        scale = .6
        # arcadeplus.draw_texture_rectangle(540, 120, scale * texture.width,
        #                               scale * texture.height, texture, 0)
        # arcadeplus.draw_texture_rectangle(540, 60, scale * texture.width,
        #                               scale * texture.height, texture, 45)
        #
        # Overlapping, with transparency test
        # Draw
        arcadeplus.draw_rectangle_filled(650, 100, 50, 50, (255, 0, 0))
        arcadeplus.draw_rectangle_filled(670, 100, 50, 50, (0, 255, 0, 127))

        # Test colors
        color = arcadeplus.get_pixel(635, 100)
        assert color == (255, 0, 0)
        color = arcadeplus.get_pixel(670, 100)
        assert color == (128, 127, 0)
        color = arcadeplus.get_pixel(690, 100)
        assert color == (128, 255, 128)

        # Test this other thing
        color = arcadeplus.get_pixel(100, 100)
        assert color == (255, 255, 255)

        # Run the get image. Ideally we'd test the output
        arcadeplus.get_image()
Ejemplo n.º 18
0
    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.
        arcadeplus.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
        arcadeplus.draw_point(start_x, start_y, arcadeplus.color.BLUE, 5)
        arcadeplus.draw_text("Simple line of text in 12 point", start_x,
                             start_y, arcadeplus.color.BLACK, 12)

        start_x = 50
        start_y = 150
        arcadeplus.draw_point(start_x, start_y, arcadeplus.color.BLUE, 5)
        arcadeplus.draw_text("Garamond Text",
                             start_x,
                             start_y,
                             arcadeplus.color.BLACK,
                             15,
                             font_name='GARA')

        start_x = 50
        start_y = 400
        arcadeplus.draw_point(start_x, start_y, arcadeplus.color.BLUE, 5)
        arcadeplus.draw_text("Text anchored 'top' and 'left'.",
                             start_x,
                             start_y,
                             arcadeplus.color.BLACK,
                             12,
                             anchor_x="left",
                             anchor_y="top")

        start_y = 350
        arcadeplus.draw_point(start_x, start_y, arcadeplus.color.BLUE, 5)
        arcadeplus.draw_text("14 point multi\nline\ntext",
                             start_x,
                             start_y,
                             arcadeplus.color.BLACK,
                             14,
                             anchor_y="top")

        start_y = 450
        start_x = 300
        width = 200
        height = 20
        arcadeplus.draw_point(start_x, start_y, arcadeplus.color.BLUE, 5)
        arcadeplus.draw_lrtb_rectangle_outline(start_x, start_x + width,
                                               start_y + height, start_y,
                                               arcadeplus.color.BLUE, 1)
        arcadeplus.draw_text("Centered Text.",
                             start_x,
                             start_y,
                             arcadeplus.color.BLACK,
                             14,
                             width=200,
                             align="center")

        start_y = 250
        start_x = 300
        arcadeplus.draw_point(start_x, start_y, arcadeplus.color.BLUE, 5)
        arcadeplus.draw_text("Text centered on\na point",
                             start_x,
                             start_y,
                             arcadeplus.color.BLACK,
                             14,
                             width=200,
                             align="center",
                             anchor_x="center",
                             anchor_y="center")

        start_y = 150
        start_x = 300
        arcadeplus.draw_point(start_x, start_y, arcadeplus.color.BLUE, 5)
        arcadeplus.draw_text("Text rotated on\na point",
                             start_x,
                             start_y,
                             arcadeplus.color.BLACK,
                             14,
                             width=200,
                             align="center",
                             anchor_x="center",
                             anchor_y="center",
                             rotation=self.text_angle)

        start_y = 150
        start_x = 20
        arcadeplus.draw_point(start_x, start_y, arcadeplus.color.BLUE, 5)
        arcadeplus.draw_text("Sideways text",
                             start_x,
                             start_y,
                             arcadeplus.color.BLACK,
                             14,
                             width=200,
                             align="center",
                             anchor_x="center",
                             anchor_y="center",
                             rotation=90.0)

        start_y = 20
        start_x = 50
        arcadeplus.draw_point(start_x, start_y, arcadeplus.color.BLUE, 5)
        arcadeplus.draw_text(f"Time elapsed: {self.time_elapsed:7.1f}",
                             start_x, start_y, arcadeplus.color.BLACK, 14)
Ejemplo n.º 19
0
def on_draw():
    arcade.start_render()
    arcade.draw_points(outside_points, (0, 0, 0), 2)
    arcade.draw_points(circle_points, (255, 0, 0), 2)
    arcade.draw_rectangle_filled(0, 0, 300, 40, arcade.color.WHITE)
    arcade.draw_text(f'pi={pi}', 0, 0, arcade.color.BLACK)
Ejemplo n.º 20
0
def render_toolbar_text():
    arcadeplus.draw_text("Total # Frames:",
                         905,
                         731,
                         color=arcadeplus.color.BLACK,
                         font_size=12)
    arcadeplus.draw_text(str(len(frames)),
                         910,
                         705,
                         color=arcadeplus.color.BLACK,
                         font_size=20)
    arcadeplus.draw_text("Current Frame:",
                         905,
                         681,
                         color=arcadeplus.color.BLACK,
                         font_size=12)
    arcadeplus.draw_text(str(current_frame),
                         910,
                         655,
                         color=arcadeplus.color.BLACK,
                         font_size=20)

    arcadeplus.draw_text("PREV FRM",
                         902,
                         631,
                         color=arcadeplus.color.BLACK,
                         font_size=9)
    arcadeplus.draw_text("NEXT FRM",
                         952,
                         631,
                         color=arcadeplus.color.BLACK,
                         font_size=9)

    arcadeplus.draw_text("UNDO",
                         910,
                         581,
                         color=arcadeplus.color.BLACK,
                         font_size=9)
    arcadeplus.draw_text("CLR FRM",
                         955,
                         581,
                         color=arcadeplus.color.BLACK,
                         font_size=9)

    arcadeplus.draw_text("DEL FRM",
                         904,
                         531,
                         color=arcadeplus.color.BLACK,
                         font_size=9)
    arcadeplus.draw_text("NEW FRM",
                         952,
                         531,
                         color=arcadeplus.color.BLACK,
                         font_size=9)

    arcadeplus.draw_text("LOAD SCN",
                         902,
                         481,
                         color=arcadeplus.color.BLACK,
                         font_size=9)
    arcadeplus.draw_text("NEW SCN",
                         954,
                         481,
                         color=arcadeplus.color.BLACK,
                         font_size=9)

    if captured[current_frame - 1]:
        arcadeplus.draw_xywh_rectangle_filled(900,
                                              750,
                                              100,
                                              50,
                                              color=arcadeplus.color.GREEN)
        arcadeplus.draw_text("CAPTURED",
                             907,
                             765,
                             color=arcadeplus.color.BLACK,
                             font_size=16)
    else:
        arcadeplus.draw_text("CAPTURE",
                             912,
                             765,
                             color=arcadeplus.color.BLACK,
                             font_size=16)
    if all(captured):
        arcadeplus.draw_xywh_rectangle_filled(0,
                                              750,
                                              100,
                                              50,
                                              color=arcadeplus.color.GREEN)
    arcadeplus.draw_text("RENDER",
                         13,
                         765,
                         color=arcadeplus.color.BLACK,
                         font_size=18)

    arcadeplus.draw_text("ABOUT",
                         918,
                         17,
                         color=arcadeplus.color.BLACK,
                         font_size=18)
Ejemplo n.º 21
0
    def on_draw(self):
        arcadeplus.start_render()
        current_x = 20

        # First line
        current_y = SCREEN_HEIGHT - LINE_HEIGHT
        arcadeplus.draw_text("Test Text", current_x, current_y,
                             arcadeplus.color.BLACK, 12)

        # Again to test caching
        current_y -= LINE_HEIGHT
        arcadeplus.draw_text("Test Text", current_x, current_y,
                             arcadeplus.color.BLACK, 12)

        current_y -= LINE_HEIGHT
        arcadeplus.draw_text("Test Text Anchor Left",
                             SCREEN_WIDTH // 2,
                             current_y,
                             arcadeplus.color.BLACK,
                             12,
                             anchor_x="left")
        arcadeplus.draw_point(SCREEN_WIDTH // 2, current_y,
                              arcadeplus.color.RED, 5)

        current_y -= LINE_HEIGHT
        arcadeplus.draw_text("Test Text Anchor Center",
                             SCREEN_WIDTH // 2,
                             current_y,
                             arcadeplus.color.BLACK,
                             12,
                             anchor_x="center")
        arcadeplus.draw_point(SCREEN_WIDTH // 2, current_y,
                              arcadeplus.color.RED, 5)

        current_y -= LINE_HEIGHT
        arcadeplus.draw_text("Test Text Anchor Right",
                             SCREEN_WIDTH // 2,
                             current_y,
                             arcadeplus.color.BLACK,
                             12,
                             anchor_x="right")
        arcadeplus.draw_point(SCREEN_WIDTH // 2, current_y,
                              arcadeplus.color.RED, 5)

        current_y -= LINE_HEIGHT
        arcadeplus.draw_text("Test Text Anchor Top",
                             SCREEN_WIDTH // 2,
                             current_y,
                             arcadeplus.color.BLACK,
                             12,
                             anchor_y="top")
        arcadeplus.draw_point(SCREEN_WIDTH // 2, current_y,
                              arcadeplus.color.RED, 5)

        current_y -= LINE_HEIGHT
        arcadeplus.draw_text("Test Text Anchor Center",
                             SCREEN_WIDTH // 2,
                             current_y,
                             arcadeplus.color.BLACK,
                             12,
                             anchor_y="center")
        arcadeplus.draw_point(SCREEN_WIDTH // 2, current_y,
                              arcadeplus.color.RED, 5)

        current_y -= LINE_HEIGHT
        arcadeplus.draw_text("Test Text Anchor Bottom",
                             SCREEN_WIDTH // 2,
                             current_y,
                             arcadeplus.color.BLACK,
                             12,
                             anchor_y="bottom")
        arcadeplus.draw_point(SCREEN_WIDTH // 2, current_y,
                              arcadeplus.color.RED, 5)

        field_width = SCREEN_WIDTH
        current_y -= LINE_HEIGHT
        arcadeplus.draw_text(f"Test Text Field Width {field_width}",
                             current_x,
                             current_y,
                             arcadeplus.color.BLACK,
                             12,
                             font_name="arial",
                             width=field_width)

        current_y -= LINE_HEIGHT
        arcadeplus.draw_text(f"Centered Test Text Field Width {field_width}",
                             current_x,
                             current_y,
                             arcadeplus.color.BLACK,
                             12,
                             font_name="arial",
                             width=field_width,
                             align="center")

        current_y -= LINE_HEIGHT
        font_name = "comic"
        arcadeplus.draw_text("Different font",
                             current_x,
                             current_y,
                             arcadeplus.color.BLACK,
                             12,
                             font_name=font_name)

        current_y -= LINE_HEIGHT
        # noinspection PyDeprecation
        text = arcadeplus.create_text("Create text", arcadeplus.color.BLACK)
        # noinspection PyDeprecation
        arcadeplus.render_text(text, current_x, current_y)
Ejemplo n.º 22
0
 def on_draw(self):
     arcadeplus.start_render()
     arcadeplus.draw_text("Menu Screen - click to advance", WIDTH/2, HEIGHT/2,
                      arcadeplus.color.BLACK, font_size=30, anchor_x="center")
Ejemplo n.º 23
0
 def on_draw(self):
     arcadeplus.start_render()
     arcadeplus.draw_text("Game - press SPACE to advance", WIDTH/2, HEIGHT/2,
                      arcadeplus.color.BLACK, font_size=30, anchor_x="center")
Ejemplo n.º 24
0
 def on_draw(self):
     arcadeplus.start_render()
     arcadeplus.draw_text("Instructions Screen", WIDTH/2, HEIGHT/2,
                      arcadeplus.color.BLACK, font_size=50, anchor_x="center")
     arcadeplus.draw_text("Click to advance", WIDTH/2, HEIGHT/2-75,
                      arcadeplus.color.GRAY, font_size=20, anchor_x="center")
Ejemplo n.º 25
0
 def on_draw(self):
     arcadeplus.start_render()
     arcadeplus.draw_text("Game Over - press ESCAPE to advance", WIDTH/2, HEIGHT/2,
                      arcadeplus.color.WHITE, 30, anchor_x="center")
Ejemplo n.º 26
0
arcadeplus.set_background_color(arcadeplus.color.WHITE)

# Start the render process. This must be done before any drawing commands.
arcadeplus.start_render()

# Draw a grid
# Draw vertical lines every 120 pixels
for x in range(0, 601, 120):
    arcadeplus.draw_line(x, 0, x, 600, arcadeplus.color.BLACK, 2)

# Draw horizontal lines every 200 pixels
for y in range(0, 601, 200):
    arcadeplus.draw_line(0, y, 800, y, arcadeplus.color.BLACK, 2)

# Draw a point
arcadeplus.draw_text("draw_point", 3, 405, arcadeplus.color.BLACK, 12)
arcadeplus.draw_point(60, 495, arcadeplus.color.RED, 10)

# Draw a set of points
arcadeplus.draw_text("draw_points", 123, 405, arcadeplus.color.BLACK, 12)
point_list = ((165, 495), (165, 480), (165, 465), (195, 495), (195, 480),
              (195, 465))
arcadeplus.draw_points(point_list, arcadeplus.color.ZAFFRE, 10)

# Draw a line
arcadeplus.draw_text("draw_line", 243, 405, arcadeplus.color.BLACK, 12)
arcadeplus.draw_line(270, 495, 300, 450, arcadeplus.color.WOOD_BROWN, 3)

# Draw a set of lines
arcadeplus.draw_text("draw_lines", 363, 405, arcadeplus.color.BLACK, 12)
point_list = ((390, 450), (450, 450), (390, 480), (450, 480), (390, 510),
Ejemplo n.º 27
0
 def on_draw(self):
     arcadeplus.start_render()
     super().on_draw()
     if self.text:
         arcadeplus.draw_text(f"Hello {self.text}", 400, 100,
                              arcadeplus.color.BLACK, 24)