Ejemplo n.º 1
0
def on_draw():
    global toolbar, frames, current_frame, linked_scenes

    # Render entire toolbar, all user-drawn shapes
    arcadeplus.start_render()

    if (current_frame - 1) in linked_scenes.keys():
        background_texture = arcadeplus.load_texture(
            "data/scenes/" + linked_scenes[current_frame - 1] + ".png")
        arcadeplus.draw_texture_rectangle(center_x=500,
                                          center_y=400,
                                          width=800,
                                          height=800,
                                          texture=background_texture)
    try:
        frames[current_frame - 1].draw()
    except Exception as e:
        pass
    try:
        toolbar.draw()
    except Exception as e:
        pass

    render_toolbar_icons()
    render_toolbar_text()
def on_draw():
    arcade.start_render()
    arcade.draw_rectangle_filled(WIDTH * 1 / 5 + 20, HEIGHT / 4 + 30, 640, 480, arcade.color.LIGHT_GREEN)
    for i in range(len(ball_pos)):
        arcade.draw_circle_filled(ball_pos[i][0], ball_pos[i][1], 5, ball_pos[i][2])
    for i in range(len(history)):
        arcade.draw_line(ball_pos[history[i][0]][0], ball_pos[history[i][0]][1], ball_pos[history[i][1]][0],
                         ball_pos[history[i][1]][1], arcade.color.RED)
    arcade.draw_circle_filled(10, 740, 5, arcade.color.BLACK)  # Unaffected
    arcade.draw_circle_filled(10, 720, 5, arcade.color.RED)  # Infected
    arcade.draw_circle_filled(10, 700, 5, arcade.color.GRAY)  # Cured
    arcade.draw_circle_filled(10, 680, 5, arcade.color.YELLOW)  # Dead
    arcade.draw_text(
        f'Number unaffected: {population - len(history) - 1}\nNumber infected: {(len(history) + 1)-CURED-DEAD}\nNumber cured: {CURED}\nNumber deceased: {DEAD}\nTime elapsed: {(time_elapsed):.2f}',
        20, HEIGHT / 2 + 200,
        arcade.color.BLACK, 18)
    if not start:
        draw_button(WIDTH - 100, 50, 100, 30, arcade.color.GREEN, 'Start', arcade.color.LIGHT_GREEN, arcade.color.RED)
    else:
        draw_button(WIDTH - 100, 50, 100, 30, arcade.color.GREEN, 'Pause', arcade.color.LIGHT_GREEN, arcade.color.RED)
    sliders()
    sliders1()
    sliders2()
    draw_reset_button(WIDTH / 2, HEIGHT / 2 - 300, 150, 50, arcade.color.RED, "Reset", arcade.color.SALMON_PINK,
                      arcade.color.PINK)
    graph()
Ejemplo n.º 3
0
    def on_draw(self):
        """
        Render the screen.
        """

        arcadeplus.start_render()

        # Get viewport dimensions
        left, screen_width, bottom, screen_height = self.get_viewport()

        text_size = 18
        # Draw text on the screen so the user has an idea of what is happening
        arcadeplus.draw_text(
            "Press F to toggle between full screen and windowed mode, unstretched.",
            screen_width // 2,
            screen_height // 2 - 20,
            arcadeplus.color.WHITE,
            text_size,
            anchor_x="center")
        arcadeplus.draw_text(
            "Press S to toggle between full screen and windowed mode, stretched.",
            screen_width // 2,
            screen_height // 2 + 20,
            arcadeplus.color.WHITE,
            text_size,
            anchor_x="center")

        # Draw some boxes on the bottom so we can see how they change
        for x in range(64, 800, 128):
            y = 64
            width = 128
            height = 128
            arcadeplus.draw_texture_rectangle(x, y, width, height,
                                              self.example_image)
Ejemplo n.º 4
0
def on_draw(delta_time):
    """
    Use this function to draw everything to the screen.
    """

    # Start the render. This must happen before any drawing
    # commands. We do NOT need a stop render command.
    arcadeplus.start_render()

    # Draw a rectangle.
    # For a full list of colors see:
    # http://arcadeplus.academy/arcadeplus.color.html
    arcadeplus.draw_rectangle_filled(on_draw.center_x, on_draw.center_y,
                                     RECT_WIDTH, RECT_HEIGHT,
                                     arcadeplus.color.ALIZARIN_CRIMSON)

    # Modify rectangles position based on the delta
    # vector. (Delta means change. You can also think
    # of this as our speed and direction.)
    on_draw.center_x += on_draw.delta_x * delta_time
    on_draw.center_y += on_draw.delta_y * delta_time

    # Figure out if we hit the edge and need to reverse.
    if on_draw.center_x < RECT_WIDTH // 2 \
            or on_draw.center_x > SCREEN_WIDTH - RECT_WIDTH // 2:
        on_draw.delta_x *= -1
    if on_draw.center_y < RECT_HEIGHT // 2 \
            or on_draw.center_y > SCREEN_HEIGHT - RECT_HEIGHT // 2:
        on_draw.delta_y *= -1
Ejemplo n.º 5
0
def main():
    """
    This is the main program.
    """

    # Open the window
    arcadeplus.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)

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

    # Call our drawing functions.
    draw_background()
    draw_pine_tree(50, 250)
    draw_pine_tree(350, 320)
    draw_bird(70, 500)
    draw_bird(470, 550)

    # Finish the render.
    # Nothing will be drawn without this.
    # Must happen after all draw commands
    arcadeplus.finish_render()

    # Keep the window up until someone closes it.
    arcadeplus.run()
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.wall_list.draw()
        self.player_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.player_sprite.right
        output = "Distance: {}".format(distance)
        arcadeplus.draw_text(output, self.view_left + 10,
                             self.view_bottom + 20, arcadeplus.color.WHITE, 14)

        if self.game_over:
            output = "Game Over"
            arcadeplus.draw_text(output, self.view_left + 200,
                                 self.view_bottom + 200,
                                 arcadeplus.color.WHITE, 30)
Ejemplo n.º 7
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.º 8
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.º 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 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)

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

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

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

        arcadeplus.start_render()

        # Draw the y labels
        i = 0
        for y in range(START, END, STEP):
            arcadeplus.draw_point(0, y, arcadeplus.color.BLUE, 5)
            arcadeplus.draw_text(f"{y}",
                                 5,
                                 y,
                                 arcadeplus.color.BLACK,
                                 12,
                                 anchor_x="left",
                                 anchor_y="bottom")
            i += 1

        # Draw the x labels.
        i = 1
        for x in range(START + STEP, END, STEP):
            arcadeplus.draw_point(x, 0, arcadeplus.color.BLUE, 5)
            arcadeplus.draw_text(f"{x}",
                                 x,
                                 5,
                                 arcadeplus.color.BLACK,
                                 12,
                                 anchor_x="left",
                                 anchor_y="bottom")
            i += 1
Ejemplo n.º 11
0
    def on_draw(self):
        """
        Render the screen.
        """
        arcadeplus.start_render()

        self.player.draw()
Ejemplo n.º 12
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.º 13
0
    def on_draw(self):
        """ Draw everything """

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

        arcadeplus.start_render()
        for shape in self.shape_list:
            shape.draw()

        # Display info on sprites
        output = f"Shape count: {len(self.shape_list):,}"
        arcadeplus.draw_text(output, 20, SCREEN_HEIGHT - 20,
                             arcadeplus.color.BLACK, 16)

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

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

        fps = self.fps.get_fps()
        output = f"FPS: {fps:3.0f}"
        arcadeplus.draw_text(output, 20, SCREEN_HEIGHT - 80,
                             arcadeplus.color.BLACK, 16)

        self.draw_time = timeit.default_timer() - draw_start_time
        self.fps.tick()
Ejemplo n.º 14
0
def on_draw():
    arcade.start_render()
    # Draw in here...
    # arcade.draw_circle_filled(mouse_x, mouse_y, 25, ball_color)
    arcade.draw_line(0, HEIGHT / 2, WIDTH, HEIGHT / 2, arcade.color.BLACK)
    arcade.draw_line(WIDTH / 2, HEIGHT, WIDTH / 2, 0, arcade.color.BLACK)
    for i in range(WIDTH * 2):
        arcade.draw_point(i, 0.001 * (i - WIDTH / 2)**2, arcade.color.BLUE, 10)
Ejemplo n.º 15
0
    def on_draw(self):
        """Render the screen. """

        arcadeplus.start_render()

        self.enemy_list.draw()
        self.bullet_list.draw()
        self.player_list.draw()
Ejemplo n.º 16
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()
Ejemplo n.º 17
0
    def on_draw(self):
        """
        Render the screen.
        """
        arcadeplus.start_render()

        for shape in self.shape_list:
            shape.draw()
Ejemplo n.º 18
0
    def on_draw(self):
        """ Draw everything """
        arcadeplus.start_render()
        self.all_sprites_list.draw()

        # Put the text on the screen.
        output = f"Score: {self.score}"
        arcadeplus.draw_text(output, 10, 20, arcadeplus.color.WHITE, 14)
Ejemplo n.º 19
0
    def on_draw(self):
        """
        Render the screen.
        """
        # This command has to happen before we start drawing
        arcadeplus.start_render()

        self.shape_list.draw()
Ejemplo n.º 20
0
 def on_draw(self):
     arcadeplus.start_render()
     for e in self.emitters:
         e.draw()
     arcadeplus.draw_lrtb_rectangle_filled(0, SCREEN_WIDTH, 25, 0,
                                           arcadeplus.color.DARK_GREEN)
     mid = SCREEN_WIDTH / 2
     arcadeplus.draw_lrtb_rectangle_filled(mid - 2, mid + 2, SPINNER_HEIGHT,
                                           10, arcadeplus.color.DARK_BROWN)
Ejemplo n.º 21
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.player_list.draw()
Ejemplo n.º 22
0
    def on_draw(self):
        try:
            arcadeplus.start_render()

            assert arcadeplus.get_pixel(50, 50) == (59, 122, 87)
            self.sprite.draw()
            assert arcadeplus.get_pixel(50, 50) == (255, 204, 0)

        except Exception as e:
            assert e is None
Ejemplo n.º 23
0
    def on_draw(self):
        """ Render the screen. """

        # Clear the screen to the background color
        arcadeplus.start_render()

        # Draw our sprites
        self.wall_list.draw()
        self.coin_list.draw()
        self.player_list.draw()
Ejemplo n.º 24
0
    def on_draw(self):
        """Render the screen"""

        arcadeplus.start_render()

        # Text on screen
        text = "Press left mouse to make noise"

        # Render text
        arcadeplus.draw_text(text, 150, 300, arcadeplus.color.WHITE, 30)
Ejemplo n.º 25
0
    def on_draw(self):
        arcadeplus.start_render()
        # Draw all the sprites.
        self.player_list.draw()
        self.coin_list.draw()

        # Put the text on the screen.
        output = f"Score: {self.score}"
        arcadeplus.draw_text(output, 10, 30, arcadeplus.color.WHITE, 14)
        output_total = f"Total Score: {self.window.total_score}"
        arcadeplus.draw_text(output_total, 10, 10, arcadeplus.color.WHITE, 14)
Ejemplo n.º 26
0
def on_draw():
    arcade.start_render()
    # Draw in here...
    # arcade.draw_circle_filled(mouse_x, mouse_y, 25, ball_color)
    for i in range(len(ball_pos)):
        arcade.draw_circle_filled(ball_pos[i][0], ball_pos[i][1], 5, ball_pos[i][2])
    for i in range(len(history)):
        arcade.draw_line(ball_pos[history[i][0]][0], ball_pos[history[i][0]][1], ball_pos[history[i][1]][0],
                         ball_pos[history[i][1]][1], arcade.color.RED)
    arcade.draw_text(f'Number infected: {len(history) + 1}\nTime elapsed: {(time_elapsed):.2f}', 0, 0,
                     arcade.color.BLACK, 18)
Ejemplo n.º 27
0
    def on_draw(self):

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

        # Draw all the sprites.
        self.all_sprites_list.draw()

        # Put the text on the screen.
        output = "Score: " + str(self.score)
        arcadeplus.draw_text(output, 10, 20, arcadeplus.color.WHITE, 14)
Ejemplo n.º 28
0
    def on_draw(self):
        """
        This is called every time we need to update our screen. About 60
        times per second.

        Just draw things in this function, don't update where they are.
        """
        # Call our drawing functions.

        arcadeplus.start_render()
        for mountain_range in self.mountains:
            mountain_range.draw()
Ejemplo n.º 29
0
    def on_draw(self):
        arcadeplus.start_render()
        # Draw all the sprites.
        self.player_sprite.draw()

        # Show tip to pause screen
        arcadeplus.draw_text("Press Esc. to pause",
                             WIDTH / 2,
                             HEIGHT - 100,
                             arcadeplus.color.BLACK,
                             font_size=20,
                             anchor_x="center")
Ejemplo n.º 30
0
    def on_draw(self):
        """
        Render the screen.
        """

        arcadeplus.start_render()

        # Draw the coins
        self.coin_list.draw()

        # Draw the buttons
        for button in self.button_list:
            button.draw()