Пример #1
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
Пример #2
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)
Пример #3
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)
Пример #4
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)
Пример #5
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)
# Top of 300, bottom of 0
arcade.draw_lrtb_rectangle_filled(0, 599, 300, 0, arcade.csscolor.GREEN)
# Tree trunk
# Center of 100, 320
# Width of 20
# Height of 60
arcade.draw_rectangle_filled(0, 320, 20, 60, arcade.csscolor.SIENNA)
arcade.draw_rectangle_filled(100, 320, 20, 60, arcade.csscolor.SIENNA)
arcade.draw_rectangle_filled(200, 320, 20, 60, arcade.csscolor.SIENNA)
arcade.draw_rectangle_filled(300, 320, 20, 60, arcade.csscolor.SIENNA)
arcade.draw_rectangle_filled(400, 320, 20, 60, arcade.csscolor.SIENNA)
arcade.draw_rectangle_filled(500, 320, 20, 60, arcade.csscolor.SIENNA)
arcade.draw_rectangle_filled(600, 320, 20, 60, arcade.csscolor.SIENNA)
# Tree top
arcade.draw_ellipse_filled(0, 370, 60, 80, arcade.csscolor.DARK_GREEN)
arcade.draw_circle_filled(100, 350, 30, arcade.csscolor.DARK_GREEN)
arcade.draw_ellipse_filled(200, 370, 60, 80, arcade.csscolor.DARK_GREEN)
#arcade.draw_circle_filled(300, 350, 30, arcade.csscolor.DARK_GREEN)
arcade.draw_arc_filled(300, 340, 60, 100, arcade.csscolor.DARK_GREEN, 0, 180)
arcade.draw_triangle_filled(400, 400, 370, 320, 430, 320,
                            arcade.csscolor.DARK_GREEN)
arcade.draw_polygon_filled(
    ((500, 400), (480, 360), (470, 320), (530, 320), (520, 360)),
    arcade.csscolor.DARK_GREEN)
arcade.draw_ellipse_filled(600, 370, 60, 80, arcade.csscolor.DARK_GREEN)
# Draw a sun
arcade.draw_circle_filled(500, 550, 40, arcade.color.YELLOW)

# Rays to the left, right, up, and down
arcade.draw_line(500, 550, 400, 550, arcade.color.YELLOW, 3)
arcade.draw_line(500, 550, 600, 550, arcade.color.YELLOW, 3)
Пример #7
0
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
# Nothing will be drawn without this.
Пример #8
0
import arcade
import random

high = 600
width = 600

xPos = width / 2
yPos = high / 2
radius = 15

arcade.open_window(high, width, "Drawing Example")
arcade.set_background_color(arcade.color.DEEP_JUNGLE_GREEN)

while True:
    xSpeedVector = random.randint(-3, 3)
    ySpeedVector = random.randint(-3, 3)

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

    arcade.draw_circle_filled(xPos, yPos, radius, arcade.color.RED_DEVIL)

    xPos = xPos + xSpeedVector
    yPos = yPos + ySpeedVector

    arcade.finish_render()

arcade.run()
Пример #9
0
 def draw(self):
     arcade.draw_circle_filled(self.x, self.y, self.radius, self.color)
 def draw_star(self):
     arcade.draw_circle_filled(self.pos_x,self.pos_y,self.radius,self.col)
Пример #11
0
Somewhere you must include a WHILE or FOR loop to create a repeating pattern.
Do not just redraw the same thing in the same location 10 times. 
You can contain multiple drawing commands in a loop, so you can draw multiple train cars for example.
Please use comments and blank lines to make it easy to follow your program. 
If you have 5 lines that draw a robot, group them together with blank lines above and below. 
Then add a comment at the top telling the reader what you are drawing.
After you have showed your picture to your instructor, screenshot your picture,
name it firstname_lastname.jpg and use the submit button to e-mail it to your instructor
'''
import arcade, random
circle_x = 0
arcade.open_window(500, 500, "Picasso Project")  #Creates the window
arcade.set_background_color(
    arcade.color.SKY_BLUE)  #Makes background color sky color
arcade.start_render()
arcade.draw_circle_filled(300, 400, 100, arcade.color.SUNGLOW)

for i in range(6):  #Generates Clouds
    y = random.randrange(200, 450)
    x = random.randrange(1, 501)
    for i in range(random.randrange(4, 8)):
        arcade.draw_circle_filled(x, y, 30, arcade.color.LIGHT_GRAY)
        x += 30

for i in range(1):  #Generates the grass
    for i in range(25):
        arcade.draw_circle_filled(circle_x, 25, 25, arcade.color.GO_GREEN)
        circle_x += 25

arcade.draw_rectangle_filled(250, 0, 500, 50, arcade.color.GO_GREEN)
arcade.finish_render()
Пример #12
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)
Пример #13
0
 def draw(self):
     self.image = arcade.draw_circle_filled(self.x, self.y, self.radius,
                                            arcade.color.SPANISH_CRIMSON)
Пример #14
0
arcade.draw_text("draw_polygon_filled", 123, 207, arcade.color.WHITE, 9)
point_list = ((150, 240),
              (165, 240),
              (180, 255),
              (180, 285),
              (165, 300),
              (150, 300))
arcade.draw_polygon_filled(point_list, arcade.color.SPANISH_VIOLET)

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

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

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

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

# Draw an arc, and another one rotated
arcade.draw_text("draw_arc/filled_arc", 123, 3, arcade.color.WHITE, 10)
Пример #15
0
#changing the increment, more or less faces will be drawn.
#Changing the last number determines how often a face is drawn and how close they are together
#start at 100, go to 799, counting by 150
for x in range(100, 800, 150):
    #start at 100, go to 599, counting by 150
    for y in range(100, 600, 150):
        face_x, face_y = (x, y)
        smile_x, smile_y = (face_x + 0, face_y - 0)
        eye1_x, eye1_y = (face_x - 30, face_y + 50)
        eye2_x, eye2_y = (face_x + 30, face_y + 50)
        catch1_x, catch1_y = (face_x - 25, face_y + 63)
        catch2_x, catch2_y = (face_x + 35, face_y + 63)

        # 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, face_y, 100, open_color.black, 4)

        #(x,y,width,height,color)
        #Again, changed size of eyes to match example
        arcade.draw_ellipse_filled(eye1_x, eye1_y, 30, 50, open_color.black)
        arcade.draw_ellipse_filled(eye2_x, eye2_y, 30, 50, open_color.black)
        arcade.draw_circle_filled(catch1_x, catch1_y, 3, open_color.gray_2)
        arcade.draw_circle_filled(catch2_x, catch2_y, 3, open_color.gray_2)

        #(x,y,width,height,color,start_degrees,end_degrees,border_thickness)
        arcade.draw_arc_outline(smile_x, smile_y, 60, 50, open_color.black,
                                190, 350, 4)

# Finish the render
Пример #16
0
point_list = ((150, 240),
              (165, 240),
              (180, 255),
              (180, 285),
              (165, 300),
              (150, 300))
arcade.draw_polygon_filled(point_list, arcade.color.RED) 

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


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

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

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

# Draw an arc, and another one rotated
arcade.draw_text("draw_arc/filled_arc", 123, 3, arcade.color.BLACK, 10)
arcade.draw_arc_outline(150, 81, 15, 36, arcade.color.BRIGHT_MAROON, 90, 360)
arcade.draw_arc_filled(150, 144, 15, 36, arcade.color.BOTTLE_GREEN, 90, 360, 45)
Пример #17
0
def draw_point(p: Point, color: tuple = POINT_COLOR, size: int = POINT_SIZE):
    arcade.draw_circle_filled(*p, size, color=color)
Пример #18
0
def draw_ball(x, y, z):
    arcade.draw_circle_filled(200 + x, 200 + y, 40 + z, arcade.color.RED_ORANGE)
    # arcade.draw_circle_filled(250 + x, 200 + y, 30 + z, arcade.color.BABY_BLUE_EYES)
    arcade.draw_circle_filled(300 + x, 200 + y, 30 + z, arcade.color.PINK_LAVENDER)
Пример #19
0
 def draw(self):
     arcade.draw_circle_filled(self.position.x, self.position.y, self.radius, self.color)
     return
Пример #20
0
import arcade
import os

#arcade uses pixels to measure eveything, so the below line of code
#create a game window that is 600 pixels wide and 600 pixels high
#the last variable gives the window its name
arcade.open_window(600, 600, "ArcadeIntroduction")

#you need this line of code to start drawing
arcade.start_render()

#this is where you type all the code you want to use to draw
#try and work out what each number does
#http://arcade.academy/arcade.html#drawing-commands may give you some hints
arcade.draw_circle_filled(300, 300, 200, arcade.color.BLACK)

#this command tells the program you are done writing all your drawing commands
arcade.finish_render()

#this line runs your game
arcade.run()
Пример #21
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
Пример #22
0
def draw_cheek(x, y):
    """ Draw a cheek """
    arcade.draw_circle_filled(x, y, 73, (194, 125, 58))
Пример #23
0
    def on_draw(self):
        """ Called whenever we need to draw the window. """
        arcade.start_render()

        arcade.draw_circle_filled(self.ball_x, self.ball_y, 15, arcade.color.AUBURN)
Пример #24
0
 def draw(self):
     """
     Draw the rectangle
     """
     arcade.draw_circle_filled(self.position[0], self.position[1],
                               self.radius, self.color)
Пример #25
0
def draw_face():
    """ Draw the face """
    arcade.draw_circle_filled(300, 300, 200, arcade.csscolor.PERU)
Пример #26
0
 def draw(self):
     """ Draw the balls with the instance variables we have. """
     arcade.draw_circle_filled(self.position_x, self.position_y,
                               self.radius, self.color)
Пример #27
0
 def draw(self):
     #arcade.draw_rectangle_filled(self.display_x, self.display_y, (self.radius/Balls.scale)+15, (self.radius/Balls.scale)+15,self.colour)
     arcade.draw_circle_filled(self.display_x, self.display_y,
                               self.radius / Balls.scale + 3, self.colour)
Пример #28
0
 def draw(self):
     arcade.draw_circle_filled(self.position[0], self.position[1],
                               self.radius, self.color)
Пример #29
0
COLUMN_SPACING = 20
ROW_SPACING = 20
LEFT_MARGIN = 110
BOTTOM_MARGIN = 110

# Open the window and set the background
arcade.open_window(400, 400, "Complex Loops - Top Right Triangle")

arcade.set_background_color(arcade.color.WHITE)

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

# Loop for each row
for row in range(10):
    # Loop for each column
    # Change the number of columns depending on the row we are in
    for column in range(9 - row, 10):
        # Calculate our location
        x = column * COLUMN_SPACING + LEFT_MARGIN
        y = row * ROW_SPACING + BOTTOM_MARGIN

        # Draw the item
        arcade.draw_circle_filled(x, y, 7, arcade.color.AO)

# Finish the render.
arcade.finish_render()

# Keep the window up until someone closes it.
arcade.run()