Beispiel #1
18
    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 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.
    arcade.start_render()

    # Draw a rectangle.
    # For a full list of colors see:
    # http://pythonhosted.org/arcade/arcade.color.html
    arcade.draw_rectangle_filled(on_draw.center_x, on_draw.center_y,
                                 RECT_WIDTH, RECT_HEIGHT,
                                 arcade.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
Beispiel #3
0
def main():
    """
    This is the main program.
    """

    # Open the window
    arcade.open_window("Drawing With Functions", SCREEN_WIDTH, SCREEN_HEIGHT)

    # Start the render process. This must be done before any drawing commands.
    arcade.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)
    draw_bird(175, 450)
    draw_bird(525, 475)
    draw_bird(415, 475)

    # My drawing of PACMAN
    arcade.draw_arc_filled(225, 230, 36, 36,
                       arcade.color.YELLOW, 90, 360, -45)


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

    # Keep the window up until someone closes it.
    arcade.run()
def main():
    """
    This is the main program.
    """

    # Open the window
    arcade.open_window("Drawing With Functions", 600, 600)

    # Start the render process. This must be done before any drawing commands.
    arcade.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
    arcade.finish_render()

    # Keep the window up until someone closes it.
    arcade.run()
Beispiel #5
0
    def on_draw(self):
        """
        Render the screen.
        """
        arcade.start_render()

        self.player.draw()
Beispiel #6
0
def draw(dt):
    """ 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()

    # Draw our rectangle
    arcade.draw_circle_filled(draw.x, draw.y, CIRCLE_RADIUS,
                              arcade.color.BLACK)

    # Modify rectangles position based on the delta
    # vector. (Delta means change. You can also think
    # of this as our speed and direction.)
    draw.x += draw.delta_x
    draw.y += draw.delta_y

    draw.delta_y -= GRAVITY_CONSTANT

    # Figure out if we hit the left or right edge and need to reverse.
    if draw.x < CIRCLE_RADIUS and draw.delta_x < 0:
        draw.delta_x *= -BOUNCINESS
    elif draw.x > SCREEN_WIDTH - CIRCLE_RADIUS and draw.delta_x > 0:
        draw.delta_x *= -BOUNCINESS

    # See if we hit the bottom
    if draw.y < CIRCLE_RADIUS and draw.delta_y < 0:
        # If we bounce with a decent velocity, do a normal bounce.
        # Otherwise we won't have enough time resolution to accurate represent
        # the bounce and it will bounce forever. So we'll divide the bounciness
        # by half to let it settle out.
        if draw.delta_y * -1 > GRAVITY_CONSTANT * 15:
            draw.delta_y *= -BOUNCINESS
        else:
            draw.delta_y *= -BOUNCINESS / 2
Beispiel #7
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.
        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)
Beispiel #8
0
    def on_draw(self):
        """
        Render the screen.
        """
        arcade.start_render()

        for shape in self.shape_list:
            shape.draw()
Beispiel #9
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.
        arcade.start_render()
Beispiel #10
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 an stop render command.
    arcade.start_render()

    # Draw shapes
    arcade.draw_all(shapes)
Beispiel #11
0
    def on_draw(self):
        """
        Render the screen.
        """

        # This command has to happen before we start drawing
        arcade.start_render()
        for a in self.object_list:
            a.draw()
Beispiel #12
0
    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)
Beispiel #13
0
    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)
Beispiel #14
0
    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)
Beispiel #15
0
    def on_draw(self):
        """
        Render the screen.
        """

        # This command is necessary before drawing
        arcade.start_render()

        # Draw the current position of each snowflake
        for snowflake in self.snowflake_list:
            arcade.draw_circle_filled(snowflake.x, snowflake.y,
                                      snowflake.size, arcade.color.WHITE)
Beispiel #16
0
    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)
Beispiel #17
0
    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)
Beispiel #18
0
    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)
Beispiel #19
0
    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)
Beispiel #20
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.
        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)
Beispiel #22
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.
        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()

        if self.current_state == INSTRUCTIONS_PAGE_0:
            self.draw_instructions_page(0)

        elif self.current_state == INSTRUCTIONS_PAGE_1:
            self.draw_instructions_page(1)

        elif self.current_state == GAME_RUNNING:
            self.draw_game()

        else:
            self.draw_game()
            self.draw_game_over()
Beispiel #24
0
def on_draw(delta_time):
    arcade.start_render()

    #Appear in first column
    arcade.draw_circle_filled(100, 100, 50, arcade.color.YELLOW)
    
    #Appear in second column
    arcade.draw_small_filled_circle(300, 100, arcade.color.YELLOW)
    arcade.draw_medium_filled_circle(300, 300, arcade.color.YELLOW)
    arcade.draw_large_filled_circle(300, 500, arcade.color.YELLOW)
    
    #Appear in third column    
    arcade.draw_standard_circle(500, 100, arcade.color.YELLOW, "LARGE", "filled")
    arcade.draw_standard_circle(500, 300, arcade.color.YELLOW, "m", "filled")
    arcade.draw_standard_circle(500, 500, arcade.color.YELLOW, "small", "filled")
    
    #Appear in fourth column
    arcade.draw_circle_outline(700, 300, 50, arcade.color.YELLOW)
    
    arcade.draw_circle(700, 100, 50, arcade.color.YELLOW)
Beispiel #25
0
def on_draw(delta_time):
    """ Use this function to draw everything to the screen. """

    # Move the angle of the sweep.
    on_draw.angle += RADIANS_PER_FRAME

    # Calculate the end point of our radar sweep. Using math.
    x = SWEEP_LENGTH * math.sin(on_draw.angle) + CENTER_X
    y = SWEEP_LENGTH * math.cos(on_draw.angle) + CENTER_Y

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

    # Draw the radar line
    arcade.draw_line(CENTER_X, CENTER_Y, x, y, arcade.color.OLIVE, 2)

    # Draw the outline of the radar
    arcade.draw_circle_outline(CENTER_X, CENTER_Y, SWEEP_LENGTH,
                               arcade.color.DARK_GREEN, 3)
Beispiel #26
0
def main():
    """
    This is the main program.
    """

    # Open the window
    arcade.open_window("Drawing With Loops", SCREEN_WIDTH, SCREEN_HEIGHT)

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

    # Call our drawing functions.
    draw_background()

    # Loop to draw ten birds in random locations.
    for bird_count in range(10):
        # Any random x from 0 to the width of the screen
        x = random.randrange(0, SCREEN_WIDTH)

        # Any random y from in the top 2/3 of the screen.
        # No birds on the ground.
        y = random.randrange(SCREEN_HEIGHT / 3, SCREEN_HEIGHT - 20)

        # Draw the bird.
        draw_bird(x, y)

    # Draw the top row of trees
    for x in range(45, SCREEN_WIDTH, 90):
        draw_pine_tree(x, SCREEN_HEIGHT / 3)

    # Draw the bottom row of trees
    for x in range(65, SCREEN_WIDTH, 90):
        draw_pine_tree(x, (SCREEN_HEIGHT / 3) - 120)

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

    # Keep the window up until someone closes it.
    arcade.run()
Beispiel #27
0
    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)
Beispiel #28
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 an stop render command.
    arcade.start_render()

    # Draw shapes
    on_draw.rectangle.draw()
    on_draw.oval.draw()
    on_draw.ellipse.draw()
    on_draw.circle.draw()
    on_draw.square.draw()
    arcade.draw_all(shapes)

    #update shape positions
    on_draw.rectangle.update()
    on_draw.oval.update()
    on_draw.ellipse.update()
    on_draw.circle.update()
    on_draw.square.update()
    arcade.update_all(shapes)
Beispiel #29
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 an stop render command.
    arcade.start_render()

    # Draw our rectangle
    arcade.draw_rectangle_filled(on_draw.x, on_draw.y,
                            RECT_WIDTH, RECT_HEIGHT,
                            arcade.color.BLACK)

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

    # Figure out if we hit the edge and need to reverse.
    if on_draw.x < RECT_WIDTH // 2 or on_draw.x > SCREEN_WIDTH - RECT_WIDTH // 2:
        on_draw.delta_x *= -1
    if on_draw.y < RECT_HEIGHT // 2 or on_draw.y > SCREEN_HEIGHT - RECT_HEIGHT // 2:
        on_draw.delta_y *= -1
Beispiel #30
0
    def on_draw(self):
        """
        Render the screen.
        """

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

        # Draw the grid
        for row in range(10):
            for column in range(10):
                # Figure out what color to draw the box
                if self.grid[row][column] == 1:
                    color = arcade.color.GREEN
                else:
                    color = arcade.color.WHITE

                # Do the math to figure out where the box is
                x = (MARGIN + WIDTH) * column + MARGIN + WIDTH // 2
                y = (MARGIN + HEIGHT) * row + MARGIN + HEIGHT // 2

                # Draw the box
                arcade.draw_rectangle_filled(x, y, WIDTH, HEIGHT, color)
Beispiel #31
0
 def on_draw(self):
     arcade.start_render()
     # Code to draw the screen goes here
     self.wall_list.draw()
     self.player_list.draw()
     self.entities_list.draw()
 def on_draw(self):
     """ Called when it is time to draw the world """
     arcade.start_render()
     self.pic_list.draw()
     arcade.draw_text(f"Points: {self.points}", 20, 50, arcade.color.WHITE,
                      14)
Beispiel #33
0
 def on_draw(self):
     arcade.start_render()
     arcade.draw_text("Menu Screen", WIDTH/2, HEIGHT/2,
                      arcade.color.BLACK, font_size=50, anchor_x="center")
     arcade.draw_text("Click to advance.", WIDTH/2, HEIGHT/2-75,
                      arcade.color.GRAY, font_size=20, anchor_x="center")
Beispiel #34
0
 def setup(self):
     ui_manager.purge_ui_elements()
     arcade.start_render()
     button = GameViewButton('Play', center_x=650, center_y=400, width=250)
     ui_manager.add_ui_element(button)
 def on_draw(self):
     """ Called when it is time to draw the world """
     arcade.start_render()
     self.logo_list.draw()
Beispiel #36
0
 def on_draw(self):
     arcade.start_render()
     self.sprites.draw()
Beispiel #37
0
 def on_draw(self):
     arcade.start_render()
     for b in self.ball_list:
         b.draw()
Beispiel #38
0
 def on_draw(self):
     arcade.start_render()
     self.apple_list.draw()
     self.snake_list.draw()
     output = f"Score: {self.score}"
     arcade.draw_text(output, 10, 20, arcade.color.BLACK, 14)
Beispiel #39
0
#!/usr/bin/env python3

import utils, open_color, arcade

utils.check_version((3, 7))

# Open the window. Set the window title and dimensions (width and height)
arcade.open_window(800, 600, "Smiley Face Example")
arcade.set_background_color(open_color.white)
# Start the render process. This must be done before any drawing commands.
arcade.start_render()

face_x, face_y = (400, 300)

# Draw the smiley face:
# (x,y,radius,color)
arcade.draw_circle_filled(face_x, face_y, 100, open_color.yellow_3)
# (x,y,radius,color,border_thickness)
arcade.draw_circle_outline(face_x + 0, face_y + 0, 100, open_color.black, 4)

#(x,y,width,height,color)
arcade.draw_ellipse_filled(face_x - 40, face_y + 25, 15, 25, open_color.black)
arcade.draw_ellipse_filled(face_x + 40, face_y + 25, 15, 25, open_color.black)
arcade.draw_circle_filled(face_x + 45, face_y + 40, 3, open_color.gray_2)
arcade.draw_circle_filled(face_x - 35, face_y + 40, 3, open_color.gray_2)

#(x,y,width,height,color,start_degrees,end_degrees,border_thickness)
arcade.draw_arc_outline(face_x + 0, face_y - 25, 60, 50, open_color.black, 190,
                        350, 4)

# Finish the render
Beispiel #40
0
 def on_draw(self):
     arcade.start_render()
     self.particle_list.draw()
 def on_draw(self):
     arcade.start_render()
     # Code to draw the screen goes here
     self.star_liste.draw()
     self.player_liste.draw()
     arcade.draw_text("Hallo world",10, SCREEN_HEIGHT -20, arcade.color.WHITE)
Beispiel #42
0
    def on_draw(self):
        arcade.start_render()
        if self.page_number == 0:
            arcade.draw_circle_filled(50, 50, 500, arcade.color.WHITE)
            arcade.set_background_color(arcade.color.GRAY)
            if time() - self.time_check >= 1:
                self.motion = randint(0, 2)
                self.time_check = time()
            pic = [
                arcade.load_texture('pics/menu/menu1.png'),
                arcade.load_texture('pics/menu/menu2.png', ),
                arcade.load_texture('pics/menu/menu3.png')
            ]
            # For menu pic
            for each_pic in pic:
                self.set_center(each_pic)
            arcade.draw_texture_rectangle(pic[self.motion].center_x,
                                          pic[self.motion].center_y,
                                          texture=pic[self.motion],
                                          height=700,
                                          width=900)
            #For 1.3.7
            #arcade.draw_text('Press ENTER to start the game', 0, 100, arcade.color.AMETHYST, width=self.width,
            #                    font_size=35)
            arcade.draw_text('Press ENTER to start the game',
                             0,
                             100,
                             arcade.color.AMETHYST,
                             font_size=35)
            arcade.draw_text('Just An Ordinary Dungeon Crawler game',
                             0,
                             200,
                             arcade.color.GOLD_FUSION,
                             font_size=50,
                             width=3500)

        elif self.page_number == -1:
            self.menu.draw()

        elif self.page_number == 1:
            arcade.draw_texture_rectangle(self.bg.center_x,
                                          self.bg.center_y,
                                          texture=self.bg,
                                          height=600,
                                          width=800)
            self.player.draw()
            self.enemy_type.draw()
            self.player.attack(self.time_check)
            self.map.map_component()
            arcade.draw_text(f'The current level is {self.level}',
                             self.width - 200, self.height - 100,
                             arcade.color.BLACK)
            arcade.draw_text(f'Current life {self.player.life}', 100,
                             self.height - 100, arcade.color.BLACK)
            arcade.draw_text(f'Current Money {self.MONEY}',
                             self.width // 2 - 50, self.height - 100,
                             arcade.color.BLACK)
            self.shield.draw()
            if self.hurt_status:
                arcade.draw_rectangle_outline(self.width // 2,
                                              self.height // 2, self.width,
                                              self.height, arcade.color.RED,
                                              10)
                if time() - self.hurt_time >= 1.5:
                    self.hurt_status = False

        elif self.page_number == -3 or self.page_number == -2:
            tutorial = arcade.load_texture('pics/scene/t2.png')
            if self.page_number == -2:
                tutorial = arcade.load_texture('pics/scene/t1.png')
            self.set_center(tutorial)
            arcade.draw_texture_rectangle(tutorial.center_x,
                                          tutorial.center_y,
                                          texture=tutorial,
                                          height=600,
                                          width=800)

        elif self.page_number == 3:
            bonus = arcade.load_texture('pics/game_over/game.png')
            self.set_center(bonus)
            arcade.draw_texture_rectangle(bonus.center_x,
                                          bonus.center_y,
                                          texture=bonus,
                                          height=700,
                                          width=900)
        self.dialog.on_draw(self.dialog_status)
Beispiel #43
0
 def on_draw(self):
     arcade.start_render()
Beispiel #44
0
 def on_draw(self):
     """ Called whenever we need to draw the window. """
     arcade.start_render()
     self.ball.draw()
Beispiel #45
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.
        arcade.start_render()

        arcade.draw_text(str(self.fps), 0.97 * SCREEN_WIDTH,
                         0.97 * SCREEN_HEIGHT, arcade.color.WHITE, 20)

        if not self.game_finished:
            arcade.draw_rectangle_filled(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2,
                                         5, SCREEN_HEIGHT, (46, 46, 46))

            for ball in self.ball_list:
                arcade.draw_circle_filled(ball.x, ball.y, ball.radius,
                                          ball.colour)

            for paddle in self.paddles:
                arcade.draw_rectangle_filled(paddle.x, paddle.y, paddle.width,
                                             paddle.height, paddle.colour)

            self.player1points_texture = points[self.player1points]
            self.player2points_texture = points[self.player2points]

            arcade.draw_texture_rectangle(
                SCREEN_WIDTH // 2 - 50, SCREEN_HEIGHT - 50,
                self.player1points_texture.width * self.scale,
                self.player1points_texture.height * self.scale,
                self.player1points_texture)
            arcade.draw_texture_rectangle(
                SCREEN_WIDTH // 2 + 50, SCREEN_HEIGHT - 50,
                self.player2points_texture.width * self.scale,
                self.player2points_texture.height * self.scale,
                self.player2points_texture)

        if self.player1points == 9:
            self.win_texture = win_textures[0]
            arcade.draw_texture_rectangle(SCREEN_WIDTH // 2,
                                          SCREEN_HEIGHT // 2,
                                          self.win_texture.width,
                                          self.win_texture.height,
                                          self.win_texture)
            self.game_finished = True
            if not self.report_written:
                with open("Results.txt", "a") as f:
                    f.write(
                        "\n{} vs {} on {} at {}. {} won with a score of {} - {}."
                        .format(player1name, player2name, date, time_started,
                                player1name, self.player1points,
                                self.player2points))
                    self.report_written = True

        if self.player2points == 9:
            self.win_texture = win_textures[1]
            arcade.draw_texture_rectangle(SCREEN_WIDTH // 2,
                                          SCREEN_HEIGHT // 2,
                                          self.win_texture.width,
                                          self.win_texture.height,
                                          self.win_texture)
            self.game_finished = True
            if not self.report_written:
                with open("Results.txt", "a") as f:
                    f.write(
                        "\n{} vs {} on {} at {}. {} won with a score of {} - {}."
                        .format(player1name, player2name, date, time_started,
                                player2name, self.player1points,
                                self.player2points))
                    self.report_written = True
Beispiel #46
0
 def on_draw(self):
     """ Render the screen. """
     arcade.start_render()